Visitar URL original
fix(compiler): compare ReadTemporaryExpr against the given expression by MeAkib 路 Pull Request #71245 路 angular/angular 路 GitHub
Skip to content

fix(compiler): compare ReadTemporaryExpr against the given expression - #71245

Open
MeAkib wants to merge 1 commit into
angular:mainfrom
MeAkib:compiler/read-temporary-is-equivalent
Open

MeAkib wants to merge 1 commit into
angular:mainfrom
MeAkib:compiler/read-temporary-is-equivalent

Conversation

@MeAkib

@MeAkib MeAkib commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

fix(compiler): compare ReadTemporaryExpr against the given expression

Fixes ReadTemporaryExpr.isEquivalent() to compare against the provided
expression instead of its own xref, ensuring it is only equivalent to a
read of the same temporary.

Adds specs covering comparisons with other temporaries and unrelated
expressions.

@pullapprove
pullapprove Bot requested a review from JoostK October 8, 2026 04:42
@angular-robot angular-robot Bot added the area: compiler Issues related to `ngc`, Angular's template compiler label Oct 8, 2026
@ngbot ngbot Bot added this to the Backlog milestone Oct 8, 2026
Comment thread packages/compiler/test/template/pipeline/ir/expression_spec.ts Outdated
`ReadTemporaryExpr.isEquivalent()` didn't take the expression it was
compared against and compared its own `xref` with itself, so a temporary
read was considered equivalent to any expression, including reads of other
temporaries and unrelated expressions like literals.

Compare against the given expression instead, like the other IR
expressions do: it's only equivalent to a read of the same temporary.

No miscompilation is known to be caused by this, since temporaries are
usually converted to variables before expressions are compared, but the
result was wrong for any caller that compared them earlier.
@MeAkib
MeAkib force-pushed the compiler/read-temporary-is-equivalent branch from 3fb5882 to fecdfc7 Compare October 8, 2026 08:47
@MeAkib
MeAkib requested a review from JoostK October 8, 2026 08:48
@JoostK JoostK added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release action: presubmit The PR is in need of a google3 presubmit labels Oct 9, 2026

@JoostK JoostK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an obvious bug in the original code so I'm accepting this without test this time, but please focus any fix efforts on observable bugs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker action: presubmit The PR is in need of a google3 presubmit area: compiler Issues related to `ngc`, Angular's template compiler target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants