2
function nice(uint8 x) public  returns(uint8 z){
       uint8 z = 0;
       z = z + 240;
       require(z = z + x, "overflow");
   }

I have been using this code with the solidity versions, prior to 0.8 update. If there was an overflow, transaction would get reverted with the message overflow.

Now, I am moving to 0.8. If I use the same code, my test cases fail, because they don't get overfow revert message anymore. If I remove require and just leave z = z+x as the solidity suggests, then, I have no idea with what message it gets reverted. What I want to achieve is to use 0.8 and still get overflow revert message.

NOTE I don't want to use unchecked .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.