diff options
author | Damian Gryski <[email protected]> | 2023-04-11 08:18:18 -0700 |
---|---|---|
committer | Damian Gryski <[email protected]> | 2023-04-11 18:54:05 -0700 |
commit | 0244bed0333885b7b399107ad4e8157c54b5c3b2 (patch) | |
tree | e46a8dc81ececb906efa30a9427ea15540b0b567 /testdata | |
parent | 60b23a7035f5d3df52b01cc3e6ed5ae8b79e00e5 (diff) | |
download | tinygo-0244bed0333885b7b399107ad4e8157c54b5c3b2.tar.gz tinygo-0244bed0333885b7b399107ad4e8157c54b5c3b2.zip |
testdata: add test for else/defer bug
Diffstat (limited to 'testdata')
-rw-r--r-- | testdata/calls.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/testdata/calls.go b/testdata/calls.go index b8b10c2c9..960443959 100644 --- a/testdata/calls.go +++ b/testdata/calls.go @@ -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 +} |