Support 'pragma unchecked' in Solidity 0.8.0 #10706
Labels
closed due inactivity
The issue/PR was automatically closed due to inactivity.
language design
Any changes to the language, e.g. new features
stale
The issue/PR was marked as stale because it has been open for too long.
I have a style of dealing with over/underflows in Solidity that works like this:
Very often I use large enough variables in contexts where it is impossible to overflow and/or underflow them. Therefore I don't need to use SafeMath or default reverts from Solidity 0.8.0.
In cases where using large enough variables to prevent overflow/underflow is not possible I use explicit require statements or other custom logic to handle. I found that doing this better expresses the algorithm being implemented and can give better error messages.
I have found it important to be aware of and understand each mathematical operation that occurs in a contract and if it can over/underflow and the consequences if that happens and handle accordingly. Reverting on under/overflow is not always the right action and can result in locking funds in contracts forever. So it is important to be aware of and understand each potential over/underflow and handle it correctly.
With this style the default revert on under/overflow from Solidity 0.8.0 is not used and requires me to run all my mathematical operations within
unchecked
blocks. I would like to request apragma unchecked
or similar directive that turns off default reverts on over/underflow for the whole file.Besides supporting the style I mention above the pragma could make it easier and faster to port older Solidity code to Solidity 0.8.0.
The text was updated successfully, but these errors were encountered: