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/compile: cannot import "package" (type parameter bound more than once) #49893

Closed
csgura opened this issue Dec 1, 2021 · 5 comments
Closed
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Milestone

Comments

@csgura
Copy link

csgura commented Dec 1, 2021

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

$ go version
go version devel go1.18-a412b5f Wed Dec 1 06:03:27 2021 +0000 darwin/amd64

Does this issue reproduce with the latest release?

yes

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

The Gotip Playground

What did you do?

https://gotipplay.golang.org/p/MFUJGGC_uWf

What did you expect to see?

Compiled without error

What did you see instead?

./prog.go:5:2: could not import tptest/option (cannot import "tptest/option" (type parameter bound more than once), possibly version skew - reinstall package)

@danscales
Copy link
Contributor

danscales commented Dec 1, 2021

I'm looking at this, since it may relate to confusion with import/export, but @findleyr , you may also want to take a look when you get a chance, since the error happens in types2. Seems like we may somehow confused distinct type parameters during export/import across multiple packages. Problem goes away if the type params in definition of Ap2 are renamed (e.g. to A2/B2).

@griesemer

@danscales danscales added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Dec 1, 2021
@danscales danscales added this to the Go1.18 milestone Dec 1, 2021
@findleyr
Copy link
Contributor

findleyr commented Dec 1, 2021

Thanks for the repro. This should be a release blocker: there is something wrong with our type-parameter scoping.

@findleyr
Copy link
Contributor

findleyr commented Dec 1, 2021

the error happens in types2

@danscales the error is coming from types2, but the bug must be in the importer. Type parameters are local to their function/type, and so must be bound only once.

@danscales danscales self-assigned this Dec 1, 2021
@findleyr findleyr changed the title cmd/compile: cannot import "pacakge" (type parameter bound more than once) cmd/compile: cannot import "package" (type parameter bound more than once) Dec 1, 2021
@danscales
Copy link
Contributor

The bug relates to the type parameter B being specified in Ap1, but not actually being used in Ap1 (applies to Ap2 as well). Because B is not used, we are somehow referencing the wrong B during definition and then export. Doesn't always cause a visible problem, but sometimes does (as in this issue).

@gopherbot
Copy link

Change https://golang.org/cl/368454 mentions this issue: cmd/compile: fix case where g.curDecl should be saved/restored

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Projects
None yet
Development

No branches or pull requests

4 participants