-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Detect duplicate const literals in match #4712
Comments
This now gives an error |
It should not (because it's an approximate zero and thus not an integer exact zero). |
@dumblob if the value that is matched (here |
Generally yes, but only for compatible types. In V it must not be possible to do: mut x := 1.5
x = 0.0
assert x == 0 The correct way would be: mut x := 1.5
x = 0.0
assert int( x ) == 0 |
Therefore we have rules for automatic type promotions. You can look them up in the docs |
Type promotions are in flux for quite some time already (#7801 (comment) , #8601 , #7692 , #6251 ) and they converge to guarantee no information loss which in this case is not possible (it's possible to silently promote int to f64, but not any float to int). |
Fixed. |
Expected behavior:
The text was updated successfully, but these errors were encountered: