fix: correct new() when using in indirect assign (#202)
This commit is contained in:
committed by
Ludovic Fernandez
parent
548c57efc3
commit
ad009959af
13
_test/new1.go
Normal file
13
_test/new1.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
a := [1]*int{}
|
||||
a[0] = new(int)
|
||||
*a[0] = 2
|
||||
fmt.Println(*a[0])
|
||||
}
|
||||
|
||||
// Output:
|
||||
// 2
|
||||
@@ -1769,12 +1769,12 @@ func _len(n *Node) {
|
||||
}
|
||||
|
||||
func _new(n *Node) {
|
||||
i := n.findex
|
||||
dest := genValue(n)
|
||||
next := getExec(n.tnext)
|
||||
typ := n.child[1].typ.TypeOf()
|
||||
|
||||
n.exec = func(f *Frame) Builtin {
|
||||
f.data[i] = reflect.New(typ)
|
||||
dest(f).Set(reflect.New(typ))
|
||||
return next
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user