Skip to content

Class static initializer lexical scope bug? #138

@bnoordhuis

Description

@bnoordhuis

This works:

class C {
    static x = 42
    static y = this.x
}
(globalThis.print??console.log)(C.y) // 42

But this throws a C is not initialized ReferenceError:

class C {
    static x = 42
    static y = C.x // ReferenceError (but not in V8)
}

test262 has tests that exercise the former but not the latter (that I can find) so I'm not 100% sure it's actually a bug but both work in V8.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions