WIP: Fix incompatibilities with Lua 5.5 - #463
Draft
MineRobber9000 wants to merge 5 commits into
Draft
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`.MineRobber9000
marked this pull request as draft
January 11, 2026 00:59
MineRobber9000
commented
Jan 11, 2026
Author
Marking this as draft since |
| end | ||
| fold = function(items, fn) | ||
| local len = #items | ||
| len = #items |
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).
s-ol
commented
Apr 23, 2026
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.