blob: 60983c0d471097fa8312b4b0cc7d662c3860cdb2 [file] [log] [blame]
Dan Willemsena3223282018-02-27 19:41:43 -08001// errorcheck
2
3// Copyright 2017 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// Ensure that typed non-integer, negative and too large
8// values are not accepted as size argument in make for
9// maps.
10
11package main
12
13type T map[int]int
14
15var sink T
16
17func main() {
18 sink = make(T, -1) // ERROR "negative size argument in make.*"
19 sink = make(T, uint64(1<<63)) // ERROR "size argument too large in make.*"
20
21 sink = make(T, 0.5) // ERROR "constant 0.5 truncated to integer"
22 sink = make(T, 1.0)
23 sink = make(T, float32(1.0)) // ERROR "non-integer size argument in make.*"
24 sink = make(T, float64(1.0)) // ERROR "non-integer size argument in make.*"
25 sink = make(T, 1.0)
26 sink = make(T, float32(1.0)) // ERROR "non-integer size argument in make.*"
27 sink = make(T, float64(1.0)) // ERROR "non-integer size argument in make.*"
28 sink = make(T, 1+0i)
29 sink = make(T, complex64(1+0i)) // ERROR "non-integer size argument in make.*"
30 sink = make(T, complex128(1+0i)) // ERROR "non-integer size argument in make.*"
31 sink = make(T, 1+0i)
32 sink = make(T, complex64(1+0i)) // ERROR "non-integer size argument in make.*"
33 sink = make(T, complex128(1+0i)) // ERROR "non-integer size argument in make.*"
34}