espruino / Espruino

The Espruino JavaScript interpreter - Official Repo
http://www.espruino.com/
Other
2.76k stars 742 forks source link

Static fields in classes #2517

Closed gfwilliams closed 3 months ago

gfwilliams commented 3 months ago

This got added in 2v22, but there seem to be issues. Getters:

    class Foo {
        static get CH0() { return 0xdeadbeef; }
        constructor() {
            print('nothing to see here')
        }
    }

And even standard

    class Foo {
        static TEST = 5
        constructor() {
            print('nothing to see here')
        }
    }

doesn't seem to work. You can trace(Foo) and not see anything. https://forum.espruino.com/conversations/397119/#comment17421196

gfwilliams commented 3 months ago

Fixed - turns out if you add the static vars after the constructor it's fine.