-
-
Notifications
You must be signed in to change notification settings - Fork 496
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
Make all scopes unconditional #5008
Comments
Yes, I agreed |
We need to remove these conditional in oxc/crates/oxc_semantic/src/builder.rs Lines 946 to 950 in 4e1f4ab
|
Glad you agree! We would also need to remove the |
@Boshen Would you be happy with this change? |
What does a mouse dressed as a detective mean??! |
Sorry I'm old. |
Not as old as me! But thanks for explaining. |
Part of #5008. Make scope for `CatchClause` unconditional. i.e. always create a scope, even if there is no catch parameter.
Part of #5008. Make scopes for `ForStatement`, `ForInStatement` and `ForOfStatement` unconditional. i.e. always create a scope, even if there is no lexical binding (e.g. `for (i of a) {}`).
Closes #5008. There are no longer any nodes with conditional scopes. Remove support for `#[scope(if(...))]` attr from `oxc_traverse` codegen - it's no longer needed.
Implemented in #5114 and preceding PRs. |
Part of #5008. Make scopes for `ForStatement`, `ForInStatement` and `ForOfStatement` unconditional. i.e. always create a scope, even if there is no lexical binding (e.g. `for (i of a) {}`).
Closes #5008. There are no longer any nodes with conditional scopes. Remove support for `#[scope(if(...))]` attr from `oxc_traverse` codegen - it's no longer needed.
…in the correct scope (#5066) Blocked by #5008 In the SemanticBuilder, we insert all CatchClause parameters in the BlockStatement scope, a child-scope of CatchClause https://github.com/oxc-project/oxc/blob/858f510d59cb9ea29cca36c31fdf037b0d627f2c/crates/oxc_semantic/src/builder.rs#L709-L718 So we should do the same thing in this plugin, but because CatchClause has no parameters, SemanticBuilder doesn't create scope for `CatchClause`. This cause we cannot find the `BlockStatement` scope_id. This PR has changed to the correct logic. Just to wait #5008 solved
Almost all nodes which can hold a scope always hold a scope. But a small handful only create a scope if required:
ForStatement
ForInStatement
ForOfStatement
CatchClause
I propose that we make all scopes unconditional i.e. all these nodes always have a scope.
My rationale is:
for (let item of arr)
is more common thanfor (item of arr)
, andcatch (err) {
is much more common thancatch {
).if
orfunction
), so even if it wasn't so cheap, a few extra unnecessary scopes would not hurt perf much anyway.If I remember right, Dunqing was in favour of this a while back, but I resisted. At that point I didn't realise how few nodes had conditional scopes, so I thought the perf upside of eliding them was much bigger than it is.
The text was updated successfully, but these errors were encountered: