Skip to content

cmd/compile: unified IR needs to treat conversion of constants to type parameter type as non-constant #54307

Closed
@mdempsky

Description

@mdempsky

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.)

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions