WIP: Fix incompatibilities with Lua 5.5#463
WIP: Fix incompatibilities with Lua 5.5#463MineRobber9000 wants to merge 5 commits intoleafo:masterfrom
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.
looks like a bug being introduced
There was a problem hiding this comment.
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).
|
Oh hey this is interesting, so moonscript is working at all for you on Lua 5.5? Some problems I'm facing are having problems with loop variables now being const in my moonscript code and errors like |
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.