mirror of
https://github.com/golang/go
synced 2024-11-25 10:47:56 -07:00
bdc6dbbc64
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: cd042fdc38
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>
28 lines
696 B
Go
28 lines
696 B
Go
// errorcheck -lang=go1.17
|
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package main
|
|
|
|
type I1 interface{ I2 } // ERROR "interface"
|
|
type I2 int
|
|
|
|
type I3 interface{ int } // ERROR "interface"
|
|
|
|
type S struct { // GC_ERROR "invalid recursive type"
|
|
x interface{ S } // GCCGO_ERROR "interface"
|
|
}
|
|
type I4 interface { // GC_ERROR "invalid recursive type: I4 refers to itself"
|
|
I4 // GCCGO_ERROR "interface"
|
|
}
|
|
|
|
type I5 interface { // GC_ERROR "invalid recursive type I5\n\tLINE:.* I5 refers to I6\n\tLINE+4:.* I6 refers to I5$"
|
|
I6
|
|
}
|
|
|
|
type I6 interface {
|
|
I5 // GCCGO_ERROR "interface"
|
|
}
|