modernc.org/gc@v1.0.1-0.20240304020402-f0dba7c97c2b/testdata/errchk/test/fixedbugs/issue7675.go (about)

     1  // errorcheck
     2  
     3  // Copyright 2014 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  // Issue 7675: fewer errors for wrong argument count
     8  
     9  package p
    10  
    11  func f(string, int, float64, string)
    12  
    13  func g(string, int, float64, ...string)
    14  
    15  func main() {
    16  	f(1, 0.5, "hello") // ERROR "not enough arguments"
    17  	f("1", 2, 3.1, "4")
    18  	f(1, 0.5, "hello", 4, 5) // ERROR "too many arguments"
    19  	g(1, 0.5)                // ERROR "not enough arguments"
    20  	g("1", 2, 3.1)
    21  	g(1, 0.5, []int{3, 4}...) // ERROR "not enough arguments"
    22  	g("1", 2, 3.1, "4", "5")
    23  	g(1, 0.5, "hello", 4, []int{5, 6}...) // ERROR "too many arguments"
    24  }