Fix handling chan boolean values

This commit is contained in:
Marc Vertes
2018-11-29 19:28:12 +01:00
parent eb56b7dbb1
commit 5c7b669fcc
3 changed files with 54 additions and 5 deletions

View File

@@ -1188,13 +1188,23 @@ func _make(n *Node) {
// recv reads from a channel
func recv(n *Node) {
i := n.findex
value := genValue(n.child[0])
next := getExec(n.tnext)
tnext := getExec(n.tnext)
n.exec = func(f *Frame) Builtin {
f.data[i], _ = value(f).Recv()
return next
if n.fnext != nil {
fnext := getExec(n.fnext)
n.exec = func(f *Frame) Builtin {
if v, _ := value(f).Recv(); v.Bool() {
return tnext
}
return fnext
}
} else {
i := n.findex
n.exec = func(f *Frame) Builtin {
f.data[i], _ = value(f).Recv()
return tnext
}
}
}