nsf / gocode

An autocompletion daemon for the Go programming language
MIT License
5.01k stars 657 forks source link

Incorrect parsing of parametric function Result #469

Closed guns closed 7 years ago

guns commented 7 years ago

According to https://golang.org/ref/spec#Function_types, a function can declare its return types as a list of parameters. The following function, therefore, is valid:

func f() (a, b io.Reader, c error) {
    return
}

Gocode, however, incorrectly determines that the second return type from f is error, not io.Reader, as demonstrated by the following:

package main

func f() (a, b io.Reader, c error) { return }

func main() {
    a, b, c := f()
    b.
}

With the above saved as issue.go:

$ gocode -in ./issue.go autocomplete 94
Found 1 candidates:
  func Error() string

Thank you for gocode!

nsf commented 7 years ago

Thanks for reporting it.