]> Cypherpunks repositories - gostls13.git/commit
go/types: improve recursive type error message
authorMax Neverov <neverov.max@gmail.com>
Wed, 9 Oct 2024 00:00:28 +0000 (00:00 +0000)
committerRobert Griesemer <gri@google.com>
Tue, 22 Oct 2024 22:20:29 +0000 (22:20 +0000)
commitbdc6dbbc6465bc617b778e6e3a1ae49daa35ea69
treeb37627cf048bac43969a8f9e5de0f6067ef5c6a3
parentd40ae5efc889bf4f0878eefe52694112e93a7542
go/types: improve recursive type error message

This change improves error message for recursive types.
Currently, compilation of the [following program](https://go.dev/play/p/3ef84ObpzfG):

package main

type T1[T T2] struct{}
type T2[T T1] struct{}

returns an error:

./prog.go:3:6: invalid recursive type T1
./prog.go:3:6: T1 refers to
./prog.go:4:6: T2 refers to
./prog.go:3:6: T1

With the patch applied the error message looks like:

./prog.go:3:6: invalid recursive type T1
./prog.go:3:6: T1 refers to T2
./prog.go:4:6: T2 refers to T1

Change-Id: Ic07cdffcffb1483c672b241fede4e694269b5b79
GitHub-Last-Rev: cd042fdc384cf5591b3258ca80fdc002bb8c5e0d
GitHub-Pull-Request: golang/go#69574
Reviewed-on: https://go-review.googlesource.com/c/go/+/614084
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tim King <taking@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/cmd/compile/internal/types2/decl.go
src/cmd/compile/internal/types2/initorder.go
src/go/types/decl.go
src/go/types/initorder.go
test/fixedbugs/bug195.go
test/fixedbugs/issue41575.go
test/fixedbugs/issue50788.dir/b.go
test/initloop.go