Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix couple bugs with multiple results and varargs (...) #515

Merged
merged 3 commits into from
Sep 10, 2023
Merged

Fix couple bugs with multiple results and varargs (...) #515

merged 3 commits into from
Sep 10, 2023

Conversation

juntuu
Copy link
Contributor

@juntuu juntuu commented Aug 13, 2023

The vararg.rotate, and both functional.partial and fun.bind (which are the same), had couple mistakes. I'll mention the particular bugs in the diff. For a reference, see: https://www.lua.org/manual/5.4/manual.html#3.4.12.

These fixes make the functions generally correct. Since these bugs have been there from the beginning, the real use is more limited (i.e. bind a single (non nil) parameter, or rotate 1-16 arguments). So another valid fix would be to limit the generality to these already working cases.

Let me know if that would be preferable.

Also let me know if there is some convention I've missed, or if you would like me to document this also on the issues.

lua/plenary/fun.lua Show resolved Hide resolved
lua/plenary/functional.lua Show resolved Hide resolved
lua/plenary/functional.lua Show resolved Hide resolved
scripts/vararg/rotate.lua Show resolved Hide resolved
scripts/vararg/rotate.lua Show resolved Hide resolved
tests/plenary/rotate_spec.lua Show resolved Hide resolved
lua/plenary/vararg/rotate.lua Show resolved Hide resolved
@juntuu
Copy link
Contributor Author

juntuu commented Aug 24, 2023

The test failures seem to be a race condition with filesystem state.

I checked one, and the difference looks like what path tests have created in between. The others were also these tests that use the filesystem state.

-- generate {file}_{level}.lua on every directory level in src
-- src
-- ├── file1_1.lua
-- ├── file2_1.lua
-- ├── .file3_1.lua
-- └── sub_dir1
-- ├── file1_2.lua
-- ├── file2_2.lua
-- ├── .file3_2.lua
-- └── sub_dir2
-- ├── file1_3.lua
-- ├── file2_3.lua
-- └── .file3_3.lua

            Passed in:
            (table: 0x7fd42d9d1230) {
              [1] = '.'
             *[2] = './src'
              [3] = './src/file2_1.lua'
              [4] = './src/file1_1.lua'
              [5] = './src/.file3_1.lua'
              [6] = './src/sub_dir1'
              [7] = './src/sub_dir1/.file3_2.lua'
              [8] = './src/sub_dir1/sub_dir2'
              [9] = './src/sub_dir1/sub_dir2/file1_3.lua'
              [10] = './src/sub_dir1/sub_dir2/.file3_3.lua'
              [11] = './src/sub_dir1/sub_dir2/file2_3.lua'
              [12] = './src/sub_dir1/file2_2.lua'
              [13] = './src/sub_dir1/file1_2.lua'
              [14] = './.styluaignore'
              [15] = './TESTS_README.md'
...
            Expected:
            (table: 0x7fd42da0e418) {
              [1] = '.'
             *[2] = './.styluaignore'
              [3] = './TESTS_README.md'
...

@Conni2461
Copy link
Collaborator

rebase should fix the tests, see f97a076

- zero argument rotation returned one value (a global by the name A0)
- the generic fallback dropped the first argument and trailing nils
These only worked for binding exactly one parameter.
@Conni2461
Copy link
Collaborator

Thanks :)

@Conni2461 Conni2461 merged commit 23deb47 into nvim-lua:master Sep 10, 2023
6 checks passed
@juntuu juntuu deleted the dot-dot-dot branch September 23, 2023 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants