* fix: copy the type in recursion
In more advanced recursive cases, setting the rtype to interface may interfear with typeing. To stop this from happening, instead of setting t.val.rtype to interface in the hope it will be set correctly later, a copy if the type is made, and the rtype of the copy is set to interface{}.
* fix: detect intermediate recursive structs
In the case of a nested recussion, each symbol can have
a different perspective on the recursion. In this case,
it is impossible to move from one struct to the next.
To keep the perspectives the same, any intermediate struct
that contains a recursion should also be set to interface{}.
so that all perspectives are the same.
* fix: handle arb recursion
* chore: refactor dref to be consistent
* fix: invalid recursive struct issue
* fix: handle checkptr issue
* fix: move unsafe into function to stop ptr check
* fix: handle deref in assign
21 lines
419 B
Go
21 lines
419 B
Go
package main
|
|
|
|
import "fmt"
|
|
|
|
type Node struct {
|
|
Name string
|
|
Child map[string]Node
|
|
}
|
|
|
|
func main() {
|
|
a := Node{Name: "hello", Child: map[string]Node{}}
|
|
a.Child["1"] = Node{Name: "world", Child: map[string]Node{}}
|
|
fmt.Println(a)
|
|
a.Child["1"].Child["1"] = Node{Name: "sunshine", Child: map[string]Node{}}
|
|
fmt.Println(a)
|
|
}
|
|
|
|
// Output:
|
|
// {hello map[1:{world map[]}]}
|
|
// {hello map[1:{world map[1:{sunshine map[]}]}]}
|