diff options
| author | Mark Freeman <mark@golang.org> | 2026-01-08 16:06:45 -0500 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2026-01-27 07:52:02 -0800 |
| commit | 8ca47fab421e99306afb6f7a0941d85f579ae3c0 (patch) | |
| tree | a30fae2a35ad16339fa864e45ebddea7d1960f07 /src/internal | |
| parent | 2d1f571c6b420757b2a72b9e53d486840a1317f9 (diff) | |
| download | go-8ca47fab421e99306afb6f7a0941d85f579ae3c0.tar.xz | |
go/types, types2: replace pendingType with completion check
This change establishes the invariant that Underlying() cannot observe
a nil RHS for a defined type, unless that type was created by go/types
with an explicitly nil underlying type.
It does so using isComplete, which is a guard to check that a type has
an underlying type. This guard is needed whenever we could produce a
value of a defined type or access some property of a defined type.
Examples include T{}, *x (where x has type *T), T.x, etc. (see CL
734600 for more).
The pendingType mechanism to deeply traverse values of a defined type
is moved to hasVarSize, since this is only truly needed at the site
of a built-in such as unsafe.Sizeof.
This ties cycle detection across value context directly to the syntax,
which seems like the right direction.
Change-Id: Ic47862a2038fb2ba3ae6621e9907265ccbd86ea3
Reviewed-on: https://go-review.googlesource.com/c/go/+/734980
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Mark Freeman <markfreeman@google.com>
Diffstat (limited to 'src/internal')
| -rw-r--r-- | src/internal/types/testdata/fixedbugs/issue52915.go | 2 | ||||
| -rw-r--r-- | src/internal/types/testdata/fixedbugs/issue75918.go | 2 | ||||
| -rw-r--r-- | src/internal/types/testdata/fixedbugs/issue76478.go | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/src/internal/types/testdata/fixedbugs/issue52915.go b/src/internal/types/testdata/fixedbugs/issue52915.go index e60c1767e9..4c7adff5c5 100644 --- a/src/internal/types/testdata/fixedbugs/issue52915.go +++ b/src/internal/types/testdata/fixedbugs/issue52915.go @@ -18,4 +18,4 @@ func _[P any]() { _ = unsafe.Sizeof(struct{ T[P] }{}) } -const _ = unsafe.Sizeof(T /* ERROR "invalid recursive type" */ [int]{}) +const _ = unsafe /* ERROR "not constant" */ .Sizeof(T /* ERROR "invalid recursive type" */ [int]{}) diff --git a/src/internal/types/testdata/fixedbugs/issue75918.go b/src/internal/types/testdata/fixedbugs/issue75918.go index 373db4a21b..713bb2e207 100644 --- a/src/internal/types/testdata/fixedbugs/issue75918.go +++ b/src/internal/types/testdata/fixedbugs/issue75918.go @@ -6,7 +6,7 @@ package p import "unsafe" -type A /* ERROR "invalid recursive type" */ [unsafe.Sizeof(S{})]byte +type A /* ERROR "invalid recursive type" */ [unsafe/* ERROR "must be constant" */.Sizeof(S{})]byte type S struct { a A diff --git a/src/internal/types/testdata/fixedbugs/issue76478.go b/src/internal/types/testdata/fixedbugs/issue76478.go index f16b40e04e..76f71dba74 100644 --- a/src/internal/types/testdata/fixedbugs/issue76478.go +++ b/src/internal/types/testdata/fixedbugs/issue76478.go @@ -15,7 +15,7 @@ func f() D { } type D C -type E /* ERROR "invalid recursive type" */ [unsafe.Sizeof(g[F]())]int +type E /* ERROR "invalid recursive type" */ [unsafe/* ERROR "must be constant" */.Sizeof(g[F]())]int func g[P any]() P { panic(0) } |
