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

Unsigned negation in for inferred expressions doesn't warn #24676

Closed
Aatch opened this issue Apr 22, 2015 · 0 comments · Fixed by #27026
Closed

Unsigned negation in for inferred expressions doesn't warn #24676

Aatch opened this issue Apr 22, 2015 · 0 comments · Fixed by #27026
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@Aatch
Copy link
Contributor

Aatch commented Apr 22, 2015

While this warns about unsigned negation:

let x : u8 = -1;

This does not:

let x = -1;
let y : u8 = x;

This especially egregious in places like range expressions where it can cause a loop to not run at all when the lower bound is negative (and therefore becomes a large unsigned integer).

@steveklabnik steveklabnik added the A-diagnostics Area: Messages for errors, warnings, and lints label Apr 22, 2015
bors added a commit that referenced this issue Jul 20, 2015
This commit fixes the negate_unsigned feature gate to appropriately
account for inferred variables.

This is technically a [breaking-change], but I’d consider it a bug fix.

cc @brson for your relnotes.

Fixes #24676
Fixes #26840 
Fixes #25206
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants