cmd/compile: remove typechecker calls in varDecl()

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>
This commit is contained in:
Dan Scales 2021-03-25 12:23:44 -07:00
parent 2abf280a28
commit 1a7d921aa5
3 changed files with 15 additions and 7 deletions

View 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)
}
}