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: could not import "package" (cannot import "package" (type parameter bound more than once), possibly version skew - reinstall package) #51836

Closed
elagergren-spideroak opened this issue Mar 21, 2022 · 8 comments
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

@elagergren-spideroak
Copy link

elagergren-spideroak commented Mar 21, 2022

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

$ go version
go version go1.18 darwin/amd64

Does this issue reproduce with the latest release?

This is the latest release.

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN="/Users/elagergren/gopath/bin"
GOCACHE="/Users/elagergren/Library/Caches/go-build"
GOENV="/Users/elagergren/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/elagergren/gopath/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/elagergren/gopath"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.18"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/elagergren/git/some/path/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/2b/74fz3jhd4wz4vnbf4z7ywzww0000gp/T/go-build2780518648=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

https://go.dev/play/p/oIoBIbuJ4n8

What did you expect to see?

It compile correctly.

What did you see instead?

Compiler error.

@elagergren-spideroak
Copy link
Author

Related to #49893

@elagergren-spideroak
Copy link
Author

elagergren-spideroak commented Mar 21, 2022

Note that the problem the duplicate package name, a. Changing a/a to a/b fixes the problem: https://go.dev/play/p/OWv924ynWsv

Same for other variations (a/internal/a, etc.).

@ianlancetaylor
Copy link
Member

CC @griesemer @findleyr

@ianlancetaylor ianlancetaylor added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker labels Mar 21, 2022
@ianlancetaylor ianlancetaylor added this to the Go1.19 milestone Mar 21, 2022
@ianlancetaylor
Copy link
Member

@gopherbot Please open backport to 1.18

This seems to be a compiler error on valid code.

@gopherbot
Copy link
Contributor

Backport issue(s) opened: #51847 (for 1.18).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.

@findleyr
Copy link
Member

I can take a look at this.

Presumably the problem is that the key in this index is incorrect, and doesn't differentiate the two packages:
https://cs.opensource.google/go/go/+/master:src/cmd/compile/internal/importer/iimport.go;l=219;drc=d35ed094864617d82c5701f56811ad68b37eda6e

@findleyr findleyr self-assigned this Mar 21, 2022
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/394219 mentions this issue: cmd/compile/internal/importer: key tparams on pkg path rather than name

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/394854 mentions this issue: [release-branch.go1.18] cmd/compile/internal/importer: key tparams by Package instead of pkgname

gopherbot pushed a commit that referenced this issue Apr 4, 2022
… Package instead of pkgname

The importer type param index used package name as type parameter key,
causing type parameters to be reused/overwritten if two packages in the
import graph had the same combination of (package name, declaration
name, type parameter name).

Fix this by instead using the *Package in the key.

Note: -G=3 was added to typeparam/issue51836.go, as it is necessary for
1.18 but not for tip.

For #51836
Fixes #51847

Change-Id: I881ceaf3cf7c1ab4e0835962350feb552e79b233
Reviewed-on: https://go-review.googlesource.com/c/go/+/394219
Trust: Robert Findley <[email protected]>
Run-TryBot: Robert Findley <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Robert Griesemer <[email protected]>
(cherry picked from commit fd1b590)
Reviewed-on: https://go-review.googlesource.com/c/go/+/394854
@golang golang locked and limited conversation to collaborators Jun 22, 2023
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