blob: fcd32c282fa59083d2af29b4c11c7dd51d3de585 [file] [log] [blame]
Russ Cox68796b02010-02-01 00:25:59 -08001// errchk $G -e $D/$F.go
2
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.
6
7package main
8
Russ Cox75dd8fd2010-09-24 11:55:30 -04009import "unsafe"
10
Russ Cox68796b02010-02-01 00:25:59 -080011func sum(args ...int) int { return 0 }
12
13var (
14 _ = sum(1, 2, 3)
15 _ = sum()
16 _ = sum(1.0, 2.0)
17 _ = sum(1.5) // ERROR "integer"
Ian Lance Taylor635093e2010-02-05 18:38:27 -080018 _ = sum("hello") // ERROR "convert|incompatible"
19 _ = sum([]int{1}) // ERROR "slice literal.*as type int|incompatible"
Russ Cox68796b02010-02-01 00:25:59 -080020)
21
22type T []T
23
24func funny(args ...T) int { return 0 }
25
26var (
27 _ = funny(nil)
28 _ = funny(nil, nil)
29 _ = funny([]T{}) // ok because []T{} is a T; passes []T{[]T{}}
30)
Russ Cox75dd8fd2010-09-24 11:55:30 -040031
32func bad(args ...int) {
33 print(1, 2, args...) // ERROR "[.][.][.]"
34 println(args...) // ERROR "[.][.][.]"
35 ch := make(chan int)
36 close(ch...) // ERROR "[.][.][.]"
37 _ = len(args...) // ERROR "[.][.][.]"
38 _ = closed(ch...) // ERROR "[.][.][.]"
39 _ = new(int...) // ERROR "[.][.][.]"
40 n := 10
41 _ = make([]byte, n...) // ERROR "[.][.][.]"
42 // TODO(rsc): enable after gofmt bug is fixed
43 // _ = make([]byte, 10 ...) // error "[.][.][.]"
44 var x int
45 _ = unsafe.Pointer(&x...) // ERROR "[.][.][.]"
46 _ = unsafe.Sizeof(x...) // ERROR "[.][.][.]"
47}