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

Incorrect Handling of Constant Conversion (math.MaxFloat64 to float32 ) #3496

Open
omarsy opened this issue Jan 13, 2025 · 0 comments · May be fixed by #3749
Open

Incorrect Handling of Constant Conversion (math.MaxFloat64 to float32 ) #3496

omarsy opened this issue Jan 13, 2025 · 0 comments · May be fixed by #3749
Assignees
Labels
🐞 bug Something isn't working

Comments

@omarsy
Copy link
Member

omarsy commented Jan 13, 2025

Description

The following code compiles and executes successfully, but it should fail during compilation:

package main

import "math"

func main() {
    const f = math.MaxFloat64
    println(float32(f))
}

Expected Behavior

This code should fail at compile time with the following error (consistent with Go's behavior):

cannot convert f (untyped float constant 1.79769e+308) to type float32

Actual Behavior

The code compiles successfully and returns +Inf when executed.

@omarsy omarsy added the 🐞 bug Something isn't working label Jan 13, 2025
@omarsy omarsy changed the title Incorrect Handling of Constant math.MaxFloat64 to float32 Conversion in Gno Incorrect Handling of Constant Conversion (math.MaxFloat64 to float32 ) Jan 13, 2025
@thehowl thehowl added this to the 🚀 Mainnet beta launch milestone Jan 20, 2025
@Kouteki Kouteki moved this from Triage to Todo in 🧙‍♂️gno.land core team Jan 20, 2025
@Kouteki Kouteki removed the in focus label Feb 3, 2025
@petar-dambovaliev petar-dambovaliev moved this from Todo to In Progress in 🧙‍♂️gno.land core team Feb 12, 2025
odeke-em added a commit to odeke-em/gno that referenced this issue Feb 13, 2025
…constants

With this change we check that the values converted are within the
max_float32 limit.

Fixes gnolang#3496
odeke-em added a commit to odeke-em/gno that referenced this issue Feb 13, 2025
…constants

With this change we check that the values converted are within the
max_float32 limit.

Fixes gnolang#3496
@petar-dambovaliev petar-dambovaliev moved this from In Progress to In Review in 🧙‍♂️gno.land core team Feb 13, 2025
@petar-dambovaliev petar-dambovaliev linked a pull request Feb 13, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
Status: In Review
4 participants