Lucky hour! Grab a free trial license — offer ends in 00:59:58. Claim now
The analyzer has detected an error related to using postfix increment or decrement when writing to the same variable.
The example:
let value = 0;
....
value = value++; // <=
....
The value variable remains zero after the assignment. This happens because the postfix increment and decrement return the variable value before it is modified. The expression evaluates in the following order:
value variable; value variable by one; value variable. As a result, the effect of the postfix increment or decrement is lost when the result is reassigned to the same variable.
This may be a typo, and the result should have been stored in another variable. In that case, the fixed code might look like this:
let value = 0;
let savedValue = ....;
....
savedValue = value++;
....
Otherwise, developers might have accidentally written the assignment, even though it is not really needed here:
let value = 0;
....
value++;
....
This diagnostic is classified as:
Was this page helpful?
Your message has been sent. We will email you at
If you do not see the email in your inbox, please check if it is filtered to one of the following folders: