Constants on the left are better, but this is often trumped by a preference for English word order.
Typically we all write comparison statements like this:
the compiler will assign 5 to the “currentValue” variable and the result will be the value of the assignment, which is 5.
Anything that isn’t zero is “truthy” and will cause the “if” branch to be taken. If you didn’t intend for this and you’re lucky enough to have compiler warnings turned all the way up, you’ll get a helpful message like “warning C4706: assignment within conditional expression.”
Instances: 7
Escrow.sol
:
|if (address(tokenContract) == address(0)) revert Escrow__TokenZeroAddress();
|if (buyer == address(0)) revert Escrow__BuyerZeroAddress();
|if (seller == address(0)) revert Escrow__SellerZeroAddress();
|if (i_arbiter == address(0)) revert Escrow__DisputeRequiresArbiter();
Placing the constants on the left will prevent typo bugs.
Manual finding
Change the order of the conditions such as:
if (address(0) == seller)
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.