-
Notifications
You must be signed in to change notification settings - Fork 195
WIP: Fix incompatibilities with Lua 5.5 #463
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
base: master
Are you sure you want to change the base?
Conversation
A temporary measure, until argparse gets updated to support 5.5.
Basically, in a few places moonscript will do:
```
tbl = {"foo", nil, "bar", "baz"}
```
And expect `#tbl` to be `4`. While this was never guaranteed behavior in Lua
(the reference manual states that *any* table border can be returned in this
case), under PUC-Rio Lua <5.5 (and LuaJIT, which presumably emulates the
behavior of PUC-Rio Lua 5.1), it would work correctly. However, with the update
to 5.5, this has now broken. As a result, some things that worked under
previous versions no longer do.
I've made changes in 3 places to fix this:
- Added `moon.len`, a function which returns the largest integer key in a table
- Fixed the `unpack` call in `moonscript.transform.class` to unpack indices 2
to 4, instead of leaving the last index as `#node`
- Fixed the `moon.type` test in `spec.moon_spec` to use `moon.len`.
|
Marking this as draft since |
| end | ||
| fold = function(items, fn) | ||
| local len = #items | ||
| len = #items |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like a bug being introduced
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing in moon/init.moon actually uses this new function, so reusing the same local variable for it and the local here isn't really in conflict (at least, that's why I presume moonscript removed the local from this line; admittedly I just ran moonc over it and then ran busted to make sure I hadn't broken anything else).
Basically, in a few places moonscript will do:
And expect
#tblto be4. While this was never guaranteed behavior in Lua (the reference manual states that any table border can be returned in this case), under PUC-Rio Lua <5.5 (and LuaJIT, which presumably emulates the behavior of PUC-Rio Lua 5.1), it would work correctly. However, with the update to 5.5, this has now broken. As a result, some things that worked under previous versions no longer do.I've made changes in 3 places to fix this:
moon.len, a function which returns the largest integer key in a tableunpackcall inmoonscript.transform.classto unpack indices 2 to 4, instead of leaving the last index as#nodemoon.typetest inspec.moon_specto usemoon.len.I've also added
5.5.0to thespecmatrix and set luarocks to use 3.13.0, which supports Lua 5.5.