fix: correct handling of logical expression involving parenthesis block (#194)

This commit is contained in:
Marc Vertes
2019-05-29 15:51:41 +02:00
committed by Ludovic Fernandez
parent 557a02d616
commit 873df6b445
5 changed files with 235 additions and 62 deletions

View File

@@ -1109,19 +1109,21 @@ func land(n *Node) {
value0 := genValue(n.child[0])
value1 := genValue(n.child[1])
tnext := getExec(n.tnext)
dest := genValue(n)
if n.fnext != nil {
fnext := getExec(n.fnext)
n.exec = func(f *Frame) Builtin {
if value0(f).Bool() && value1(f).Bool() {
dest(f).SetBool(true)
return tnext
}
dest(f).SetBool(false)
return fnext
}
} else {
i := n.findex
n.exec = func(f *Frame) Builtin {
f.data[i].SetBool(value0(f).Bool() && value1(f).Bool())
dest(f).SetBool(value0(f).Bool() && value1(f).Bool())
return tnext
}
}
@@ -1131,19 +1133,21 @@ func lor(n *Node) {
value0 := genValue(n.child[0])
value1 := genValue(n.child[1])
tnext := getExec(n.tnext)
dest := genValue(n)
if n.fnext != nil {
fnext := getExec(n.fnext)
n.exec = func(f *Frame) Builtin {
if value0(f).Bool() || value1(f).Bool() {
dest(f).SetBool(true)
return tnext
}
dest(f).SetBool(false)
return fnext
}
} else {
i := n.findex
n.exec = func(f *Frame) Builtin {
f.data[i].SetBool(value0(f).Bool() || value1(f).Bool())
dest(f).SetBool(value0(f).Bool() || value1(f).Bool())
return tnext
}
}