mirror of
https://github.com/golang/go
synced 2025-05-30 15:30:51 +00:00
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 <gri@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
committed by
Gopher Robot
parent
c759ea7471
commit
5e91059f8b
@ -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:
|
||||
|
Reference in New Issue
Block a user