diff --git a/src/Expr.h b/src/Expr.h index 0cfdf84a2c..2dde29e52c 100644 --- a/src/Expr.h +++ b/src/Expr.h @@ -304,11 +304,11 @@ public: // True if this expression can be the RHS for a field assignment. bool IsFieldAssignable(const Expr* e) const; - // True if the expression will transform to one of another type - // upon reduction, for non-constant operands. "Transform" means - // something beyond assignment to a temporary. Necessary so that - // we know to fully reduce such expressions if they're the RHS - // of an assignment. + // True if the expression will transform to one of another AST node + // (perhaps of the same type) upon reduction, for non-constant + // operands. "Transform" means something beyond assignment to a + // temporary. Necessary so that we know to fully reduce such + // expressions if they're the RHS of an assignment. virtual bool WillTransform(Reducer* c) const { return false; } // The same, but for the expression when used in a conditional context. diff --git a/src/script_opt/Expr.cc b/src/script_opt/Expr.cc index 83480680e7..8c99d6f5de 100644 --- a/src/script_opt/Expr.cc +++ b/src/script_opt/Expr.cc @@ -1812,8 +1812,9 @@ ExprPtr AssignExpr::Reduce(Reducer* c, StmtPtr& red_stmt) if ( op2->WillTransform(c) ) { StmtPtr xform_stmt; + StmtPtr lhs_stmt = lhs_ref->ReduceToLHS(c); op2 = op2->ReduceToSingleton(c, xform_stmt); - red_stmt = MergeStmts(rhs_reduce, xform_stmt); + red_stmt = MergeStmts(lhs_stmt, rhs_reduce, xform_stmt); return ThisPtr(); }