golang / go

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

cmd/go2go: calling a generic function with the same type argument(s) in two different files generates duplicate code #39749

Closed firelizzard18 closed 4 years ago

firelizzard18 commented 4 years ago

What version of Go are you using (go version)?

$ go version
go version devel +0a030888da Sat Jun 20 04:46:40 2020 +0000 linux/amd64

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"

What did you do?

I ran go tool go2go build on https://gitlab.com/firelizzard/go-iter/-/tree/master/issues/i1

What did you expect to see?

A successful build

What did you see instead?

a.go2:9: instantiate୦୦A୦int redeclared in this block
        previous declaration at a.go2:9

Both b.go and c.go define func instantiate୦୦A୦int(m [](int), i int) { ... }

DylanMeeus commented 4 years ago

Just ran into this myself, it does indeed break the build.

gopherbot commented 4 years ago

Change https://golang.org/cl/239337 mentions this issue: [dev.go2go] go/go2go: avoid multiple identical instantiations

ianlancetaylor commented 4 years ago

Thanks for the test case. This is now fixed on the dev.go2go branch.

DylanMeeus commented 4 years ago

@ianlancetaylor that was fast, thanks!