blob: 6f1a1c8ac01c97288756dc5654acd189194f8807 [file] [log] [blame]
Russ Cox57eb06f2012-02-16 23:51:04 -05001// errorcheck
Russ Cox7ca40632011-09-19 13:11:24 -04002
3// Copyright 2011 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
Rob Pike501f0b52012-02-23 18:47:26 +11007// Test map declarations of many types, including erroneous ones.
8// Does not compile.
9
Russ Cox7ca40632011-09-19 13:11:24 -040010package main
11
12func main() {}
13
14type v bool
15
16var (
17 // valid
Russ Cox5bb54b82011-11-13 22:58:08 -050018 _ map[int8]v
19 _ map[uint8]v
20 _ map[int16]v
21 _ map[uint16]v
22 _ map[int32]v
23 _ map[uint32]v
24 _ map[int64]v
25 _ map[uint64]v
26 _ map[int]v
27 _ map[uint]v
Russ Cox7ca40632011-09-19 13:11:24 -040028 _ map[uintptr]v
29 _ map[float32]v
30 _ map[float64]v
31 _ map[complex64]v
32 _ map[complex128]v
33 _ map[bool]v
34 _ map[string]v
35 _ map[chan int]v
Russ Cox7ca40632011-09-19 13:11:24 -040036 _ map[*int]v
Russ Cox196b6632011-12-12 22:22:09 -050037 _ map[struct{}]v
38 _ map[[10]int]v
Russ Cox7ca40632011-09-19 13:11:24 -040039
40 // invalid
Russ Cox5bb54b82011-11-13 22:58:08 -050041 _ map[[]int]v // ERROR "invalid map key"
Russ Cox5bb54b82011-11-13 22:58:08 -050042 _ map[func()]v // ERROR "invalid map key"
43 _ map[map[int]int]v // ERROR "invalid map key"
Russ Cox6363fc52012-06-07 03:06:40 -040044 _ map[T1]v // ERROR "invalid map key"
45 _ map[T2]v // ERROR "invalid map key"
46 _ map[T3]v // ERROR "invalid map key"
47 _ map[T4]v // ERROR "invalid map key"
48 _ map[T5]v
49 _ map[T6]v
50 _ map[T7]v
51 _ map[T8]v
Russ Cox7ca40632011-09-19 13:11:24 -040052)
Russ Cox6363fc52012-06-07 03:06:40 -040053
54type T1 []int
55type T2 struct { F T1 }
56type T3 []T4
57type T4 struct { F T3 }
58
59type T5 *int
60type T6 struct { F T5 }
61type T7 *T4
62type T8 struct { F *T7 }