-
-
Notifications
You must be signed in to change notification settings - Fork 256
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
RCS1089: += 1
is not always equivalent to postfix increment
#639
Comments
It's the same with Do you know of any other syntax where the pre-increment should be used? |
Passing arguments ( And of course it's not just the increment operator, this affects the decrement operator as well. |
I came to this conclusion: If an assignment expression is used as a part of statement, post-increment should be used: Every other use of Same logic applies to decrement operation. |
Sharplab
Whenever the value of the
+=
expression is taken, it's equivalent to a pre-increment, not a post-increment. When applying the code fix RCS1089, this difference can introduce subtle off-by-one bugs.Version: 2.3.0
The text was updated successfully, but these errors were encountered: