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

Disallow duplicated AST nodes #11807

Merged
merged 4 commits into from Jul 14, 2020
Merged

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Jul 8, 2020

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

As a follow-up to #7149, this PR enables duplicated node checks against all testcases and then fixes all duplicate AST errors.

I didn't add a regression test of #11506 because it is covered in this test case. I realized that the duplicated node checks are not effective when I am investigating #11506, which should have been captured by our test runner.

@JLHwung JLHwung added the PR: Bug Fix 🐛 A type of pull request used for our changelog categories label Jul 8, 2020
@JLHwung JLHwung added this to the 7.10.5 milestone Jul 8, 2020
@codesandbox-ci
Copy link

codesandbox-ci bot commented Jul 8, 2020

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 1e796b3:

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

@babel-bot
Copy link
Collaborator

babel-bot commented Jul 8, 2020

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

for (const bareSuper of bareSupers) {
bareSuper.insertAfter(nodes);
if (isFirst) {
Copy link
Contributor Author

@JLHwung JLHwung Jul 8, 2020

Choose a reason for hiding this comment

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

The test legacy-class-prototype-properties/child-classes-properties is failing if we change these to bareSuper.insertAfter(nodes.map(n => t.cloneNode(n))) unconditionally. The current approach happens to make our test cases happy and also slightly faster because we get rid of redundant clone.

However, I think it reveals an issue which is not caught in our current test cases.

I suggest we address that in a separate PR or even let it stay in the backlog since it is related to legacy decorators only.

I am not familiar with decorators part, suggestions are definitely welcome.

Copy link
Member

Choose a reason for hiding this comment

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

It is probably failing because in the decorators plugin we use a WARNING_CALLS WeakSet to track warnings: if we clone the node we cannot find it anymore in the set.

Copy link
Member

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

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

I left some code style suggestions, but overall it looks good 👍

for (const bareSuper of bareSupers) {
bareSuper.insertAfter(nodes);
if (isFirst) {
Copy link
Member

Choose a reason for hiding this comment

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

It is probably failing because in the decorators plugin we use a WARNING_CALLS WeakSet to track warnings: if we clone the node we cannot find it anymore in the set.

packages/babel-plugin-transform-parameters/src/params.js Outdated Show resolved Hide resolved
packages/babel-plugin-transform-typescript/src/index.js Outdated Show resolved Hide resolved
@existentialism existentialism merged commit 5dd64ec into babel:main Jul 14, 2020
@existentialism existentialism deleted the duplicated-nodes branch July 14, 2020 13:32
@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 Oct 14, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 14, 2020
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

plugin-proposal-decorators doesn't clone id identifier
5 participants