-
Notifications
You must be signed in to change notification settings - Fork 398
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
bug(gnovm): prohibit conversion of non-convertible typed constants #2681
Milestone
Comments
I am starting work on this. I talked to @ltzmaxwell and he said i should take it. |
petar-dambovaliev
added a commit
that referenced
this issue
Nov 22, 2024
During preprocessing, validates if typed constants are convertible. Fixes [issue](#2681) Typed constants are convertible only in a lossless way. That means that we can convert floats to integers if the fractional part of the float is 0.
omarsy
pushed a commit
to omarsy/gno
that referenced
this issue
Nov 23, 2024
During preprocessing, validates if typed constants are convertible. Fixes [issue](gnolang#2681) Typed constants are convertible only in a lossless way. That means that we can convert floats to integers if the fractional part of the float is 0.
omarsy
added a commit
to omarsy/gno
that referenced
this issue
Nov 23, 2024
During preprocessing, validates if typed constants are convertible. Fixes [issue](gnolang#2681) Typed constants are convertible only in a lossless way. That means that we can convert floats to integers if the fractional part of the float is 0.
r3v4s
pushed a commit
to gnoswap-labs/gno
that referenced
this issue
Dec 10, 2024
During preprocessing, validates if typed constants are convertible. Fixes [issue](gnolang#2681) Typed constants are convertible only in a lossless way. That means that we can convert floats to integers if the fractional part of the float is 0.
albttx
pushed a commit
that referenced
this issue
Jan 10, 2025
During preprocessing, validates if typed constants are convertible. Fixes [issue](#2681) Typed constants are convertible only in a lossless way. That means that we can convert floats to integers if the fractional part of the float is 0.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
High Level Summary
The Go spec says that constant float values should not be convertible to integer values. Gno guards against conversion of untyped float constants, but not typed constants. For example, both of these examples work in Gno when they should not:
Details
From the Go spec:
To interpret the above, it is necessary to know if a typed constant float value x is representable as an integer. Looking at the definition of constant representability:
In the case of this particular issue, typed float constant values are not representable as integers because they fail to to satisfy and of the criteria -- most notably that a non-natural number is not contained in the set of possible integer values.
Other Examples
All of these are examples that work in Gno but should not.
Integer Underflow
Integer Overflow
The text was updated successfully, but these errors were encountered: