sjbarag / brs

An interpreter for the BrightScript language that runs on non-Roku platforms.
MIT License
114 stars 43 forks source link

`constructor` identifier causes parse issues in `brs` #613

Closed sjbarag closed 3 years ago

sjbarag commented 3 years ago

Attempting to use the word constructor as an identifier in brs causes parser errors, despite the fact that this is valid in RBI.

sub main()
    constructor = function()
        return {
            foo: "bar"
        }
    end function

    instance = constructor()
    print instance.foo ' => "bar"
end sub

output:

$ bin/cli.js /tmp/mwe.brs 
/tmp/derp.brs(2,4-15): Found unexpected token 'constructor'
/tmp/derp.brs(6,4-16): Expected 'end sub' to terminate sub block
/tmp/derp.brs(8,15-26): Found unexpected token 'constructor'
/tmp/derp.brs(10,0-7): Found unexpected token 'end sub'
Error occurred parsing