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

refactor: use FunctionParent on visiting var scope #13152

Merged

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Apr 14, 2021

Q                       A
Tests Added + Pass? Yes
License MIT

Based on #13151 (comment), we should use FunctionParent when we intend to visit those AST nodes starting a new var scope. This PR does not have observable behaviour changes since currently Function equals to FunctionParent.

@JLHwung JLHwung added the PR: Internal 🏠 A type of pull request used for our changelog categories label Apr 14, 2021
@babel-bot
Copy link
Collaborator

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

@codesandbox-ci
Copy link

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

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

@@ -19,7 +19,7 @@ const visitor = {
if (state.kind === "let") path.skip();
},

Function(path: NodePath) {
FunctionParent(path: NodePath) {
path.skip();
Copy link
Member

Choose a reason for hiding this comment

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

This might actually be a bugfix?

let x = async do {
  class A {
    static {
    	var a = 2;
    }
  }
}

since we use hoistVariables for asycn do expressions, I'd expect var here to be hoisted before this PR (but I didn't test it)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will be a bugfix when we mark StaticBlock as FunctionParent, but I tend to land it in another PR with new tests.

Copy link
Member

Choose a reason for hiding this comment

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

Oh ok 👍

@nicolo-ribaudo
Copy link
Member

E2E Vue error is unrelated, it's also failing in other PRs.

@JLHwung JLHwung merged commit 1e31d41 into babel:main Apr 14, 2021
@JLHwung JLHwung deleted the use-function-parent-on-visiting-var-scope branch April 14, 2021 20:00
@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 Jul 15, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 15, 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: Internal 🏠 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants