You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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"
| ^
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 predeclaredcopy
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./cc @ianlancetaylor
The text was updated successfully, but these errors were encountered: