-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
cmd/compile: internal compiler error: assertion failed #54135
Comments
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. |
May be a dup of #53762. |
@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. |
Thanks, closing as a dup. My understanding is that #53762 has already been fixed on tip. |
@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. |
You're right, it's still crashing. Sorry about that. |
Change https://go.dev/cl/420394 mentions this issue: |
Tested the fix above, and it still is failing to build some generics code. I will follow up with a repro shortly. |
The repro below still fails to build with the fix above. import (
"fmt"
"testing"
)
type Foo[T comparable] interface {
FooFoo(tt []T)
}
type Bar interface {
BarSize() int
}
func Test[T comparable](tt []T, foos []Foo[T]) {
if len(foos) == 0 {
return
}
p := FooBar[T]{fooCnt: len(foos)}
p.getT(foos[0])
}
type FooBar[T comparable] struct {
fooCnt int
}
func (p *FooBar[T]) getT(foo Foo[T]) {
barSize(foo)
}
func barSize[T comparable](p Foo[T]) {
s := 1
if b, ok := p.(Bar); ok {
s = b.BarSize()
}
fmt.Println(s)
}
func TestTest(t *testing.T) {
tt := []int{1, 2, 3}
foos := []Foo[int]{}
Test(tt, foos)
} On Go 1.18, this passes as expected. On Go 1.19, both on tip and tip with the patch in https://go-review.googlesource.com/c/go/+/420394/ |
Change https://go.dev/cl/420421 mentions this issue: |
The test added in CL 420394 only tested that the type assertions compiled at all. This CL changes it into a run test to make sure the type assertions compile and also run correctly. Updates #54135. Change-Id: Id17469faad1bb55ff79b0bb4163ef50179330033 Reviewed-on: https://go-review.googlesource.com/c/go/+/420421 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com>
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. |
Change https://go.dev/cl/420675 mentions this issue: |
Change https://go.dev/cl/420674 mentions this issue: |
…r type assertions Updates #54135. Change-Id: I2b27af8124014b2699ea44bdc765e1fb8f6c8028 Reviewed-on: https://go-review.googlesource.com/c/go/+/420394 Reviewed-by: Keith Randall <khr@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org> Reviewed-by: Ian Lance Taylor <iant@google.com> (cherry picked from commit 27038b7) Reviewed-on: https://go-review.googlesource.com/c/go/+/420674 Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
The test added in CL 420674 only tested that the type assertions compiled at all. This CL changes it into a run test to make sure the type assertions compile and also run correctly. Updates #54135. Change-Id: Id17469faad1bb55ff79b0bb4163ef50179330033 Reviewed-on: https://go-review.googlesource.com/c/go/+/420421 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com> (cherry picked from commit f2a9f3e) Reviewed-on: https://go-review.googlesource.com/c/go/+/420675 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Fixes golang#54135 Change-Id: I2b27af8124014b2699ea44bdc765e1fb8f6c8028 Reviewed-on: https://go-review.googlesource.com/c/go/+/420394 Reviewed-by: Keith Randall <khr@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
The test added in CL 420394 only tested that the type assertions compiled at all. This CL changes it into a run test to make sure the type assertions compile and also run correctly. Updates golang#54135. Change-Id: Id17469faad1bb55ff79b0bb4163ef50179330033 Reviewed-on: https://go-review.googlesource.com/c/go/+/420421 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com>
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
OutputWhat did you do?
Try compiling this test program
What did you expect to see?
Test passed.
What did you see instead?
./main_test.go:19:7: internal compiler error: assertion failed
The text was updated successfully, but these errors were encountered: