Sitelet https://github.com/angular/angular/commit/5e50658fd23983dd27ef89a67cea26910af6fd79
Skip to content

Commit 5e50658

Browse files
MeAkibamishne
authored andcommitted
fix(compiler): compare the operand in ReadTemporaryExpr.isEquivalent
`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. (cherry picked from commit 3aaf026)
1 parent 90af679 commit 5e50658

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎packages/compiler/src/template/pipeline/ir/src/expression.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -983,8 +983,8 @@ export class ReadTemporaryExpr extends ExpressionBase {
983983

984984
override visitExpression(visitor: o.ExpressionVisitor, context: any): any {}
985985

986-
override isEquivalent(): boolean {
987-
return this.xref === this.xref;
986+
override isEquivalent(e: o.Expression): boolean {
987+
return e instanceof ReadTemporaryExpr && e.xref === this.xref;
988988
}
989989

990990
override isConstant(): boolean {

0 commit comments

Comments
 (0)