If a struct contains several fields of the same temporary incomplete type, it could be detected incorrectly as a recursive struct. Pass a copy of defined types map to avoid this issue. Fixes #1007.
41 lines
408 B
Go
41 lines
408 B
Go
package main
|
|
|
|
type TypeA struct {
|
|
B TypeB
|
|
}
|
|
|
|
type TypeB struct {
|
|
C1 *TypeC
|
|
C2 *TypeC
|
|
}
|
|
|
|
type TypeC struct {
|
|
Val string
|
|
D *TypeD
|
|
D2 *TypeD
|
|
}
|
|
|
|
type TypeD struct {
|
|
Name string
|
|
}
|
|
|
|
func build() *TypeA {
|
|
return &TypeA{
|
|
B: TypeB{
|
|
C2: &TypeC{Val: "22"},
|
|
},
|
|
}
|
|
}
|
|
|
|
func Bar(s string) string {
|
|
a := build()
|
|
return s + "-" + a.B.C2.Val
|
|
}
|
|
|
|
func main() {
|
|
println(Bar("test"))
|
|
}
|
|
|
|
// Output:
|
|
// test-22
|