https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100388
Bug ID: 100388 Summary: import seems to define identifiers in package block not file block Product: gcc Version: 10.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: go Assignee: ian at airs dot com Reporter: ben.hutchings at essensium dot com CC: cmang at google dot com Target Milestone: --- Given a package made of these two files: $ cat a.go package main import ( copy "golang.org/x/sys/unix" ) func Getuid() int { return copy.Getuid() } $ cat b.go package main func main() { foo := make([]string, 1) bar := make([]string, 1) copy(bar, foo) } gccgo seems to treat the imported "copy" as defined at package scope, shadowing the global "copy": $ go build . # _/home/bwh/tmp/gotest ./b.go:6:2: error: ‘copy’ defined as both imported name and global name 6 | copy(bar, foo) | ^ ./a.go:4:2: note: ‘copy’ imported here 4 | copy "golang.org/x/sys/unix" | ^ I'm seeing this with the Debian package of gccgo, version 10.2.1-6. gc (again from a Debian package, version 1.15.9-1) does not report an error. The Go Programming Language spec says that import declares names in the "file block" which seems to mean it should not affect any other source file. But I am a Go novice, so I might be misinterpreting this.