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

Compile error: transformer.lua:23: table index is nil #428

Open
linkpy opened this issue Oct 21, 2020 · 1 comment
Open

Compile error: transformer.lua:23: table index is nil #428

linkpy opened this issue Oct 21, 2020 · 1 comment

Comments

@linkpy
Copy link

linkpy commented Oct 21, 2020

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): ?
  1. I know that in that case the code is invalid, but i found that issue with valid code (within a with block).
  2. Even if the code is erronous, an error like that shouldn't be generated (since it's an internal error).
  3. moonc -T test.moon and moonc -b test.moon generates the same error without displaying more information.
@natnat-mc
Copy link
Contributor

  1. 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
  2. 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
  3. 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.

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

No branches or pull requests

2 participants