-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
interp: fix detection of type recursivity
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.
- Loading branch information
Showing
2 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters