fix: assign binary func to func type var

This commit is contained in:
Marc Vertes
2019-10-20 04:52:03 +02:00
committed by Traefiker Bot
parent ac504a2e8a
commit 15686873e0
5 changed files with 49 additions and 3 deletions

View File

@@ -227,6 +227,8 @@ func assign(n *node) {
svalue[i] = genInterfaceWrapper(src, dest.typ.rtype)
case dest.typ.cat == valueT && src.typ.cat == funcT:
svalue[i] = genFunctionWrapper(src)
case dest.typ.cat == funcT && src.typ.cat == valueT:
svalue[i] = genValueNode(src)
case src.kind == basicLit && src.val == nil:
t := dest.typ.TypeOf()
svalue[i] = func(*frame) reflect.Value { return reflect.New(t).Elem() }
@@ -649,6 +651,29 @@ func call(n *node) {
n.exec = func(f *frame) bltn {
def := value(f).Interface().(*node)
// Call bin func if defined
if def.rval.IsValid() {
in := make([]reflect.Value, len(values))
for i, v := range values {
in[i] = v(f)
}
if goroutine {
go def.rval.Call(in)
return tnext
}
out := def.rval.Call(in)
for i, v := range rvalues {
if v != nil {
v(f).Set(out[i])
}
}
if fnext != nil && !out[0].Bool() {
return fnext
}
return tnext
}
anc := f
// Get closure frame context (if any)
if def.frame != nil {