fix: check compound expressions in needs_temporary_in_safe_access for safe navigation#14
Merged
Brooooooklyn merged 1 commit intomainfrom Feb 6, 2026
Conversation
…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>
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.
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 defaultfalsecase, 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.tslines 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_readstemporary-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 atmp_*and only a singlepipeBind1(...), 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.