Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: incorrect error message when mixing named/unamed with an interface arg type #17382

Closed
mitchellh opened this issue Oct 8, 2016 · 3 comments

Comments

@mitchellh
Copy link

mitchellh commented Oct 8, 2016

What version of Go are you using (go version)?

go version go1.7.1 darwin/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/mitchellh/code/go"
GORACE=""
GOROOT="/Users/mitchellh/code/3rdparty/go"
GOTOOLDIR="/Users/mitchellh/code/3rdparty/go/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/3q/c37yygcs4vl7cvzq3k3wdnyr0000gn/T/go-build207171984=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"

What did you do?

https://play.golang.org/p/4UIQBFK6tm

What did you expect to see?

I expect this error message:

tmp/sandbox307788845/main.go:15: mixed named and unnamed function parameters

Which you get if you change the A parameter to a pointer to A (notice A just changed to *A):

https://play.golang.org/p/EoGX8zfkKj

What did you see instead?

I see this error message with the key point being the type signature just looks wrong:

tmp/sandbox076937847/main.go:15: cannot use new(Impl) (type *Impl) as type I in assignment:
    *Impl does not implement I (wrong type for F method)
        have F(*B, *B)
        want F(A, *B)

It says have F(*B, *B) but if you look at the source thats not what you see and its very confusing.

@odeke-em odeke-em changed the title Incorrect compiler error message when mixing named/unamed with an interface arg type cmd/compile: incorrect error message when mixing named/unamed with an interface arg type Oct 8, 2016
@odeke-em
Copy link
Member

odeke-em commented Oct 8, 2016

/cc @griesemer @josharian

@cznic
Copy link
Contributor

cznic commented Oct 8, 2016

It says have F(*B, *B) but if you look at the source thats not what you see and its very confusing.

The error message is correct. F(A, b *B) has signature F(*B, *B) because it has two named parameters, A and b, both of type *B.

@mitchellh
Copy link
Author

Ahhhh, interesting.

I can see that now (I'm just so used to lowercase var names). That is really confusing but I can see how that's possible. I can see how this probably isn't a bug then and I'll close it.

@golang golang locked and limited conversation to collaborators Oct 8, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants