diff options
author | Russ Cox <rsc@golang.org> | 2011-09-19 13:11:24 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2011-09-19 13:11:24 -0400 |
commit | 7ca406396f33d69fbe922ee9e8d305c61f6d4394 (patch) | |
tree | 5fcfa9d00c43848720013c9445b98c2ff98b3b71 /test/map1.go | |
parent | 48ff4a849c7c532cbdd0cfa4a0f66859967c65a0 (diff) | |
download | go-7ca406396f33d69fbe922ee9e8d305c61f6d4394.tar.gz go-7ca406396f33d69fbe922ee9e8d305c61f6d4394.zip |
gc: disallow invalid map keys
The algtype-based test broke when algtype
got a bit more fine-grained, so replace with
an explicit check for the invalid key types.
R=ken2
CC=golang-dev
https://golang.org/cl/5071041
Diffstat (limited to 'test/map1.go')
-rw-r--r-- | test/map1.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/test/map1.go b/test/map1.go new file mode 100644 index 0000000000..3a56cf057d --- /dev/null +++ b/test/map1.go @@ -0,0 +1,41 @@ +// errchk $G -e $D/$F.go + +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +func main() {} + +type v bool + +var ( + // valid + _ map[int8]v + _ map[uint8]v + _ map[int16]v + _ map[uint16]v + _ map[int32]v + _ map[uint32]v + _ map[int64]v + _ map[uint64]v + _ map[int]v + _ map[uint]v + _ map[uintptr]v + _ map[float32]v + _ map[float64]v + _ map[complex64]v + _ map[complex128]v + _ map[bool]v + _ map[string]v + _ map[chan int]v + _ map[func()]v + _ map[*int]v + _ map[map[int]int]v + + // invalid + _ map[struct{}]v // ERROR "invalid map key" + _ map[[]int]v // ERROR "invalid map key" + _ map[[10]int]v // ERROR "invalid map key" +) |