3 // Copyright 2010 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.
7 // Verify that illegal uses of ... are detected.
14 func sum(args ...int) int { return 0 }
20 _ = sum(1.5) // ERROR "integer"
21 _ = sum("hello") // ERROR ".hello. .type string. as type int|incompatible"
22 _ = sum([]int{1}) // ERROR "\[\]int literal.*as type int|incompatible"
25 func sum3(int, int, int) int { return 0 }
26 func tuple() (int, int, int) { return 1, 2, 3 }
30 _ = sum(tuple()...) // ERROR "multiple-value|[.][.][.]"
32 _ = sum3(tuple()...) // ERROR "multiple-value|[.][.][.]" "not enough"
37 func funny(args ...T) int { return 0 }
42 _ = funny([]T{}) // ok because []T{} is a T; passes []T{[]T{}}
45 func bad(args ...int) {
46 print(1, 2, args...) // ERROR "[.][.][.]"
47 println(args...) // ERROR "[.][.][.]"
49 close(ch...) // ERROR "[.][.][.]"
50 _ = len(args...) // ERROR "[.][.][.]"
51 _ = new(int...) // ERROR "[.][.][.]"
53 _ = make([]byte, n...) // ERROR "[.][.][.]"
54 // TODO(rsc): enable after gofmt bug is fixed
55 // _ = make([]byte, 10 ...) // error "[.][.][.]"
57 _ = unsafe.Pointer(&x...) // ERROR "[.][.][.]"
58 _ = unsafe.Sizeof(x...) // ERROR "[.][.][.]"
59 _ = [...]byte("foo") // ERROR "[.][.][.]"
60 _ = [...][...]int{{1,2,3},{4,5,6}} // ERROR "[.][.][.]"