Home | History | Annotate | Download | only in fixedbugs
      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"
     31 
     32 	var i I
     33 	var t *T
     34 
     35 	g()()    // ERROR "not enough arguments in call to g\(\)"
     36 	f()      // ERROR "not enough arguments in call to f"
     37 	i.M()    // ERROR "not enough arguments in call to i\.M"
     38 	I.M()    // ERROR "not enough arguments in call to method expression I\.M"
     39 	t.M()    // ERROR "not enough arguments in call to t\.M"
     40 	T.M()    // ERROR "not enough arguments in call to method expression T\.M"
     41 	(*T).M() // ERROR "not enough arguments in call to method expression \(\*T\)\.M"
     42 }
     43