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

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

Closed
firelizzard18 opened this issue Jun 22, 2020 · 4 comments

Comments

@firelizzard18
Copy link

@firelizzard18 firelizzard18 commented Jun 22, 2020

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) { ... }

@cagedmantis cagedmantis changed the title cmd/go2go: Calling a generic function with the same type argument(s) in two different files generates duplicate code cmd/go2go: calling a generic function with the same type argument(s) in two different files generates duplicate code Jun 22, 2020
@DylanMeeus
Copy link

@DylanMeeus DylanMeeus commented Jun 22, 2020

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

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 22, 2020

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

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jun 22, 2020

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

gopherbot pushed a commit that referenced this issue Jun 22, 2020
Move tracking of instantiations from translator to Importer,
so that we can track all instantiations within a package
to avoid duplicates.

Fixes #39749

Change-Id: If6cd5bcdc6e19c2d6481e62a6187ddf7f4fac72a
Reviewed-on: https://go-review.googlesource.com/c/go/+/239337
Reviewed-by: Ian Lance Taylor <iant@golang.org>
@DylanMeeus
Copy link

@DylanMeeus DylanMeeus commented Jun 22, 2020

@ianlancetaylor that was fast, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.