golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.99k stars 17.67k forks source link

gc: function redeclaration error could be improved #4012

Closed davecheney closed 9 years ago

davecheney commented 12 years ago
What steps will reproduce the problem?

Reported by f2f and alexluya on #go-nuts

package p

import (
        "testing"
        . "launchpad.net/gocheck"
        . "code.google.com/p/gomock/gomock"
)

func Test(t *testing.T) { TestingT(t) }

What is the expected output? What do you see instead?

expected: Tests run 

actual: 
% go build issue.go
# command-line-arguments
./issue.go:6: Not redeclared during import
        previous declaration during import
./issue.go:6: imported and not used: "code.google.com/p/gomock/gomock"

As it happens both gomock and gocheck define a function called Not, and as they are both
imported locally, they conflicted. The name of the function didn't help, but that is not
its fault.

The suggestion was to either quote the name of the function "Not", or if
possible give its full import path in the error message. The former sounds easier given
the offending line number is also available.

Please use labels and text to provide additional information.
gopherbot commented 12 years ago

Comment 1 by Alexander.Luya:

./issue.go:6: Not redeclared during import
should be changed to "function: Not() redeclared during import",it will be more obvious.
gopherbot commented 12 years ago

Comment 2 by Alexander.Luya:

"Not redeclared during import"
should be changed to "function: Not() redeclared during import",it will be more obvious.
remyoudompheng commented 12 years ago

Comment 3:

Not could be the name of a variable.
I suggest:
error during import of "code.google.com/p/gomock/gomock": Not is already declared
robpike commented 12 years ago

Comment 4:

Labels changed: added priority-later, removed priority-triage.

Status changed to Accepted.

DanielMorsing commented 12 years ago

Comment 5:

I have a fix at http://golang.org/cl/6490082/
It only specifies which package import caused the error, but I think that is enough
context to make the error non-ambiguous.
rsc commented 12 years ago

Comment 6:

Labels changed: added go1.1.

DanielMorsing commented 12 years ago

Comment 7:

This issue was closed by revision d06dcd45959f83c3b82c10116acc9a64beff14c.

Status changed to Fixed.