Source file test/fixedbugs/issue8385.go

     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 8385: provide a more descriptive error when a method expression
     8  // is called without a receiver.
     9  
    10  package main
    11  
    12  type Fooer interface {
    13  	Foo(i, j int)
    14  }
    15  
    16  func f(x int) {
    17  }
    18  
    19  type I interface {
    20  	M(int)
    21  }
    22  type T struct{}
    23  
    24  func (t T) M(x int) {
    25  }
    26  
    27  func g() func(int)
    28  
    29  func main() {
    30  	Fooer.Foo(5, 6) // ERROR "not enough arguments in call to method expression Fooer.Foo|incompatible type|not enough arguments"
    31  
    32  	var i I
    33  	var t *T
    34  
    35  	g()()    // ERROR "not enough arguments in call to g\(\)|not enough arguments"
    36  	f()      // ERROR "not enough arguments in call to f|not enough arguments"
    37  	i.M()    // ERROR "not enough arguments in call to i\.M|not enough arguments"
    38  	I.M()    // ERROR "not enough arguments in call to method expression I\.M|not enough arguments"
    39  	t.M()    // ERROR "not enough arguments in call to t\.M|not enough arguments"
    40  	T.M()    // ERROR "not enough arguments in call to method expression T\.M|not enough arguments"
    41  	(*T).M() // ERROR "not enough arguments in call to method expression \(\*T\)\.M|not enough arguments"
    42  }
    43  

View as plain text