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
check descriptor before private field access #12910
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit f9123cf:
|
C.#p; | ||
} | ||
} | ||
}).toThrow(/attempted to use private field on non-instance/); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is exactly #12905, the Babel behaviour on static accessors are not aligned with V8. I will try to tackle in a separate PR. Before that it is just a test case parallel to properties.
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/43564/ |
As suggested in #12904, check if
descriptor
isundefined
before pass it as a descriptor. Note that theprivateFieldAsProperty
a.k.a. loose handler is not affected because the loosePrivateKey is always hoisted before class declaration. So in this case they will throw the same error as if we are accessing a private properties that is not defined in current class.I mark this PR as polish because we still throw on the new cases, but the error message is confusing.
This PR is now based on #12911, please review that PR first.