testdata: add test for else/defer bug

Этот коммит содержится в:
Damian Gryski 2023-04-11 08:18:18 -07:00 коммит произвёл Damian Gryski
родитель 60b23a7035
коммит 0244bed033

16
testdata/calls.go предоставленный
Просмотреть файл

@ -82,6 +82,10 @@ func main() {
// covered the entire variable. // covered the entire variable.
var x issue1304 var x issue1304
x.call() x.call()
if testDeferElse(false) != 0 {
println("else defer returned wrong value")
}
} }
func runFunc(f func(int), arg int) { func runFunc(f func(int), arg int) {
@ -232,3 +236,15 @@ func (x issue1304) call() {
type recursiveFuncType func(recursiveFuncType) type recursiveFuncType func(recursiveFuncType)
var recursiveFunction recursiveFuncType var recursiveFunction recursiveFuncType
//go:noinline
func testDeferElse(b bool) (r int) {
if !b {
defer func() {
r = 0
}()
}
return 1
}