Skip to content

fix: check compound expressions in needs_temporary_in_safe_access for safe navigation#14

Merged
Brooooooklyn merged 1 commit intomainfrom
02-06-fix_safe_nav_temp_var_compound_expressions
Feb 6, 2026
Merged

fix: check compound expressions in needs_temporary_in_safe_access for safe navigation#14
Brooooooklyn merged 1 commit intomainfrom
02-06-fix_safe_nav_temp_var_compound_expressions

Conversation

@Brooooooklyn
Copy link
Copy Markdown
Member

@Brooooooklyn Brooooooklyn commented Feb 6, 2026

When a pipe expression is wrapped in a compound expression (binary, ternary, unary, not) and then accessed with safe navigation (?.), the compiler must generate a temporary variable to avoid re-evaluating the pipe. Previously, these compound expression types fell through to the default false case, causing the pipe to be called twice and doubling slot indices.

Add missing match arms for Binary, ResolvedBinary, Ternary, Unary, Not, LiteralArray, and LiteralMap to recursively check for side-effecting sub-expressions, matching the Angular TS reference implementation (expand_safe_reads.ts lines 43-73).

Fixes 7 mismatched files in ClickUp comparison (22 → 15, 99.62% → 99.74%).


Note

Medium Risk
Touches core safe-navigation lowering and changes when temporaries are introduced, which can affect generated code shape and var/slot allocation across templates; behavior is covered by new regression tests but impacts a widely-used compilation phase.

Overview
Fixes expand_safe_reads temporary-variable generation so safe navigation guards wrapped in compound IR expressions (unary/not, binary/resolved-binary, ternary, plus array/map literals) are recursively inspected for side effects like pipes/calls.

Adds integration coverage ensuring ((data$ | async) || fallback)?.prop (and chained variants) emits a tmp_* and only a single pipeBind1(...), matching Angular’s behavior and avoiding duplicated pipe evaluation/slot drift.

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

…or safe navigation

When a pipe expression is wrapped in a compound expression (binary, ternary, unary, not)
and then accessed with safe navigation (`?.`), the compiler must generate a temporary variable
to avoid re-evaluating the pipe. Previously, these compound expression types fell through to
the default `false` case, causing the pipe to be called twice and doubling slot indices.

Add missing match arms for Binary, ResolvedBinary, Ternary, Unary, Not, LiteralArray, and
LiteralMap to recursively check for side-effecting sub-expressions, matching the Angular TS
reference implementation (`expand_safe_reads.ts` lines 43-73).

Fixes 7 mismatched files in ClickUp comparison (22 → 15, 99.62% → 99.74%).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Brooooooklyn Brooooooklyn merged commit cf75ff7 into main Feb 6, 2026
3 checks passed
@Brooooooklyn Brooooooklyn deleted the 02-06-fix_safe_nav_temp_var_compound_expressions branch February 6, 2026 01:49
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