Rémy Oudompheng | 2ece2f5 | 2012-02-18 22:15:42 +0100 | [diff] [blame] | 1 | // compile |
David Symonds | d5fa81e | 2009-04-20 21:03:38 -0700 | [diff] [blame] | 2 | |
| 3 | // Copyright 2009 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 | |
| 7 | package main |
| 8 | |
| 9 | type myMap map[string] int; |
| 10 | |
Russ Cox | 4c5c0f4 | 2009-06-25 14:44:09 -0700 | [diff] [blame] | 11 | func f() myMap { |
David Symonds | 2f8a2dc | 2009-04-21 20:26:26 -0700 | [diff] [blame] | 12 | m := make(map[string] int); |
Russ Cox | 4c5c0f4 | 2009-06-25 14:44:09 -0700 | [diff] [blame] | 13 | return m |
David Symonds | 2f8a2dc | 2009-04-21 20:26:26 -0700 | [diff] [blame] | 14 | } |
| 15 | |
David Symonds | d5fa81e | 2009-04-20 21:03:38 -0700 | [diff] [blame] | 16 | func main() { |
| 17 | m := make(myMap); |
| 18 | mp := &m; |
| 19 | |
| 20 | { |
Russ Cox | ae54cf7 | 2009-09-15 12:42:24 -0700 | [diff] [blame] | 21 | x, ok := m["key"]; |
| 22 | _, _ = x, ok; |
David Symonds | d5fa81e | 2009-04-20 21:03:38 -0700 | [diff] [blame] | 23 | } |
| 24 | { |
Russ Cox | ae54cf7 | 2009-09-15 12:42:24 -0700 | [diff] [blame] | 25 | x, ok := (*mp)["key"]; |
| 26 | _, _ = x, ok; |
David Symonds | d5fa81e | 2009-04-20 21:03:38 -0700 | [diff] [blame] | 27 | } |
| 28 | { |
Russ Cox | ae54cf7 | 2009-09-15 12:42:24 -0700 | [diff] [blame] | 29 | x, ok := f()["key"]; |
| 30 | _, _ = x, ok; |
David Symonds | 2f8a2dc | 2009-04-21 20:26:26 -0700 | [diff] [blame] | 31 | } |
| 32 | { |
| 33 | var x int; |
| 34 | var ok bool; |
Russ Cox | 1a31989 | 2009-09-14 21:03:53 -0700 | [diff] [blame] | 35 | x, ok = f()["key"]; |
| 36 | _, _ = x, ok; |
David Symonds | 2f8a2dc | 2009-04-21 20:26:26 -0700 | [diff] [blame] | 37 | } |
David Symonds | d5fa81e | 2009-04-20 21:03:38 -0700 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | /* |
| 41 | * bug143.go:19: assignment count mismatch: 2 = 1 |
| 42 | * bug143.go:18: x: undefined |
| 43 | * bug143.go:18: ok: undefined |
| 44 | */ |