]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove typechecker calls in varDecl()
authorDan Scales <danscales@google.com>
Thu, 25 Mar 2021 19:23:44 +0000 (12:23 -0700)
committerDan Scales <danscales@google.com>
Mon, 29 Mar 2021 17:46:51 +0000 (17:46 +0000)
We can now use transformAssign.

The only remaining typechecker calls in the noder2 pass are for
CompLitExpr nodes (OCOMPLIT).

Change-Id: I25671c79cc30749767bb16f84e9f151b943eccd1
Reviewed-on: https://go-review.googlesource.com/c/go/+/305509
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>

src/cmd/compile/internal/noder/decl.go
src/cmd/compile/internal/noder/expr.go
src/cmd/compile/internal/noder/helpers.go

index f0cdcbfc2e05ca015721af25f52d6255666390a3..4ca2eb4740a4916e171d2cfe278a38c9b472e9f1 100644 (file)
@@ -211,11 +211,24 @@ func (g *irgen) varDecl(out *ir.Nodes, decl *syntax.VarDecl) {
                        } else if ir.CurFunc == nil {
                                name.Defn = as
                        }
-                       out.Append(typecheck.Stmt(as))
+                       lhs := []ir.Node{as.X}
+                       rhs := []ir.Node{}
+                       if as.Y != nil {
+                               rhs = []ir.Node{as.Y}
+                       }
+                       transformAssign(as, lhs, rhs)
+                       as.X = lhs[0]
+                       if as.Y != nil {
+                               as.Y = rhs[0]
+                       }
+                       as.SetTypecheck(1)
+                       out.Append(as)
                }
        }
        if as2 != nil {
-               out.Append(typecheck.Stmt(as2))
+               transformAssign(as2, as2.Lhs, as2.Rhs)
+               as2.SetTypecheck(1)
+               out.Append(as2)
        }
 }
 
index effc63c09ab1be792382c66ae931732e93246e27..9db03a90053c361fa3b654d738c01d99e6dd030d 100644 (file)
@@ -15,7 +15,6 @@ import (
 )
 
 func (g *irgen) expr(expr syntax.Expr) ir.Node {
-       // TODO(mdempsky): Change callers to not call on nil?
        if expr == nil {
                return nil
        }
index 9ebf17aae65fbb0751eb92a0946c9b27e99a3669..cb8052c0cb70a01df7ccc5fa3e74a0922c5042ef 100644 (file)
@@ -18,10 +18,6 @@ import (
 //
 // TODO(mdempsky): Move into their own package so they can be easily
 // reused by iimport and frontend optimizations.
-//
-// TODO(mdempsky): Update to consistently return already typechecked
-// results, rather than leaving the caller responsible for using
-// typecheck.Expr or typecheck.Stmt.
 
 type ImplicitNode interface {
        ir.Node