fix(angular): enforce root-view guard in @for track method-call optimization#38
Merged
Brooooooklyn merged 1 commit intomainfrom Feb 25, 2026
Merged
Conversation
…ization Angular's `isTrackByFunctionCall` (track_fn_optimization.ts:96-100) requires `receiver.receiver.view === rootView`, rejecting non-root-view contexts from the optimized path. The Rust port ignored `root_xref` and accepted any Context receiver, which could mis-optimize nested-view track calls. - Check `ctx.view == root_xref` in the ResolvedCall path - Remove the AST fallback path entirely (dead code after resolve_names phase, and ImplicitReceiver lacks a view field to verify the guard) - Add unit tests that directly verify the root-view guard - Add integration tests for root-view vs nested-view track method calls Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Member
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
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.

Angular's
isTrackByFunctionCall(track_fn_optimization.ts:96-100) requiresreceiver.receiver.view === rootView, rejecting non-root-view contexts fromthe optimized path. The Rust port ignored
root_xrefand accepted any Contextreceiver, which could mis-optimize nested-view track calls.
ctx.view == root_xrefin the ResolvedCall pathand ImplicitReceiver lacks a view field to verify the guard)
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com
Note
Medium Risk
Touches compiler optimization logic that affects generated runtime code for
@forrepeaters; the change is narrow but could alter output for edge-case track expressions, especially in nested views.Overview
Fixes
@fortrack method-call optimization to match Angular by only optimizingtrackByFn($index[, $item])when the call receiver is aContextfrom the root view (ctx.view == root_xref), preventing incorrect directctx.methodemission in nested views.Removes the raw-AST fallback optimization path (can’t validate the root-view guard) and adds targeted unit + integration tests plus snapshots covering root vs nested view output (
ctx.trackByFnvscomponentInstance().trackByFn) and the two-argument form.Written by Cursor Bugbot for commit 6105ed1. This will update automatically on new commits. Configure here.