fix: assign composite literal by reference

This commit is contained in:
Marc Vertes
2020-04-16 12:24:04 +02:00
committed by GitHub
parent 50a34fd2a7
commit 29e1777d82
2 changed files with 18 additions and 1 deletions

View File

@@ -1732,6 +1732,7 @@ func doCompositeLit(n *node, hasType bool) {
}
}
i := n.findex
n.exec = func(f *frame) bltn {
a := reflect.New(n.typ.TypeOf()).Elem()
for i, v := range values {
@@ -1743,7 +1744,7 @@ func doCompositeLit(n *node, hasType bool) {
case destInterface:
d.Set(reflect.ValueOf(valueInterface{n, a}))
default:
d.Set(a)
f.data[i] = a
}
return next
}