moonscript
moonscript copied to clipboard
Compile error: transformer.lua:23: table index is nil
variable = \function
Generates the error :
test.moon Compile error: ...l/share/lua/5.1/moonscript/transform/transformer.lua:23: table index is nil
stack traceback:
...l/share/lua/5.1/moonscript/transform/transformer.lua:23: in function <...l/share/lua/5.1/moonscript/transform/transformer.lua:19>
(tail call): ?
/usr/local/share/lua/5.1/moonscript/compile.lua:476: in function 'value'
...usr/local/share/lua/5.1/moonscript/compile/value.lua:120: in function 'fn'
/usr/local/share/lua/5.1/moonscript/compile.lua:491: in function 'value'
...local/share/lua/5.1/moonscript/compile/statement.lua:96: in function <...local/share/lua/5.1/moonscript/compile/statement.lua:91>
...local/share/lua/5.1/moonscript/compile/statement.lua:100: in function 'fn'
/usr/local/share/lua/5.1/moonscript/compile.lua:530: in function 'stm'
/usr/local/share/lua/5.1/moonscript/compile.lua:564: in function 'stms'
...local/share/lua/5.1/moonscript/compile/statement.lua:235: in function 'fn'
/usr/local/share/lua/5.1/moonscript/compile.lua:530: in function 'stm'
/usr/local/share/lua/5.1/moonscript/compile.lua:564: in function </usr/local/share/lua/5.1/moonscript/compile.lua:555>
(tail call): ?
/usr/local/share/lua/5.1/moonscript/compile.lua:530: in function 'stm'
/usr/local/share/lua/5.1/moonscript/compile.lua:564: in function </usr/local/share/lua/5.1/moonscript/compile.lua:555>
(tail call): ?
(tail call): ?
- I know that in that case the code is invalid, but i found that issue with valid code (within a
withblock). - Even if the code is erronous, an error like that shouldn't be generated (since it's an internal error).
moonc -T test.moonandmoonc -b test.moongenerates the same error without displaying more information.
- that's not really a problem with invalid code, but yeah, the fact that it also does this on valid code is bad and IMO makes this a valid issue
- that's how all moonscript errors look and while I agree that this is pretty user-unfriendly, I don't think anyone has any plan to change it
- they seem to transform the AST before printing anything so they can't be used to debug this
I guess the expected behavior would be that
local c
with a
c = \b
should be the same as
c = a\b
which would roughly translate to
c = (...) -> a\b ...
as stated by
The with block helps to alleviate this. Within a with block we can use a special statements that begin with either . or \ which represent those operations applied to the object we are using with on.