diff --git a/_test/fun28.go b/_test/fun28.go new file mode 100644 index 000000000..c502b4c9e --- /dev/null +++ b/_test/fun28.go @@ -0,0 +1,25 @@ +package main + +import ( + "runtime" +) + +type T struct { + name string +} + +func finalize(t *T) { println("finalize") } + +func newT() *T { + t := new(T) + runtime.SetFinalizer(t, finalize) + return t +} + +func main() { + t := newT() + println(t != nil) +} + +// Output: +// true diff --git a/interp/run.go b/interp/run.go index c2fb5689c..a8cc80b7b 100644 --- a/interp/run.go +++ b/interp/run.go @@ -1561,6 +1561,8 @@ func callBin(n *node) { values = append(values, genValue(c)) case isInterfaceSrc(c.typ): values = append(values, genValueInterfaceValue(c)) + case isFuncSrc(c.typ): + values = append(values, genFunctionWrapper(c)) case c.typ.cat == arrayT || c.typ.cat == variadicT: if isEmptyInterface(c.typ.val) { values = append(values, genValueArray(c))