Test equality on interface, for compatibility with all comparable types.

This is slower than direct test on value, which requires code geneation
(next step).
This commit is contained in:
Marc Vertes
2018-11-29 13:40:26 +01:00
parent e7d185fc0e
commit 65933b2441

View File

@@ -685,14 +685,14 @@ func equal(n *Node) {
if n.fnext == nil {
n.exec = func(f *Frame) Builtin {
f.data[i].SetBool(value0(f).Int() == value1(f).Int())
f.data[i].SetBool(value0(f).Interface() == value1(f).Interface())
return tnext
}
} else {
fnext := getExec(n.fnext)
n.exec = func(f *Frame) Builtin {
if value0(f).Int() == value1(f).Int() {
if value0(f).Interface() == value1(f).Interface() {
return tnext
}
return fnext
@@ -708,14 +708,14 @@ func notEqual(n *Node) {
if n.fnext == nil {
n.exec = func(f *Frame) Builtin {
f.data[i].SetBool(value0(f).Int() != value1(f).Int())
f.data[i].SetBool(value0(f).Interface() != value1(f).Interface())
return tnext
}
} else {
fnext := getExec(n.fnext)
n.exec = func(f *Frame) Builtin {
if value0(f).Int() != value1(f).Int() {
if value0(f).Interface() != value1(f).Interface() {
return tnext
}
return fnext