[dev.unified] cmd/compile: visit LHS before RHS/X in assign/for statement

Unified IR used to visit RHS/X before LHS in assign/for statements for
satisfying toolstash in quirksmode.

After CL 385998, unified IR quirks mode was gone, the constraint to
visit RHS/X first is no longer necessary.

Change-Id: I1c3825168b67fb094928f5aa21748a3c81b118ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/410343
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Cuong Manh Le 2022-05-22 02:14:46 +07:00
parent 46ddf0873e
commit 9e5c968021
2 changed files with 5 additions and 9 deletions

View file

@ -1224,10 +1224,8 @@ func (r *reader) stmt1(tag codeStmt, out *ir.Nodes) ir.Node {
case stmtAssign:
pos := r.pos()
// TODO(mdempsky): After quirks mode is gone, swap these
// statements so we visit LHS before RHS again.
rhs := r.exprList()
names, lhs := r.assignList()
rhs := r.exprList()
if len(rhs) == 0 {
for _, name := range names {
@ -1368,10 +1366,8 @@ func (r *reader) forStmt(label *types.Sym) ir.Node {
if r.Bool() {
pos := r.pos()
// TODO(mdempsky): After quirks mode is gone, swap these
// statements so we read LHS before X again.
x := r.expr()
names, lhs := r.assignList()
x := r.expr()
body := r.blockStmt()
r.closeAnotherScope()

View file

@ -954,8 +954,8 @@ func (w *writer) stmt1(stmt syntax.Stmt) {
default:
w.Code(stmtAssign)
w.pos(stmt)
w.exprList(stmt.Rhs)
w.assignList(stmt.Lhs)
w.exprList(stmt.Rhs)
}
case *syntax.BlockStmt:
@ -1065,8 +1065,8 @@ func (w *writer) declStmt(decl syntax.Decl) {
case *syntax.VarDecl:
w.Code(stmtAssign)
w.pos(decl)
w.exprList(decl.Values)
w.assignList(namesAsExpr(decl.NameList))
w.exprList(decl.Values)
}
}
@ -1083,8 +1083,8 @@ func (w *writer) forStmt(stmt *syntax.ForStmt) {
if rang, ok := stmt.Init.(*syntax.RangeClause); w.Bool(ok) {
w.pos(rang)
w.expr(rang.X)
w.assignList(rang.Lhs)
w.expr(rang.X)
} else {
w.pos(stmt)
w.stmt(stmt.Init)