fix: handle append a string to a byte array (#133)

This commit is contained in:
Marc Vertes
2019-03-22 10:27:02 +01:00
committed by Ludovic Fernandez
parent 3616fb1b82
commit e766c272ed
4 changed files with 30 additions and 8 deletions

View File

@@ -1308,14 +1308,23 @@ func _case(n *Node) {
func appendSlice(n *Node) {
i := n.findex
value := genValue(n.child[1])
next := getExec(n.tnext)
value := genValue(n.child[1])
value0 := genValue(n.child[2])
n.exec = func(f *Frame) Builtin {
f.data[i] = reflect.AppendSlice(value(f), value0(f))
return next
if isString(n.child[2].typ) {
typ := reflect.TypeOf([]byte{})
n.exec = func(f *Frame) Builtin {
f.data[i] = reflect.AppendSlice(value(f), value0(f).Convert(typ))
return next
}
} else {
n.exec = func(f *Frame) Builtin {
f.data[i] = reflect.AppendSlice(value(f), value0(f))
return next
}
}
}
func _append(n *Node) {