From: Robert Griesemer Date: Tue, 12 Nov 2024 22:14:19 +0000 (-0800) Subject: go/types: adjust type-checking of pointer types X-Git-Tag: go1.24rc1~416 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=5e91059f8b5cc078b4b0bfa38290a98414e441e2;p=gostls13.git go/types: adjust type-checking of pointer types This matches the behavior of types2. For #49005. Change-Id: I45661c96124f1c75c4fb6f69cbba7c73984a8231 Reviewed-on: https://go-review.googlesource.com/c/go/+/626039 Auto-Submit: Robert Griesemer LUCI-TryBot-Result: Go LUCI Reviewed-by: Robert Griesemer Reviewed-by: Robert Findley --- diff --git a/src/go/types/typexpr.go b/src/go/types/typexpr.go index c83f53ba61..0b88f31d73 100644 --- a/src/go/types/typexpr.go +++ b/src/go/types/typexpr.go @@ -334,6 +334,13 @@ func (check *Checker) typInternal(e0 ast.Expr, def *TypeName) (T Type) { typ.base = Typ[Invalid] // avoid nil base in invalid recursive type declaration setDefType(def, typ) typ.base = check.varType(e.X) + // If typ.base is invalid, it's unlikely that *base is particularly + // useful - even a valid dereferenciation will lead to an invalid + // type again, and in some cases we get unexpected follow-on errors + // (e.g., go.dev/issue/49005). Return an invalid type instead. + if !isValid(typ.base) { + return Typ[Invalid] + } return typ case *ast.FuncType: