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

Closed
mdempsky opened this issue Aug 5, 2022 · 1 comment
Assignees
Labels
compiler/runtime NeedsFix
Milestone

Comments

@mdempsky
Copy link
Member

@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 https://github.com/lightstep/otel-launcher-go/blob/448fc6822e81fdde2763f224bd9c7f3bbf72309c/lightstep/sdk/metric/aggregator/histogram/structure/exponential.go#L640, 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
@gopherbot
Copy link

@gopherbot gopherbot commented Aug 6, 2022

Change https://go.dev/cl/421874 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
Labels
compiler/runtime NeedsFix
Projects
None yet
Development

No branches or pull requests

2 participants