-
-
Notifications
You must be signed in to change notification settings - Fork 781
fix(transformer/using): fix bindings scope mismatches #9962
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(transformer/using): fix bindings scope mismatches #9962
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
| let block_stmt_scope_id = | ||
| ctx.insert_scope_below_statements(&new_stmts, ScopeFlags::empty()); | ||
|
|
||
| // TODO: make this less hacky | ||
| for stmt in &new_stmts { | ||
| match stmt { |
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.
i really hate how i've done this, but it works for now.
why does ctx.insert_scope_below_statements not move the scopes of the symbols it sees? this seems like something obvious it should do (although there's probably a great reason why it doesn't), because i can't think of a situation where you would be inserting a scope but not moving the symbols scopes inside 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.
Can you use Scoping data instead? Loop through the bindings of the scope and move any symbols which are block scoped.
But I may well be wrong and that doesn't work.
Unfortunately may also need to deal with BindingIdentifiers in TS* nodes e.g. TSEnumDeclaration. TS transform will remove them anyway, but if this transform moves those nodes first, the bindings need to be moved too, to avoid confusing the TS transform.
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.
Ah feck I think I am wrong. Presumably that wouldn't work if it's a Function, because bindings for function params shouldn't be moved. Or maybe it's OK because function params aren't block scoped?
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.
apologies. i thought about replying, but forgot to!
Yes it's exactly that reason.
in this example, we've gone from:
function f(arg0) {
using test = arg0();
}to
function f(arg0) {
try {
var _usingCtx = babelHelpers.usingCtx();
const x = _usingCtx.u(arg0());
} catch (_) {
_usingCtx.e = _;
} finally {
_usingCtx.d();
}
}so only the bindings inside the function body (note arg0 is in the scope but shouldn't be moved), should be moved.
My thought's are that id's be super helpful if ChildScopeCollector also returned binding ids as well as wel as the socpes that it moved. but may have to flesh it out a bit more
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.
Actually, looking at ChildScopeCollector is used currently. it is never used in a scenario where the scope or bindings would change. it feels reasonable to adjust it as described above.
CodSpeed Instrumentation Performance ReportMerging #9962 will degrade performances by 3.41%Comparing Summary
Benchmarks breakdown
|
b1be057 to
afbdb39
Compare
fd4b0c7 to
3cfc9f1
Compare
3cfc9f1 to
f76a83b
Compare
2e5682a to
6084dcd
Compare
5973bbd to
7dffe96
Compare
5973bbd to
1a9e4fe
Compare
6084dcd to
77c12ff
Compare
dfaaa38 to
d1a8a52
Compare
1a9e4fe to
5e6c074
Compare
d1a8a52 to
412b3fb
Compare
412b3fb to
85ad8b4
Compare
ffc3de1 to
778b044
Compare
85ad8b4 to
5274758
Compare

No description provided.