blob: c985305668db7eb83b265954daba7f4414dac1b3 [file] [log] [blame]
Russ Cox80803842012-02-16 23:49:59 -05001// run
Russ Coxece6a8c2010-07-15 16:14:06 -07002
3// Copyright 2010 The Go Authors. All rights reserved.
4// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file.
6
Brad Fitzpatrick2ae77372015-07-10 17:17:11 -06007// https://golang.org/issue/846
Russ Coxece6a8c2010-07-15 16:14:06 -07008
9package main
10
11func x() (a int, b bool) {
12 defer func(){
13 a++
14 }()
15 a, b = y()
16 return
17}
18
19func x2() (a int, b bool) {
20 defer func(){
21 a++
22 }()
23 return y()
24}
25
26func y() (int, bool) {
27 return 4, false
28}
29
30func main() {
31 if a, _ := x(); a != 5 {
32 println("BUG", a)
33 }
34 if a, _ := x2(); a != 5 {
35 println("BUG", a)
36 }
37}