mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-07-26 06:38:42 +00:00
testdata: add test for else/defer bug
This commit is contained in:
committed by
Damian Gryski
parent
60b23a7035
commit
0244bed033
Vendored
+16
@@ -82,6 +82,10 @@ func main() {
|
||||
// covered the entire variable.
|
||||
var x issue1304
|
||||
x.call()
|
||||
|
||||
if testDeferElse(false) != 0 {
|
||||
println("else defer returned wrong value")
|
||||
}
|
||||
}
|
||||
|
||||
func runFunc(f func(int), arg int) {
|
||||
@@ -232,3 +236,15 @@ func (x issue1304) call() {
|
||||
type recursiveFuncType func(recursiveFuncType)
|
||||
|
||||
var recursiveFunction recursiveFuncType
|
||||
|
||||
//go:noinline
|
||||
func testDeferElse(b bool) (r int) {
|
||||
if !b {
|
||||
defer func() {
|
||||
r = 0
|
||||
|
||||
}()
|
||||
}
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user