testdata: add test for else/defer bug

This commit is contained in:
Damian Gryski
2023-04-11 08:18:18 -07:00
committed by Damian Gryski
parent 60b23a7035
commit 0244bed033
+16
View File
@@ -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
}