vyperlang / vyper

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

Exception Raised During Optimization Are Not `VyperInternalException` #4187

Open ritzdorf opened 4 months ago

ritzdorf commented 4 months ago

Version Information

Exceptions raised as part of the code generation (module.generate_ir_for_module()) are wrapped in a CodegenError exception for easier debugging. This is not the case for exceptions raised during the optimization (optimizer.optimize()).

POC

For example, the following contract fails to compile with an AssertionError and not a Vyper exception:

c: uint256

@internal
def se_bbytes() -> Bytes[4]:
    self.c += 1
    return b''

@external
def foo(a: address) -> uint256:
    x:address = create_from_blueprint(a, self.se_bbytes(), code_offset=1, raw_args = True)
    return self.c