Prep refactoring for the next CL, which removes Name.Ntype
entirely. Pulled out separately because this logic is a little subtle,
so this should be easier to bisect in case there's something I'm
missing here.
Change-Id: I4ffec6ee62fcd036582e8d2c963edcbd8bac184f
Reviewed-on: https://go-review.googlesource.com/c/go/+/403837
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
checkLHS := func(i int, typ *types.Type) {
lhs[i] = Resolve(lhs[i])
- if n := lhs[i]; typ != nil && ir.DeclaredBy(n, stmt) && n.Name().Ntype == nil {
- if typ.Kind() != types.TNIL {
- n.SetType(defaultType(typ))
- } else {
- base.Errorf("use of untyped nil")
- }
+ if n := lhs[i]; typ != nil && ir.DeclaredBy(n, stmt) && n.Type() == nil {
+ base.Assertf(typ.Kind() == types.TNIL, "unexpected untyped nil")
+ n.SetType(defaultType(typ))
}
if lhs[i].Typecheck() == 0 {
lhs[i] = AssignExpr(lhs[i])