pragma solidity ^0.8.0;
contract Test {
function f(int32 x) external pure returns (int32) {
int32 y = 1;
((x) /= (2 % x)) + (-y);
return 2;
}
}
Compiling the above program raises an error complaining that + is disallowed in ((x) /= (2 % x)) + (-y);. However, when I change this expression statement into x = ((x) /= (2 % x)) + (-y);, the compiler does not raise the error.
According to my understanding of Solidity type system, expr /= expr is an assignment expression, and its value equals the value of the left-hand-side identifier. I think + can connect the assignment expression and an identifier expression (-y).
Description
The unary "+" in "((x) /= (2 % x)) + (-y)" reports an error, but x = ((x) /= (2 % x)) + (-y) does not.
Environment
Steps to Reproduce
Compiling the above program raises an error complaining that
+
is disallowed in((x) /= (2 % x)) + (-y);
. However, when I change this expression statement intox = ((x) /= (2 % x)) + (-y);
, the compiler does not raise the error. According to my understanding of Solidity type system,expr /= expr
is an assignment expression, and its value equals the value of the left-hand-side identifier. I think+
can connect the assignment expression and an identifier expression(-y)
.