You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After #36 lands support for basic arithmetic operations including division will be implemented. However, division by zero will return 0 as that is the EVM default behavior. We should throw an exception instead.
My thinking right now is that we will introduce safe math functions to the runtime, where we check for things like overflow and div-by-zero. Then instead of mapping a / b to div(a', b'), we map to safe_div(a', b'), where safe_div is a function that we've defined that reverts on a zero denominator.
I think the semantic analysis pass should be responsible for determining what functions are needed during runtime and then we'll include them in the Yul contract when mapping from the Fe contract. This approach would be extended to things like maps where we have generic type params. For example, defining the contract field pub guest_book: map<address, bytes[100]> would result in two function being added to the runtime named something like map_get_address_bytes100 and map_insert_address_bytes100, which would be used in place of the expression self.guest_book[0x00] and statement self.guest_book[0x00] = some_bytes.
What is wrong
After #36 lands support for basic arithmetic operations including division will be implemented. However, division by zero will return
0
as that is the EVM default behavior. We should throw an exception instead.How can it be fixed
Need to investigate. Solidity fixed that a long time ago. Related threads ethereum/solidity#888, ethereum/solidity#670
The text was updated successfully, but these errors were encountered: