Skip to content

Class declaration after local ^ causes a MoonScript.lua error #287

@evaera

Description

@evaera

Forgive me if I'm just using this incorrectly, but whenever I try to use the local ^ syntax followed by a class declaration, I get the below error.

Compile error: [string "moonscript.lua"]:562: attempt to index field '?' (a nil value)
stack traceback:
    [string "moonscript.lua"]:562: in function 'transformer'
    [string "moonscript.lua"]:309: in function <[string "moonscript.lua"]:300>
    (tail call): ?
    [string "moonscript.lua"]:4858: in function 'stm'
    [string "moonscript.lua"]:4897: in function <[string "moonscript.lua"]:4888>
    (tail call): ?
    (tail call): ?

This is an example of the code that causes the error for me:

local ^

lowercase = 5
Uppercase = 3

class MyClass
    new: =>
        print 'hi'

Moving the class declaration before the line with local ^ fixes the issue, and local * also works. It doesn't seem to matter if the class name is uppercase, or if the class has a name at all, e.g. the code below still errors:

local ^
lowercase = 5
Uppercase = 5
class

Using version 0.4.0. thanks (:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions