]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.unified] cmd/compile: visit LHS before RHS/X in assign/for statement
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Sat, 21 May 2022 19:14:46 +0000 (02:14 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Tue, 7 Jun 2022 00:08:30 +0000 (00:08 +0000)
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>

src/cmd/compile/internal/noder/reader.go
src/cmd/compile/internal/noder/writer.go

index 635f02630f73d8dff2f036cd919bf16b8588aea3..7c35172f128fba352e8d3f5cc3c4ced8577616f5 100644 (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()
index 2fb158343741fa2df28aeffd6f6b6faf7677a17c..c3955c2cb642423aa51f6b208880a0bd65602925 100644 (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)