2012-02-17 04:51:04 +00:00
|
|
|
// errorcheck
|
2011-09-19 17:11:24 +00:00
|
|
|
|
2016-04-10 21:32:26 +00:00
|
|
|
// Copyright 2011 The Go Authors. All rights reserved.
|
2011-09-19 17:11:24 +00:00
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2012-02-23 07:47:26 +00:00
|
|
|
// Test map declarations of many types, including erroneous ones.
|
|
|
|
// Does not compile.
|
|
|
|
|
2011-09-19 17:11:24 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
type v bool
|
|
|
|
|
|
|
|
var (
|
|
|
|
// valid
|
2011-11-14 03:58:08 +00:00
|
|
|
_ 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
|
2011-09-19 17:11:24 +00:00
|
|
|
_ 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[*int]v
|
2011-12-13 03:22:09 +00:00
|
|
|
_ map[struct{}]v
|
|
|
|
_ map[[10]int]v
|
2011-09-19 17:11:24 +00:00
|
|
|
|
|
|
|
// invalid
|
2011-11-14 03:58:08 +00:00
|
|
|
_ map[[]int]v // ERROR "invalid map key"
|
|
|
|
_ map[func()]v // ERROR "invalid map key"
|
|
|
|
_ map[map[int]int]v // ERROR "invalid map key"
|
2012-06-07 07:06:40 +00:00
|
|
|
_ map[T1]v // ERROR "invalid map key"
|
|
|
|
_ map[T2]v // ERROR "invalid map key"
|
|
|
|
_ map[T3]v // ERROR "invalid map key"
|
|
|
|
_ map[T4]v // ERROR "invalid map key"
|
|
|
|
_ map[T5]v
|
|
|
|
_ map[T6]v
|
|
|
|
_ map[T7]v
|
|
|
|
_ map[T8]v
|
2011-09-19 17:11:24 +00:00
|
|
|
)
|
2012-06-07 07:06:40 +00:00
|
|
|
|
|
|
|
type T1 []int
|
|
|
|
type T2 struct { F T1 }
|
|
|
|
type T3 []T4
|
|
|
|
type T4 struct { F T3 }
|
|
|
|
|
|
|
|
type T5 *int
|
|
|
|
type T6 struct { F T5 }
|
|
|
|
type T7 *T4
|
|
|
|
type T8 struct { F *T7 }
|
2017-04-22 13:28:58 +00:00
|
|
|
|
|
|
|
func main() {
|
|
|
|
m := make(map[int]int)
|
|
|
|
delete() // ERROR "missing arguments"
|
|
|
|
delete(m) // ERROR "missing second \(key\) argument"
|
|
|
|
delete(m, 2, 3) // ERROR "too many arguments"
|
|
|
|
delete(1, m) // ERROR "first argument to delete must be map"
|
|
|
|
}
|