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 "1\.5 .untyped float constant. as int|integer"
21 _ = sum("hello") // ERROR ".hello. (.untyped string constant. as int|.type untyped string. as type int)|incompatible"
22 _ = sum([]int{1}) // ERROR "\[\]int{.*}.*as int value"
25 func sum3(int, int, int) int { return 0 }
26 func tuple() (int, int, int) { return 1, 2, 3 }
30 _ = sum(tuple()...) // ERROR "\.{3} with 3-valued|multiple-value"
32 _ = sum3(tuple()...) // ERROR "\.{3} in call to non-variadic|multiple-value|invalid use of .*[.][.][.]"
37 func funny(args ...T) int { return 0 }
42 _ = funny([]T{}) // ok because []T{} is a T; passes []T{[]T{}}
47 func bad(args ...int) {
48 print(1, 2, args...) // ERROR "[.][.][.]"
49 println(args...) // ERROR "[.][.][.]"
51 close(ch...) // ERROR "[.][.][.]"
52 _ = len(args...) // ERROR "[.][.][.]"
53 _ = new(int...) // ERROR "[.][.][.]"
55 _ = make([]byte, n...) // ERROR "[.][.][.]"
56 _ = make([]byte, 10 ...) // ERROR "[.][.][.]"
58 _ = unsafe.Pointer(&x...) // ERROR "[.][.][.]"
59 _ = unsafe.Sizeof(x...) // ERROR "[.][.][.]"
60 _ = [...]byte("foo") // ERROR "[.][.][.]"
61 _ = [...][...]int{{1,2,3},{4,5,6}} // ERROR "[.][.][.]"
63 Foo(x...) // ERROR "\.{3} in call to non-variadic|invalid use of .*[.][.][.]"