-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
interp: handle struct with multiple recursive fields (#1372)
* interp: handle struct with multiple recursive fields In case of a recursive struct with several recursive fields of different type, only the first one was properly fixed when constructing the corresponding reflect type. We now memorize and process all fields at the same depth level. Fixes #1371. * Update interp/type.go Co-authored-by: mpl <mathieu.lonjaret@gmail.com> * fix lint * fix comment Co-authored-by: mpl <mathieu.lonjaret@gmail.com>
- Loading branch information
Showing
2 changed files
with
31 additions
and
6 deletions.
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,18 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
type node struct { | ||
parent *node | ||
child []*node | ||
key string | ||
} | ||
|
||
func main() { | ||
root := &node{key: "root"} | ||
root.child = nil | ||
fmt.Println("root:", root) | ||
} | ||
|
||
// Output: | ||
// root: &{<nil> [] root} |
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