fix: automatic type conversion for untyped arg of append (#177)

This commit is contained in:
Marc Vertes
2019-05-01 16:49:57 +02:00
committed by Ludovic Fernandez
parent 5cdcf61e0e
commit c6c7f8cea6
3 changed files with 29 additions and 1 deletions

View File

@@ -1406,7 +1406,11 @@ func _append(n *Node) {
l := len(args)
values := make([]func(*Frame) reflect.Value, l)
for i, arg := range args {
values[i] = genValue(arg)
if arg.typ.untyped {
values[i] = genValueAs(arg, n.child[1].typ.TypeOf().Elem())
} else {
values[i] = genValue(arg)
}
}
n.exec = func(f *Frame) Builtin {
@@ -1419,6 +1423,9 @@ func _append(n *Node) {
}
} else {
value0 := genValue(n.child[2])
if n.child[2].typ.untyped {
value0 = genValueAs(n.child[2], n.child[1].typ.TypeOf().Elem())
}
n.exec = func(f *Frame) Builtin {
dest(f).Set(reflect.Append(value(f), value0(f)))