Skip to content

fix(angular): fix 3 compiler divergences from Angular reference#33

Merged
Brooooooklyn merged 1 commit intomainfrom
fix/angular-track-optimization-and-error-handling
Feb 24, 2026
Merged

fix(angular): fix 3 compiler divergences from Angular reference#33
Brooooooklyn merged 1 commit intomainfrom
fix/angular-track-optimization-and-error-handling

Conversation

@Brooooooklyn
Copy link
Member

@Brooooooklyn Brooooooklyn commented Feb 24, 2026

  1. (High) Remove incorrect bare property track optimization: Angular does
    NOT optimize track id or track trackByFn into direct ctx.id
    references. Only $index, $item, and fn($index[, $item]) calls
    are optimized. Bare property reads now correctly generate wrapper
    functions like function _forTrack($index,$item) { return this.id; }.

  2. (Medium) Report diagnostic for missing context in resolve_contexts:
    Angular throws when a ContextExpr references a view with no scope
    entry. Now reports an OxcDiagnostic error via job.diagnostics instead
    of silently keeping the unresolved expression.

  3. (Low) Report diagnostic for unknown @for loop variables in ingest:
    Angular throws an assertion for unknown loop variables. Now reports
    an OxcDiagnostic error instead of silently returning an empty
    expression.

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com


Note

Medium Risk
Changes affect template codegen for @for track expressions and add new compilation errors for previously silent edge cases, which may alter output and error behavior for some templates.

Overview
Stops optimizing bare @for ...; track id / track trackByFn property reads into direct ctx.* references, so these now fall back to the non-optimizable path that generates a wrapper track function (matching Angular runtime semantics).

Adds new error diagnostics instead of silently producing empty/unresolved expressions: unknown @for loop variables now push an OxcDiagnostic during ingestion, and missing context mappings in resolve_contexts now record errors (collected via RefCell) and append them to job.diagnostics for both component and host compilation.

Adds integration tests + snapshots covering the bare-property/bare-method track cases to prevent regression.

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

1. (High) Remove incorrect bare property track optimization: Angular does
   NOT optimize `track id` or `track trackByFn` into direct `ctx.id`
   references. Only `$index`, `$item`, and `fn($index[, $item])` calls
   are optimized. Bare property reads now correctly generate wrapper
   functions like `function _forTrack($index,$item) { return this.id; }`.

2. (Medium) Report diagnostic for missing context in resolve_contexts:
   Angular throws when a ContextExpr references a view with no scope
   entry. Now reports an OxcDiagnostic error via job.diagnostics instead
   of silently keeping the unresolved expression.

3. (Low) Report diagnostic for unknown @for loop variables in ingest:
   Angular throws an assertion for unknown loop variables. Now reports
   an OxcDiagnostic error instead of silently returning an empty
   expression.

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 96fad7b into main Feb 24, 2026
4 checks passed
@Brooooooklyn Brooooooklyn deleted the fix/angular-track-optimization-and-error-handling branch February 24, 2026 03:21
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