Skip to content

cmd/compile/internal/types2: "real(0)" and "imag(0)" have type "untyped float", but value of kind constant.Int #43891

Closed
@mdempsky

Description

@mdempsky

On dev.typeparams, go tool compile -G=3 $(go env GOROOT)/test/fixedbugs/issue11945.go currently fails because the real(0) and imag(0) expressions have type "untyped float", but then their go/constant representation has kind constant.Int, whereas irgen expects it to be constant.Float.

My intuition is that the TypeAndValue.Value's constant.Kind should always match the TypeAndValue.Type's Underlying's BasicInfo's Is{Boolean,Integer,Float,Complex,String}.

However, if that expectation is incorrect/unreasonable, I think this would be reasonable to handle in irgen instead of types2. (With the recent types2 cleanup, untyped numeric values are only seen in constant declarations. We also already have the constant's type before we set the value, so it wouldn't be hard to coerce to the expected constant.Kind.)

/cc @griesemer @findleyr @danscales

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions