Fix shadow function processing for async functions#3405
Fix shadow function processing for async functions#3405loganfsmyth merged 7 commits intobabel:masterfrom
Conversation
| * | ||
| * 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.
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.
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.
We should use the t.is helpers here, at least for consistency. We should seldom touch .type.
There was a problem hiding this comment.
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.
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
argumentsin 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.