golang / go

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

cmd/compile: internal compiler error: missing import reader with generics #47922

Closed andig closed 3 years ago

andig commented 3 years ago

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

$ go version
go version devel go1.18-3081f817da Mon Aug 23 19:27:46 2021 +0000 darwin/arm64

Does this issue reproduce with the latest release?

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

go env Output
$ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/andig/Library/Caches/go-build"
GOENV="/Users/andig/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/andig/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/andig/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/andig/sdk/gotip"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/andig/sdk/gotip/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="devel go1.18-3081f817da Mon Aug 23 19:27:46 2021 +0000"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/andig/htdocs/evcc/go.mod"
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 arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/sv/rs_453y57xj86xsbz3kw1mbc0000gn/T/go-build1862128429=/tmp/go-build -gno-record-gcc-switches -fno-common"
GOROOT/bin/go version: go version devel go1.18-3081f817da Mon Aug 23 19:27:46 2021 +0000 darwin/arm64
GOROOT/bin/go tool compile -V: compile version devel go1.18-3081f817da Mon Aug 23 19:27:46 2021 +0000
uname -v: Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:27 PDT 2021; root:xnu-7195.141.2~5/RELEASE_ARM64_T8101
ProductName:    macOS
ProductVersion: 11.5.2
BuildVersion:   20G95
lldb --version: lldb-1205.0.28.2
Apple Swift version 5.4.2 (swiftlang-1205.0.28.2 clang-1205.0.19.57)

What did you do?

Run generics program at https://github.com/evcc-io/evcc/pull/1422/commits/54c6971b2a86fdb9fc7642df25f22a92798249c0

What did you expect to see?

No error

What did you see instead?

Error in unrelated file that does not make use of the generic util.Registry:

❯ gotip run -gcflags=all=-G=3 main.go
# github.com/evcc-io/evcc/charger
charger/warp_decorators.go:68:9: internal compiler error: missing import reader for "github.com/evcc-io/evcc/util".Registry["github.com/evcc-io/evcc/util".T₂].Add

goroutine 1 [running]:
runtime/debug.Stack()
    /Users/andig/sdk/gotip/src/runtime/debug/stack.go:24 +0x68
cmd/compile/internal/base.FatalfAt({0x15ae320, 0x1}, {0x101419ec5, 0x1c}, {0x1400124f448, 0x1, 0x1})
    /Users/andig/sdk/gotip/src/cmd/compile/internal/base/print.go:227 +0x16c
cmd/compile/internal/base.Fatalf(...)
    /Users/andig/sdk/gotip/src/cmd/compile/internal/base/print.go:196
cmd/compile/internal/typecheck.ImportBody(0x14000e56840)
    /Users/andig/sdk/gotip/src/cmd/compile/internal/typecheck/iimport.go:74 +0x1a8
cmd/compile/internal/noder.checkFetchBody(0x14000e69ee0)
    /Users/andig/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:560 +0xac
cmd/compile/internal/noder.(*irgen).getInstantiation(0x1400122d680, 0x14000e69ee0, {0x1400075b4f0, 0x1, 0x1}, 0x4)
    /Users/andig/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:571 +0x44
cmd/compile/internal/noder.(*irgen).instantiateMethods(0x1400122d680)
    /Users/andig/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:511 +0x25c
cmd/compile/internal/noder.(*irgen).stencil(0x1400122d680)
    /Users/andig/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:50 +0x90
cmd/compile/internal/noder.(*irgen).generate(0x1400122d680, {0x140003c6000, 0x1d, 0x100c8f348})
    /Users/andig/sdk/gotip/src/cmd/compile/internal/noder/irgen.go:265 +0x25c
cmd/compile/internal/noder.check2({0x140003c6000, 0x1d, 0x1d})
    /Users/andig/sdk/gotip/src/cmd/compile/internal/noder/irgen.go:92 +0x130
cmd/compile/internal/noder.LoadPackage({0x140000b4100, 0x1d, 0x0})
    /Users/andig/sdk/gotip/src/cmd/compile/internal/noder/noder.go:90 +0x334
cmd/compile/internal/gc.Main(0x10161e690)
    /Users/andig/sdk/gotip/src/cmd/compile/internal/gc/main.go:190 +0xbbc
main.main()
    /Users/andig/sdk/gotip/src/cmd/compile/main.go:55 +0xf8
mdempsky commented 3 years ago

Sounds like another issue with typecheck/crawler.go and stenciling. /cc @danscales

gopherbot commented 3 years ago

Change https://golang.org/cl/344613 mentions this issue: cmd/compile: fix naming of types inside instantiations