From: Robert Griesemer Date: Wed, 16 Mar 2022 21:09:56 +0000 (-0700) Subject: go/types, types2: ensure we have a fully resolved type in validType X-Git-Tag: go1.19beta1~979 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=7751883379621d8ecbf7e4920af0a81c31f2c078;p=gostls13.git go/types, types2: ensure we have a fully resolved type in validType This addresses a situation where Named.fromRHS is nil which is causing validType to panic when the debug flag is set. Change-Id: Ie1af3f4d412efc2ce2ee7707af5375ed130a1f2a Reviewed-on: https://go-review.googlesource.com/c/go/+/393436 Trust: Robert Griesemer Reviewed-by: Robert Findley --- diff --git a/src/cmd/compile/internal/types2/validtype.go b/src/cmd/compile/internal/types2/validtype.go index f365ad1e27..c7d42551dd 100644 --- a/src/cmd/compile/internal/types2/validtype.go +++ b/src/cmd/compile/internal/types2/validtype.go @@ -63,7 +63,8 @@ func (check *Checker) validType0(typ Type, env *tparamEnv, path []Object) typeIn case *Named: // Don't report a 2nd error if we already know the type is invalid // (e.g., if a cycle was detected earlier, via under). - if t.underlying == Typ[Invalid] { + // Note: ensure that t.orig is fully resolved by calling Underlying(). + if t.Underlying() == Typ[Invalid] { check.infoMap[t] = invalid return invalid } diff --git a/src/go/types/validtype.go b/src/go/types/validtype.go index 7d7029bce2..2c686f2655 100644 --- a/src/go/types/validtype.go +++ b/src/go/types/validtype.go @@ -62,8 +62,8 @@ func (check *Checker) validType0(typ Type, env *tparamEnv, path []Object) typeIn case *Named: // Don't report a 2nd error if we already know the type is invalid - // (e.g., if a cycle was detected earlier, via under). - if t.underlying == Typ[Invalid] { + // Note: ensure that t.orig is fully resolved by calling Underlying(). + if t.Underlying() == Typ[Invalid] { check.infoMap[t] = invalid return invalid }