-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Fix shadow function processing for async functions #3405
Conversation
* starting location path, the closest function will be used. | ||
* | ||
* Please Note, these flags are for private internal use only and should be avoided. | ||
* Only "shadow" is a public property that other transforms may manipulate. | ||
*/ |
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.
Scoping shadowing is a bit....complicated right now to say the least. I didn't realize quite how hairy it was until I had to dive in for this. I ended up writing all this up for myself and figured I might as well include it.
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.
Yeah... it's gotten pretty out of hand. It used to be a simple flag then it's use was overloaded (rightfully so since it's within scope, the API is just bad).
Snap! I don't think we really have a policy on commits - I don't really like the random/merge commits but none of it is really a big deal for me at least (we don't have a commit format atm either) |
dd800b9
to
061345c
Compare
Current coverage is
|
} | ||
|
||
return false; | ||
}); | ||
|
||
if (shadowFunction && fnPath.type === "Program" && shadowFunction.type !== "Program"){ |
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.
We should use the t.is
helpers here, at least for consistency. We should seldom touch .type
.
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.
We should seldom touch
.type
Can you expand on why that is? So it's more abstracted in case node types change? There've been cases where I've thought about going either way and I'd like to learn why the helpers are preferable.
061345c
to
0a31a44
Compare
I haven't looked at these commits, but in general:
|
* Node's "shadow" props have the following behavior: | ||
* | ||
* - Boolean true will cause the function to shadow both "this" and "arguments". | ||
* - {this: false} Shadows "this" but not "arguments". |
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.
did you mean "shadows arguments
but not this
"? Since it's {this: false}
0a31a44
to
de21f2e
Compare
Fix shadow function processing for async functions
This reverts and re-implements some of the work done in #3336 because while that fixed the rest params, it broke the ability to use
arguments
in your own code, since it would resolve to the arrow function rather than the outer function.Also fixed https://phabricator.babeljs.io/T7108
Will squash if people feel like it, but I'd love to keep this split up to it's easier to follow. Not sure what the policy is specifically for non-work-in-progress commits.