fix: compose recursion
This commit is contained in:
21
_test/struct46.go
Normal file
21
_test/struct46.go
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
type A struct {
|
||||||
|
B string
|
||||||
|
C D
|
||||||
|
}
|
||||||
|
|
||||||
|
type D struct {
|
||||||
|
E *A
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
a := &A{B: "b"}
|
||||||
|
a.C = D{E: a}
|
||||||
|
fmt.Println(a.C.E.B)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Output:
|
||||||
|
// b
|
||||||
@@ -1860,9 +1860,12 @@ func doCompositeSparse(n *node, hasType bool) {
|
|||||||
c1 := c.child[1]
|
c1 := c.child[1]
|
||||||
field := n.typ.fieldIndex(c.child[0].ident)
|
field := n.typ.fieldIndex(c.child[0].ident)
|
||||||
convertLiteralValue(c1, n.typ.field[field].typ.TypeOf())
|
convertLiteralValue(c1, n.typ.field[field].typ.TypeOf())
|
||||||
if c1.typ.cat == funcT {
|
switch {
|
||||||
|
case c1.typ.cat == funcT:
|
||||||
values[field] = genFunctionWrapper(c1)
|
values[field] = genFunctionWrapper(c1)
|
||||||
} else {
|
case isRecursiveStruct(n.typ.field[field].typ, n.typ.field[field].typ.rtype):
|
||||||
|
values[field] = genValueInterfacePtr(c1)
|
||||||
|
default:
|
||||||
values[field] = genValue(c1)
|
values[field] = genValue(c1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user