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

Linter: Divide before multiply #2073

Open
jubnzv opened this issue Jan 25, 2024 · 0 comments
Open

Linter: Divide before multiply #2073

jubnzv opened this issue Jan 25, 2024 · 0 comments
Assignees
Labels
A-linter Issue regarding the ink! linter. B-feature-request A request for a new feature.

Comments

@jubnzv
Copy link
Member

jubnzv commented Jan 25, 2024

In Rust, integer division might unexpectedly result with 0:

let a: u32 = 2;
let b: u32 = 4;
let c: u32 = a / b * 8; // c == 0

The user is intended to write the following:

let a: u32 = 2;
let b: u32 = 4;
let c: u32 = a * 8 / b; // c == 4

Reference: slither documentation.

@jubnzv jubnzv added B-feature-request A request for a new feature. A-linter Issue regarding the ink! linter. labels Jan 25, 2024
@jubnzv jubnzv self-assigned this Jan 25, 2024
jubnzv added a commit to jubnzv/ink that referenced this issue Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linter Issue regarding the ink! linter. B-feature-request A request for a new feature.
Projects
None yet
Development

No branches or pull requests

1 participant