Russ Cox | 8080384 | 2012-02-16 23:49:59 -0500 | [diff] [blame] | 1 | // run |
Russ Cox | ece6a8c | 2010-07-15 16:14:06 -0700 | [diff] [blame] | 2 | |
| 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 | |
Péter Surányi | 9b6ccb1 | 2015-02-06 21:44:39 +0900 | [diff] [blame] | 7 | // http://golang.org/issue/846 |
Russ Cox | ece6a8c | 2010-07-15 16:14:06 -0700 | [diff] [blame] | 8 | |
| 9 | package main |
| 10 | |
| 11 | func x() (a int, b bool) { |
| 12 | defer func(){ |
| 13 | a++ |
| 14 | }() |
| 15 | a, b = y() |
| 16 | return |
| 17 | } |
| 18 | |
| 19 | func x2() (a int, b bool) { |
| 20 | defer func(){ |
| 21 | a++ |
| 22 | }() |
| 23 | return y() |
| 24 | } |
| 25 | |
| 26 | func y() (int, bool) { |
| 27 | return 4, false |
| 28 | } |
| 29 | |
| 30 | func main() { |
| 31 | if a, _ := x(); a != 5 { |
| 32 | println("BUG", a) |
| 33 | } |
| 34 | if a, _ := x2(); a != 5 { |
| 35 | println("BUG", a) |
| 36 | } |
| 37 | } |