fix: ctx.X vs ctx_rN.X context references#2
Merged
Conversation
`resolve_expression` in `resolve_names.rs` was missing a handler for
`IrExpression::Parenthesized`. When `convert_ast_to_ir` converts Angular
template expressions, parenthesized sub-expressions like
`!(item.private && !item.shareWithTeam)` become
`Not(Parenthesized(Binary(...)))` in the IR. Since `Parenthesized` hit
the `_ => {}` catch-all, all sub-expressions inside parentheses were
never resolved — `LexicalRead("item")` references stayed unresolved and
were later emitted as bare `ctx.item` instead of being resolved to the
proper alias variable (e.g. `item_r2` via `nextContext()`).
The fix adds `IrExpression::Parenthesized` handling to
`resolve_expression`, recursing into the inner expression so that all
nested variable references are properly resolved through the scope
chain.
ClickUp comparison: 203 → 177 mismatches (26 files fixed, 97.0% match)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
resolve_expressioninresolve_names.rswas missing a handler forIrExpression::Parenthesized. Whenconvert_ast_to_irconverts Angular template expressions, parenthesized sub-expressions like!(item.private && !item.shareWithTeam)becomeNot(Parenthesized(Binary(...)))in the IR. SinceParenthesizedhit the_ => {}catch-all, all sub-expressions inside parentheses were never resolved —LexicalRead("item")references stayed unresolved and were later emitted as barectx.iteminstead of being resolved to the proper alias variable (e.g.item_r2vianextContext()).The fix adds
IrExpression::Parenthesizedhandling toresolve_expression, recursing into the inner expression so that all nested variable references are properly resolved through the scope chain.ClickUp comparison: 203 → 177 mismatches (26 files fixed, 97.0% match)
Note
Medium Risk
Touches name-resolution logic in the template compilation pipeline, which can affect emitted JS for many expression shapes; change is small but impacts correctness of variable/context capture in embedded views and listeners.
Overview
Fixes name resolution for
IrExpression::Parenthesizedby recursing into the inner expression, ensuring lexical reads inside parentheses are resolved to the correct scoped variables or context references.Adds integration coverage for nested
@iflisteners (with and without outer aliases) to assert generated listeners usenextContext()/namedctx_rNvariables rather than incorrectly emitting barectxorctx.*for parent-scope references.Written by Cursor Bugbot for commit eada628. This will update automatically on new commits. Configure here.