aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMark Freeman <mark@golang.org>2025-11-24 17:04:49 -0500
committerGopher Robot <gobot@golang.org>2025-11-26 16:15:28 -0800
commit3531ac23d4aac6bdd914f14f65ee5fdc5e6e98fa (patch)
tree2e29591c6ee6b819f87e93f1986a4b491a3d8d84 /test
parent2b8dbb35b0d6a5601ae9b6f1d1de106774251214 (diff)
downloadgo-3531ac23d4aac6bdd914f14f65ee5fdc5e6e98fa.tar.xz
go/types, types2: replace setDefType with pending type check
Given a type definition of the form: type T RHS The setDefType function would set T.fromRHS as soon as we knew its top-level type. For instance, in: type S struct { ... } S.fromRHS is set to a struct type before type-checking anything inside the struct. This permit access to the (incomplete) RHS type in a cyclic type declaration. Accessing this information is fraught (as it's incomplete), but was used for reporting certain types of cycles. This CL replaces setDefType with a check that ensures no value of type T is used before its RHS is set up. This CL is strictly more complete than what setDefType achieved. For instance, it enables correct reporting for the below cycles: type A [unsafe.Sizeof(A{})]int var v any = 42 type B [v.(B)]int func f() C { return C{} } type C [unsafe.Sizeof(f())]int Fixes #76383 Fixes #76384 Change-Id: I9dfab5b708013b418fa66e43362bb4d8483fedec Reviewed-on: https://go-review.googlesource.com/c/go/+/724140 Auto-Submit: Mark Freeman <markfreeman@google.com> Reviewed-by: Robert Griesemer <gri@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'test')
-rw-r--r--test/fixedbugs/issue18392.go7
1 files changed, 2 insertions, 5 deletions
diff --git a/test/fixedbugs/issue18392.go b/test/fixedbugs/issue18392.go
index 32c39c3a7f..9e4d48d6ea 100644
--- a/test/fixedbugs/issue18392.go
+++ b/test/fixedbugs/issue18392.go
@@ -6,9 +6,6 @@
package p
-type A interface {
- // TODO(mdempsky): This should be an error, but this error is
- // nonsense. The error should actually mention that there's a
- // type loop.
- Fn(A.Fn) // ERROR "type A has no method Fn|A.Fn undefined|A.Fn is not a type"
+type A interface { // ERROR "invalid recursive type"
+ Fn(A.Fn)
}