-
Notifications
You must be signed in to change notification settings - Fork 17.3k
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
import . does not cause redeclaration errors #455
Labels
Comments
As you can see from this expanded version of file b.go, as expected, the most local variable X (main.X) hides the imported variable X (a.X). package main import . "./a" import a "./a" import "fmt" var X = 1 func main() { fmt.Println("X (main.X) = ", X, ", ", "a.X =", a.X) } which gives: X (main.X) = 1 , a.X = 0 The explicit period form of the package name imports all the package's exported identifiers, whether they are used or not. Therefore, there is no error for the unused imported identifiers. |
There should not be any "hiding". The spec says variable X from b.go is declared in the package scope. The spec implies that variable X from import . "./a" should be declared in file scope (the spec does not say this explicitly, but it does say that imported package identifiers are declared at file scope). Finally, the spec says "no identifier may be declared in both the file and package block". I understand that the reference implementation does not behave as I describe. A plausible resolution to this bug would be to change the spec. |
This is a real bug: the X should be a conflict, and then if you delete the declaration of X you should get an imported and not used error. Owner changed to r...@golang.org. Status changed to Accepted. |
This issue was closed by revision 5a5799f. Status changed to Fixed. Merged into issue #-. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: