-
-
Notifications
You must be signed in to change notification settings - Fork 442
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(semantic): incorrect reference in parameters #2644
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Performance ReportMerging #2644 will not alter performanceComparing Summary
|
@hyf0 cc |
Would it be easier to create a facade scope for the params part? |
My questions will always be: how does TypeScript do it? Another questions, can we do everything inside oxc/crates/oxc_semantic/src/binder.rs Lines 183 to 242 in c72675e
|
I've taken a cursory look at typescript, but I don't see a specific way to handle it yet
CatchClause no oxc/crates/oxc_ast/src/visit.rs Lines 291 to 301 in 7550838
|
I think catch clause is another special case ... |
Initially, we did everything in FormalParameters, but that would result in the node query by node id not being specific enough |
Ahh ... I'll take a look at this next week :-( |
close: #2499
We need to collect parameter bindings. If an IdentifierReference is used on a parameter, we need to check if the current parameter binding is already defined, if not then it can only access the parent scope's bindings.
Let's look at an example.
The parameter has a reference to
foo
, but there is nofoo
in the parameter binding, so it must access the parent scope. Let's look atc = b
, which has a reference tob
, and the first parameter already has ab
binding defined, so in the current scope we can accessb
.I apologize for adding two more properties to the SemanticBuilder, the current implementation can't avoid adding them. Please let me know if you have a better solution, I'm interested in a better solution!