Skip to content
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

Evaluate object and initializer when setting a private method #12707

Merged
merged 5 commits into from Mar 1, 2021

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Jan 28, 2021

Q                       A
Fixed Issues? Fixes #12705
Patch: Bug Fix? Y
Tests Added + Pass? Yes
License MIT

Pass down value to the argument of classPrivateMethodSet so it will always be evaluated before a runtime error is thrown.

@JLHwung JLHwung added PR: Bug Fix 🐛 A type of pull request used for our changelog categories Spec: Private Methods labels Jan 28, 2021
@babel-bot
Copy link
Collaborator

babel-bot commented Jan 28, 2021

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/43268/

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jan 28, 2021

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 8388185:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

Copy link
Member

@jridgewell jridgewell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test case for an accessor without a set?

@nicolo-ribaudo
Copy link
Member

@JLHwung Could you rebase this? 🙏

@@ -14,7 +14,7 @@ class Cl {
value: 0
});

babelHelpers.readOnlyError("#privateFieldValue");
this, 1, babelHelpers.readOnlyError("#privateFieldValue");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a few more unnecessary bytes, but this path will always result in an error so it's highly improbable that it will happen in production code.

@nicolo-ribaudo nicolo-ribaudo changed the title fix: evaluate initializer when a private method is set as a field Evaluate object and initializer when setting a private method Mar 1, 2021
@nicolo-ribaudo
Copy link
Member

nicolo-ribaudo commented Mar 1, 2021

I rewrote the title to keep it short enough while still adding info about the last two commits.

This was referenced Mar 17, 2021
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jun 1, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories Spec: Private Methods
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Right-hand side expression is not evaluated on assignment to private method
5 participants