-
Notifications
You must be signed in to change notification settings - Fork 13k
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
inferred literals and integer-const expressions aren't overflow checked #4220
Comments
cc @lkuper |
My suggestion for how to deal with this: Leave type check as it is. Instead, insert a lint check that examines all literals (or perhaps constant expressions) and checks whether they fit into the type that was inferred for them. |
(Mostly a dupe of #3084.) |
I have written this patch x--@e9aab10 that basically add checks for assign and assign_op expressions. |
Not critical for 0.6; de-milestoning |
Nominating for milestone 2 (backwards-compatible). |
cc #5551 |
sub-bug of #5551 |
accepted for well-defined milestone |
@fhahn you are super awesome for fixing this! |
The checks are now handled by the linter
The most egregious example is:
let x:u8 = 10_000;
which compiles without complaint. But more generally, if we're going to make a promise to constant-fold the integer-constant grammar, we might well consider overflow checks on all those arithmetic nodes. Opinions?The text was updated successfully, but these errors were encountered: