Skip to content

fix(angular): enforce root-view guard in @for track method-call optimization#38

Merged
Brooooooklyn merged 1 commit intomainfrom
fix/track-fn-optimization-root-view-guard
Feb 25, 2026
Merged

fix(angular): enforce root-view guard in @for track method-call optimization#38
Brooooooklyn merged 1 commit intomainfrom
fix/track-fn-optimization-root-view-guard

Conversation

@Brooooooklyn
Copy link
Member

@Brooooooklyn Brooooooklyn commented Feb 25, 2026

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


Note

Medium Risk
Touches compiler optimization logic that affects generated runtime code for @for repeaters; the change is narrow but could alter output for edge-case track expressions, especially in nested views.

Overview
Fixes @for track method-call optimization to match Angular by only optimizing trackByFn($index[, $item]) when the call receiver is a Context from the root view (ctx.view == root_xref), preventing incorrect direct ctx.method emission 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.trackByFn vs componentInstance().trackByFn) and the two-argument form.

Written by Cursor Bugbot for commit 6105ed1. This will update automatically on new commits. Configure here.

…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>
Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Brooooooklyn Brooooooklyn merged commit 117a8d3 into main Feb 25, 2026
4 checks passed
@Brooooooklyn Brooooooklyn deleted the fix/track-fn-optimization-root-view-guard branch February 25, 2026 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant