-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.
Milestone
Description
What version of Go are you using (go version
)?
$ go version go version go1.18 linux/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/vscode/.cache/go-build" GOENV="/home/vscode/.config/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GOVCS="" GOVERSION="go1.18" GCCGO="gccgo" GOAMD64="v1" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/workspace/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 -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2277327549=/tmp/go-build -gno-record-gcc-switches"
What did you do?
Load type and type info from a generic package.
github repo: https://github.com/tsh96/reproducing-go-generic-load-packages-error
main.go
package main
import (
_ "github.com/tsh96/reproducing-go-generic-load-packages-error/g"
"golang.org/x/tools/go/packages"
)
func main() {
mode := packages.NeedTypes | packages.NeedTypesInfo
packages.Load(&packages.Config{Mode: mode}, ".")
}
g/util.go
package g
type A[T any] struct{}
func NewA[T any]() *A[T] { return new(A[T]) }
func NewIntA() *A[int] { return NewA[int]() } // <-- This line is triggering the issue
go.mod
module github.com/tsh96/reproducing-go-generic-load-packages-error
go 1.18
require golang.org/x/tools v0.1.11-0.20220325212234-e693fb417253
require (
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
golang.org/x/sys v0.0.0-20220325203850-36772127a21f // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
)
What did you expect to see?
Nothing, success.
What did you see instead?
$ go run .
2022/03/26 02:31:45 golang.org/x/tools/go/packages: unexpected new packages during load of github.com/tsh96/reproducing-go-generic-load-packages-error/g
panic: golang.org/x/tools/go/packages: unexpected new packages during load of github.com/tsh96/reproducing-go-generic-load-packages-error/g
goroutine 21 [running]:
log.Panicf({0x63e7ca?, 0x3d?}, {0xc00005dbb0?, 0xc0000773b0?, 0xc0000b6200?})
/usr/local/go/src/log/log.go:392 +0x67
golang.org/x/tools/go/packages.(*loader).loadFromExportData(0xc00013c000, 0xc0000b1f60)
/workspace/vendor/golang.org/x/tools/go/packages/packages.go:1240 +0x4f7
golang.org/x/tools/go/packages.(*loader).loadPackage(0xc00013c000, 0xc0000b1f60)
/workspace/vendor/golang.org/x/tools/go/packages/packages.go:864 +0x3aa
golang.org/x/tools/go/packages.(*loader).loadRecursive.func1()
/workspace/vendor/golang.org/x/tools/go/packages/packages.go:829 +0x1a9
sync.(*Once).doSlow(0xc0001527a8?, 0x1?)
/usr/local/go/src/sync/once.go:68 +0xc2
sync.(*Once).Do(...)
/usr/local/go/src/sync/once.go:59
golang.org/x/tools/go/packages.(*loader).loadRecursive(0x43c085?, 0x0?)
/workspace/vendor/golang.org/x/tools/go/packages/packages.go:817 +0x52
golang.org/x/tools/go/packages.(*loader).loadRecursive.func1.1(0x0?)
/workspace/vendor/golang.org/x/tools/go/packages/packages.go:824 +0x2c
created by golang.org/x/tools/go/packages.(*loader).loadRecursive.func1
/workspace/vendor/golang.org/x/tools/go/packages/packages.go:823 +0x8f
exit status 2
An unexpected package package named go.shape
is added to the view
after following line of code:
https://github.com/golang/tools/blob/198cae37294c48f180c54b9f66617d821e185fdc/go/packages/packages.go#L1209
nlepage and crunk1
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.