Skip to content

compiler: internal compiler error: assertion failed when using concrete nested type in interface constraint #50520

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

Closed
pmalek opened this issue Jan 9, 2022 · 2 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

@pmalek
Copy link

pmalek commented Jan 9, 2022

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

$ gotip version
go version devel go1.18-90860e0 Sat Jan 8 00:24:25 2022 +0000 darwin/amd64

Does this issue reproduce with the latest release?

Only tip as mentioned above.

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/pmalek/Library/Caches/go-build"
GOENV="/Users/pmalek/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/pmalek/.gvm/pkgsets/go1.18beta1/global/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/pmalek/.gvm/pkgsets/go1.18beta1/global"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/pmalek/sdk/gotip"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/Users/pmalek/sdk/gotip/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="devel go1.18-90860e0 Sat Jan 8 00:24:25 2022 +0000"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/pmalek/code/own/go/csv/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/78/xm1r7h7s7lqdp36w81v765500000gn/T/go-build2797857967=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Playground link

package main

type Entry struct {
	Data int
}

type EntryT interface {
	Entry
}

func main() {
	foo([]Entry{})
}

func foo[T EntryT](entries []T) {
	for _, e := range entries {
		_ = e.Data // without this line the code compiles fine
	}
}

What did you expect to see?

No error

What did you see instead?

# csv
./calculate.go:149:14: internal compiler error: assertion failed

goroutine 1 [running]:
runtime/debug.Stack()
        /Users/pmalek/sdk/gotip/src/runtime/debug/stack.go:24 +0x65
cmd/compile/internal/base.FatalfAt({0x8297a0?, 0xc0?}, {0x192059c, 0x10}, {0x0, 0x0, 0x0})
        /Users/pmalek/sdk/gotip/src/cmd/compile/internal/base/print.go:227 +0x1ca
cmd/compile/internal/base.Fatalf(...)
        /Users/pmalek/sdk/gotip/src/cmd/compile/internal/base/print.go:196
cmd/compile/internal/base.Assert(...)
        /Users/pmalek/sdk/gotip/src/cmd/compile/internal/base/print.go:239
cmd/compile/internal/noder.assert(...)
        /Users/pmalek/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:28
cmd/compile/internal/noder.transformDot(0xc000881140?, 0x0)
        /Users/pmalek/sdk/gotip/src/cmd/compile/internal/noder/transform.go:645 +0x151
cmd/compile/internal/noder.(*genInst).dictPass.func1({0x1a90f80, 0xc0008297a0})
        /Users/pmalek/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:1258 +0x815
cmd/compile/internal/ir.(*AssignStmt).editChildren(0xc00089ef00, 0xc0008bc100)
        /Users/pmalek/sdk/gotip/src/cmd/compile/internal/ir/node_gen.go:163 +0xc8
cmd/compile/internal/ir.EditChildren(...)
        /Users/pmalek/sdk/gotip/src/cmd/compile/internal/ir/visit.go:185
cmd/compile/internal/noder.(*genInst).dictPass.func1({0x1a8eeb0, 0xc00089ef00})
        /Users/pmalek/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:1218 +0x74
cmd/compile/internal/ir.editNodes(...)
        /Users/pmalek/sdk/gotip/src/cmd/compile/internal/ir/node_gen.go:1521
cmd/compile/internal/ir.(*RangeStmt).editChildren(0xc00088f3b0, 0xc0008bc100)
        /Users/pmalek/sdk/gotip/src/cmd/compile/internal/ir/node_gen.go:1000 +0x236
cmd/compile/internal/ir.EditChildren(...)
        /Users/pmalek/sdk/gotip/src/cmd/compile/internal/ir/visit.go:185
cmd/compile/internal/noder.(*genInst).dictPass.func1({0x1a90b98, 0xc00088f3b0})
        /Users/pmalek/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:1218 +0x74
cmd/compile/internal/ir.editNodes(...)
        /Users/pmalek/sdk/gotip/src/cmd/compile/internal/ir/node_gen.go:1521
cmd/compile/internal/ir.(*Func).editChildren(0xc0000e94c8?, 0xc0008bc100?)
        /Users/pmalek/sdk/gotip/src/cmd/compile/internal/ir/func.go:153 +0x74
cmd/compile/internal/ir.EditChildren(...)
        /Users/pmalek/sdk/gotip/src/cmd/compile/internal/ir/visit.go:185
cmd/compile/internal/noder.(*genInst).dictPass.func1({0x1a8fbf8, 0xc000898b00})
        /Users/pmalek/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:1218 +0x74
cmd/compile/internal/noder.(*genInst).dictPass(0x1f8daa0, 0xc000881140)
        /Users/pmalek/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:1350 +0x126
cmd/compile/internal/noder.(*genInst).buildInstantiations(0x1f8daa0, 0x1)
        /Users/pmalek/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:84 +0x26b
cmd/compile/internal/noder.BuildInstantiations(...)
        /Users/pmalek/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:47
cmd/compile/internal/noder.(*irgen).generate(0xc0003723c0, {0xc000139780, 0x7, 0x203000?})
        /Users/pmalek/sdk/gotip/src/cmd/compile/internal/noder/irgen.go:331 +0x3db
cmd/compile/internal/noder.check2({0xc000139780, 0x7, 0x7})
        /Users/pmalek/sdk/gotip/src/cmd/compile/internal/noder/irgen.go:92 +0x16d
cmd/compile/internal/noder.LoadPackage({0xc00013e100, 0x7, 0x0?})
        /Users/pmalek/sdk/gotip/src/cmd/compile/internal/noder/noder.go:90 +0x335
cmd/compile/internal/gc.Main(0x1948848)
        /Users/pmalek/sdk/gotip/src/cmd/compile/internal/gc/main.go:191 +0xb13
main.main()
        /Users/pmalek/sdk/gotip/src/cmd/compile/main.go:55 +0xdd
@ALTree
Copy link
Member

ALTree commented Jan 9, 2022

Thanks for reporting this.

cc @danscales @randall77

@ALTree ALTree added this to the Go1.18 milestone Jan 9, 2022
@ALTree ALTree added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker labels Jan 9, 2022
@danscales
Copy link
Contributor

This is a dup of #50417 (field reference to a type param that has a constraint which is a single concrete type). I'm working on the compiler side of #50417 now.

@golang golang locked and limited conversation to collaborators Jan 9, 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