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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/babel-helper-hoist-variables/src/index.ts
Expand Up @@ -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 👍

},

Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-transform-block-scoping/src/index.js
Expand Up @@ -175,7 +175,7 @@ const letReferenceBlockVisitor = traverse.visitors.merge([
state.loopDepth--;
},
},
Function(path, state) {
FunctionParent(path, state) {
// References to block-scoped variables only require added closures if it's
// possible for the code to run more than once -- otherwise it is safe to
// simply rename the variables.
Expand Down