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

gccgo: incorrectly rejects import declaration that shadows predeclared identifier #43395

Open
mdempsky opened this issue Dec 27, 2020 · 0 comments
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@mdempsky
Copy link
Member

mdempsky commented Dec 27, 2020

gccgo incorrectly rejects the package below. cmd/compile and go/types correctly accept it.

The Go spec says the imported package name copy is declared in a.go's file block, whereas the predeclared copy function used in b.go is declared in the universe block. It's only an error to declare the same identifier in file and package block, not file and universe block.

-- a.go --
package p

import new "bytes"

var _ new.Buffer

-- b.go --
package p

var _ = new(int)
# command-line-arguments
./b.go:3:9: error: ‘new’ defined as both imported name and global name
    3 | var _ = new(int)
      |         ^
./a.go:3:8: note: ‘new’ imported here
    3 | import new "bytes"
      |        ^

/cc @ianlancetaylor

@mdempsky mdempsky added the NeedsFix The path to resolution is known, but the work has not been done. label Dec 27, 2020
@mdempsky mdempsky added this to the Gccgo milestone Dec 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

1 participant