-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/compile: internal compiler error: assertion failed with type aliases #73309
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
Comments
at some point I also managed to trigger a panic, but I cannot reproduce it anymore. it may have been in an older go version. I did conserve the output:
|
CC @golang/compiler. |
Thanks for finding the issue! I think the problem might be related to recursive type parameters:
However, changing the definition of
The compiler will error out with this message:
I guess the reason of this panic might be that the type recursion checker does not have a case for function types yet. |
Seems to be duplicated of #63285 |
Change https://go.dev/cl/668175 mentions this issue: |
@JunyangShao Your above program is valid, if you replaced the generic version with non-generic one:
You can see the program is compiled successfully. The problem here is the same with #66873, I sent https://go.dev/cl/668175 to fix it. |
CL 585399 fixed an initialization loop during IR contruction that involving alias type, by avoiding publishing alias declarations until the RHS type expression has been constructed. There's an assertion to ensure that the alias's type must be the same during the initialization. However, that assertion is too strict, since we may construct different instances of the same type, if the type is an instantination of generic type. To fix this, we could use types.IdenticalStrict to ensure that these types matching exactly. Updates #66873. Updates #73309. Change-Id: I2559bed37e21615854333fb1057d7349406e6a1b Reviewed-on: https://go-review.googlesource.com/c/go/+/668175 Reviewed-by: David Chase <[email protected]> Reviewed-by: Keith Randall <[email protected]> Auto-Submit: Cuong Manh Le <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Keith Randall <[email protected]>
Go version
go version go1.24.2 linux/amd64
Output of
go env
in your module/workspace:What did you do?
playground link
What did you see happen?
running or trying to build this code causes the following error:
if importing the code as a package, we see the following error from
gopls
(package name redacted):removing the type aliases makes the code runnable.
playground link with type aliases removed
What did you expect to see?
a passing test.
valid
printed in the console.The text was updated successfully, but these errors were encountered: