Repository navigation
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.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Milestone
Description
What version of Go are you using (go version)?
master
$ go version
go version devel go1.19-5c8ec89cb5 Thu Jul 28 21:13:04 2022 +0000 linux/amd64
Does this issue reproduce with the latest release?
Fails on both go1.19rc2 and master. Passes on go1.18.
What operating system and processor architecture are you using (go env)?
go env Output
$ go env GO111MODULE="off" GOARCH="amd64" GOBIN="" GOCACHE="/home/user/.cache/go-build" GOENV="/home/user/.config/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/home/user/go-code2/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/user/go-code2" GOPRIVATE="" GOPROXY="https://proxy.golang.org/,direct" GOROOT="/home/user/go/src/github.com/golang/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/home/user/go/src/github.com/golang/go/pkg/tool/linux_amd64" GOVCS="" GOVERSION="devel go1.19-5c8ec89cb5 Thu Jul 28 21:13:04 2022 +0000" GCCGO="gccgo" GOAMD64="v1" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="" 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-build3108614045=/tmp/go-build -gno-record-gcc-switches"
What did you do?
Try compiling this test program
package main
import (
"fmt"
"testing"
)
type Bar[T any] interface{
Blanker()
}
type FooBar[T any] interface{}
type Foo[E comparable] struct {
me E
}
func (b *Foo[E]) do(h Bar[E], f FooBar[E]) {
check(h, f)
}
func check[T comparable](p Bar[T], q FooBar[T]) int {
if _, ok := p.(Checkable); ok {
fmt.Println(ok)
}
if _, ok := q.(Checkable); ok {
fmt.Println(ok)
}
return 1
}
type Checkable interface{}
func TestFunction(m *testing.T) {
x := Foo[int]{me: 2}
fmt.Println(x)
}What did you expect to see?
Test passed.
What did you see instead?
./main_test.go:19:7: internal compiler error: assertion failed
Reacted by Sung Yoon Whang, Esteban Raymundo Olmedo Ramírez , jasonmills, Abhinav Gupta, r-hang, Moises Vega, Mark Jung and josephinedotlee
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.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Activity
[-]affected/package: cmd/compile go1.19 Fails to build generic program[/-][+]cmd/compile go1.19 Fails to build generic program[/+]sywhang commentedon Jul 29, 2022
To add a bit of context, we found this issue while testing Go 1.19 on our Go Monorepo at Uber. We noticed both master and 1.19 rc2 is breaking with some of the latest changes in our codebase that made use of generics.
The program above is a small repro we were able to isolate out of the actual code that broke.
ianlancetaylor commentedon Jul 29, 2022
May be a dup of #53762.
sywhang commentedon Jul 29, 2022
@ianlancetaylor thanks, i can confirm the failure is coming from the same place as #53762.
The repro program we posted above should help debugging the root cause.
ianlancetaylor commentedon Jul 29, 2022
Thanks, closing as a dup. My understanding is that #53762 has already been fixed on tip.
sywhang commentedon Jul 29, 2022
@ianlancetaylor Sorry, but I don't think it has been. The program above still fails to build on tip. The latest comments in #53762 seems like there are others facing the same issue on tip.
> Will you re-open this issue or should I create a new one?
[-]cmd/compile go1.19 Fails to build generic program[/-][+]cmd/compile: internal compiler error: assertion failed[/+]ianlancetaylor commentedon Jul 30, 2022
You're right, it's still crashing. Sorry about that.
CC @randall77 @mdempsky
gopherbot commentedon Jul 31, 2022
Change https://go.dev/cl/420394 mentions this issue:
cmd/compile: fix wrong dict pass condition for type assertionssywhang commentedon Jul 31, 2022
Tested the fix above, and it still is failing to build some generics code. I will follow up with a repro shortly.
1 remaining item
gopherbot commentedon Aug 1, 2022
Change https://go.dev/cl/420421 mentions this issue:
test: improve generic type assertion testtest: improve generic type assertion test
sywhang commentedon Aug 1, 2022
Can this fix be cherry-picked to Go 1.19 branch before the release tomorrow? Plenty of code out there will be blocked on upgrading to 1.19 until this fix is made available.
gopherbot commentedon Aug 1, 2022
Change https://go.dev/cl/420675 mentions this issue:
[release-branch.go1.19] test: improve generic type assertion testgopherbot commentedon Aug 1, 2022
Change https://go.dev/cl/420674 mentions this issue:
[release-branch.go1.19] cmd/compile: fix wrong dict pass condition for type assertions[release-branch.go1.19] cmd/compile: fix wrong dict pass condition fo…
[release-branch.go1.19] test: improve generic type assertion test
cmd/compile: fix wrong dict pass condition for type assertions
test: improve generic type assertion test
cmd/compile: fix wrong dict pass condition for type assertions