-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
interp: wrap source functions when used as input parameters.
It allows to use interpreter functions as parameters in the runtime, even for defered callbacks, or when passed as empty interfaces, as for runtime.SetFinalizer. Fixes #1503
- Loading branch information
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters