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: "internal compiler error: missing pkg" on error type argument #55101

Closed
itsabgr opened this issue Sep 16, 2022 · 4 comments
Closed
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@itsabgr
Copy link

itsabgr commented Sep 16, 2022

What version of Go are you using (go version)? 1.18, 1.19 linux/amd64

$ go version
go version go1.19 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
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/abgr/.cache/go-build"
GOENV="/home/abgr/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/abgr/go/pkg/mod"
GONOPROXY="github.com/itsabgr/*"
GONOSUMDB="github.com/itsabgr/*"
GOOS="linux"
GOPATH="/home/abgr/go"
GOPRIVATE="github.com/itsabgr/*"
GOPROXY="https://goproxy.io,direct,https://proxy.golang.org"
GOROOT="/snap/go/9951"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/snap/go/9951/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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 -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build4057876477=/tmp/go-build -gno-record-gcc-switches"

What did you do?

build a pkg

What did you expect to see?

do build

What did you see instead?

<autogenerated>:1: internal compiler error: missing pkg

@itsabgr
Copy link
Author

itsabgr commented Sep 16, 2022

src

package validator

import (
	"github.com/dboslee/lru" //v0.0.1
)

type Validator struct {
	cache *lru.Cache[string, error]
}

func New(cache *lru.Cache[string, error]) *Validator {
	return &Validator{
		cache: cache,
	}
}

@mengzhuo
Copy link
Contributor

Do you mean error is a predeclared type but not denoted correctly as compareble do?

Here is a work around example:

type Validator struct {
	cache *lru.Cache[string, interface{error}]
}
func New(cache *lru.Cache[string, interface{error}]) *Validator {
	return &Validator{
		cache: cache,
	}
}

x_test.go

cache := lru.New[string, interface{ error }]()
v := New(cache)
v.cache.Set("e1", errors.New("e1"))

cc @golang/compiler

@mengzhuo mengzhuo added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 16, 2022
@mengzhuo mengzhuo changed the title affected/package: cmd/compile, types2: "internal compiler error: missing pkg" on errro type constraints Sep 16, 2022
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Sep 16, 2022
@mdempsky
Copy link
Member

mdempsky commented Sep 16, 2022

This appears to work correctly at tip, so it should be fixed in Go 1.20: https://go.dev/play/p/zVTyPV3Q3ay?v=gotip

It looks like it fails in both 1.18 and 1.19, so it's not a regression though. So I don't think we're going to backport a fix for those releases, sorry.

Leaving issue open to add a regress test.

@mdempsky mdempsky self-assigned this Sep 16, 2022
@mdempsky mdempsky added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Sep 16, 2022
@mdempsky mdempsky added this to the Go1.20 milestone Sep 16, 2022
@mdempsky mdempsky changed the title cmd/compile, types2: "internal compiler error: missing pkg" on errro type constraints cmd/compile: "internal compiler error: missing pkg" on error type argument Sep 16, 2022
@gopherbot
Copy link

Change https://go.dev/cl/431455 mentions this issue: test: add regress test for issue 55101

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants