In unified IR, fail right away if we find a types2.Invalid while
writing out the package. This provides a clearer error message for
https://github.com/golang/go/issues/25838#issuecomment-
448746670.
Updates #25838.
Change-Id: I6902fdd891fc31bbb832b6fdba00eca301282409
Reviewed-on: https://go-review.googlesource.com/c/go/+/338973
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
base.Fatalf("unexpected type: %v (%T)", typ, typ)
case *types2.Basic:
- if kind := typ.Kind(); types2.Typ[kind] == typ {
+ switch kind := typ.Kind(); {
+ case kind == types2.Invalid:
+ base.Fatalf("unexpected types2.Invalid")
+
+ case types2.Typ[kind] == typ:
w.code(typeBasic)
w.len(int(kind))
- break
- }
- // Handle "byte" and "rune" as references to their TypeName.
- obj := types2.Universe.Lookup(typ.Name())
- assert(obj.Type() == typ)
+ default:
+ // Handle "byte" and "rune" as references to their TypeName.
+ obj := types2.Universe.Lookup(typ.Name())
+ assert(obj.Type() == typ)
- w.code(typeNamed)
- w.obj(obj, nil)
+ w.code(typeNamed)
+ w.obj(obj, nil)
+ }
case *types2.Named:
// Type aliases can refer to uninstantiated generic types, so we