diff --git a/_test/struct53.go b/_test/struct53.go new file mode 100644 index 00000000..1d97004a --- /dev/null +++ b/_test/struct53.go @@ -0,0 +1,23 @@ +package main + +import "fmt" + +type T1 struct { + P []*T +} + +type T2 struct { + P2 *T +} + +type T struct { + *T1 + S1 *T +} + +func main() { + fmt.Println(T2{}) +} + +// Output: +// {} diff --git a/interp/type.go b/interp/type.go index f08ac796..7394d109 100644 --- a/interp/type.go +++ b/interp/type.go @@ -1385,6 +1385,8 @@ func hasRecursiveStruct(t *itype, defined map[string]*itype) bool { if defined[typ.path+"/"+typ.name] != nil { return true } + defined[typ.path+"/"+typ.name] = typ + for _, f := range typ.field { if hasRecursiveStruct(f.typ, defined) { return true