Skip to content

Class static initializer lexical scope bug? #138

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

Closed
bnoordhuis opened this issue Nov 25, 2023 · 1 comment · Fixed by #139
Closed

Class static initializer lexical scope bug? #138

bnoordhuis opened this issue Nov 25, 2023 · 1 comment · Fixed by #139
Labels
bug Something isn't working

Comments

@bnoordhuis
Copy link
Contributor

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.

@bnoordhuis bnoordhuis added the bug Something isn't working label Nov 25, 2023
@bnoordhuis
Copy link
Contributor Author

I think I figured it out. I'll open a pull request.

bnoordhuis added a commit to bnoordhuis/quickjs that referenced this issue Nov 25, 2023
bnoordhuis added a commit to bnoordhuis/quickjs that referenced this issue Nov 25, 2023
bnoordhuis added a commit that referenced this issue Nov 26, 2023
bluesky950520 pushed a commit to bluesky950520/quickjs that referenced this issue Mar 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant