]> Cypherpunks repositories - gostls13.git/commitdiff
go/types, types2: ensure we have a fully resolved type in validType
authorRobert Griesemer <gri@golang.org>
Wed, 16 Mar 2022 21:09:56 +0000 (14:09 -0700)
committerRobert Griesemer <gri@golang.org>
Mon, 21 Mar 2022 19:10:26 +0000 (19:10 +0000)
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 <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
src/cmd/compile/internal/types2/validtype.go
src/go/types/validtype.go

index f365ad1e27e9ab926b5b78e1d3ec07432862851b..c7d42551dd46dd014d4cd6285f0cab3930daf883 100644 (file)
@@ -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
                }
index 7d7029bce268c7d05db4c54940ff3f058395ecab..2c686f265506e48bd90d236d5ee31937618bdf8b 100644 (file)
@@ -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
                }