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

go/constant: MakeFloat64(0).Kind() returns constant.Int, not constant.Float #42641

Closed
mdempsky opened this issue Nov 16, 2020 · 1 comment
Closed

Comments

@mdempsky
Copy link
Member

The documentation for MakeFloat64 says it returns a Float value: https://golang.org/pkg/go/constant/#MakeFloat64

But MakeFloat64(0).Kind() returns constant.Int, rather than constant.Float: https://play.golang.org/p/9TLXDgpld9S

This is because it returns int64Val(0) when x == 0. It should probably return floatVal0 instead, or maybe a new ratVal0 value (so that match continues using big.Rat arithmetic instead of falling back to big.Float).

/cc @griesemer

@griesemer griesemer self-assigned this Nov 25, 2020
@gopherbot
Copy link

Change https://golang.org/cl/273126 mentions this issue: go/constant: MakeFloat64(0) must return a value of Float kind

@golang golang locked and limited conversation to collaborators Nov 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants