mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-06 20:13:40 +00:00
compiler: fix deferred calls to exported functions
Previously using defer with an exported function generated an invalid function call due to differences between TinyGo's calling convention and the C calling convention.
This commit is contained in:
Vendored
+7
@@ -72,6 +72,8 @@ func hello(n int) {
|
||||
}
|
||||
|
||||
func testDefer() {
|
||||
defer exportedDefer()
|
||||
|
||||
i := 1
|
||||
defer deferred("...run as defer", i)
|
||||
i++
|
||||
@@ -98,6 +100,11 @@ func deferred(msg string, i int) {
|
||||
println(msg, i)
|
||||
}
|
||||
|
||||
//go:export __exportedDefer
|
||||
func exportedDefer() {
|
||||
println("...exported defer")
|
||||
}
|
||||
|
||||
func testBound(f func() string) {
|
||||
println("bound method:", f())
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -4,6 +4,7 @@ Thing.Print: foo arg: bar
|
||||
...run as defer 3
|
||||
...run closure deferred: 4
|
||||
...run as defer 1
|
||||
...exported defer
|
||||
loop 3
|
||||
loop 2
|
||||
loop 1
|
||||
|
||||
Reference in New Issue
Block a user