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 Issues related to the Go compiler and/or runtime. FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@mdempsky
Copy link
Member

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 The path to resolution is known, but the work has not been done. 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 Issues related to the Go compiler and/or runtime. label Aug 5, 2022
@gopherbot
Copy link

Change https://go.dev/cl/421874 mentions this issue: cmd/compile: treat constants to type parameter conversion as non-constant in Unified IR

jproberts pushed a commit to jproberts/go that referenced this issue Aug 10, 2022
…tant in Unified IR

Fixes golang#54307

Change-Id: Idcbdb3b1cf7c7fd147cc079659f29a9b5d17e6e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/421874
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
@golang golang locked and limited conversation to collaborators Aug 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

2 participants