fix(angular): fix nested @for track expression with outer-scope variable#29
Merged
Merged
Conversation
Member
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
051a378 to
7a713e8
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
The Rust resolve_names phase was merging update-scope variables into the create-scope, making @for loop variables (like $implicit) visible when resolving RepeaterCreate.track expressions. Angular TypeScript processes create and update ops as separate lexical scopes. This caused track expressions referencing outer @for variables to resolve incorrectly, producing broken output with out-of-scope identifiers instead of generating `this`-based track functions with usesComponentInstance=true. Three fixes applied: - resolve_names: stop merging update scope into create scope, process RepeaterCreate.track_by_ops with their own scope - resolve_contexts: process view.functions (arrow fn ops) and RepeaterCreate.track_by_ops - reify: handle track_by_ops in reify_track_by, generating proper function vs arrow forms based on usesComponentInstance Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
7a713e8 to
e99d34b
Compare
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.

The Rust resolve_names phase was merging update-scope variables into the
create-scope, making @for loop variables (like $implicit) visible when
resolving RepeaterCreate.track expressions. Angular TypeScript processes
create and update ops as separate lexical scopes. This caused track
expressions referencing outer @for variables to resolve incorrectly,
producing broken output with out-of-scope identifiers instead of
generating
this-based track functions with usesComponentInstance=true.Three fixes applied:
RepeaterCreate.track_by_ops with their own scope
RepeaterCreate.track_by_ops
function vs arrow forms based on usesComponentInstance
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com
Note
Medium Risk
Touches core template compilation phases (name/context resolution and reification) and changes lexical scoping semantics, which can subtly affect generated output across templates beyond nested
@forcases.Overview
Fixes incorrect codegen for nested
@forwhere an innertrackexpression references an outer-scope variable, aligning Rust pipeline behavior with Angular’s lexical scoping rules.resolve_namesnow treats create and update ops as separate lexical scopes (no longer merging update-scope vars into create), preventing@forupdate variables (e.g.$implicit,$index) from leaking intoRepeaterCreate.trackresolution.resolve_contextsadditionally resolves context accesses inside arrow-functionopsandRepeaterCreate.track_by_opsvia a shared vec-based update-scope resolver.reify_track_bynow supportstrack_by_opsby reifying those ops into statements and choosing function vs arrow based onuses_component_instanceand statement shape, ensuring generated track functions can safely access outer context (e.g., viathis). Adds an integration snapshot test covering the nested outer-scopetrackcase.Written by Cursor Bugbot for commit e99d34b. This will update automatically on new commits. Configure here.