vyperlang / vyper

Pythonic Smart Contract Language for the EVM
https://vyperlang.org
Other
4.83k stars 789 forks source link

Folding exponent can make the compiler crash #4078

Open trocher opened 3 months ago

trocher commented 3 months ago

Version Information

Issue description

When having x ** y folded, if x == 0 or x == 1, the compiler will crash.

See:

https://github.com/vyperlang/vyper/blob/6d4c09cda518ffce81a9a76f822059fdce16cdfb/vyper/ast/nodes.py#L1105-L1106

POC

@external
def foo()->uint256:
   return 1**2
ZeroDivisionError: float division by zero
@external
def foo()->uint256:
   return 0**2
ValueError: math domain error