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: unified IR needs to treat conversion of constants to type parameter type as non-constant #54307

mdempsky opened this issue Aug 5, 2022 · 1 comment
compiler/runtime NeedsFix


Copy link

@mdempsky mdempsky commented Aug 5, 2022

This code compiles with Go 1.19, but currently fails with GOEXPERIMENT=unified because -1 is not representable by type uint.

package p

func f[Int int, Uint uint]() {
	_ = uint(Int(-1))
	_ = uint(Uint(0) - 1)

var _ = f[int, uint]

Per the Go spec, "If the type is a type parameter, the constant is converted into a non-constant value of the type parameter."

(Noticed at, while investigating #54302.)

@mdempsky mdempsky added the NeedsFix label Aug 5, 2022
@mdempsky mdempsky added this to the Go1.20 milestone Aug 5, 2022
@mdempsky mdempsky self-assigned this Aug 5, 2022
@gopherbot gopherbot added the compiler/runtime label Aug 5, 2022
Copy link

@gopherbot gopherbot commented Aug 6, 2022

Change mentions this issue: cmd/compile: treat constants to type parameter conversion as non-constant in Unified IR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
compiler/runtime NeedsFix
None yet

No branches or pull requests

2 participants