vyperlang / vyper

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

Compiler Panic When Popping From or Appending to an Empty Array #4132

Open ritzdorf opened 4 months ago

ritzdorf commented 4 months ago

Version Information

When pop-ing from or append-ing to an empty array (empty(T)), the compiler panics when trying to call FunctionAnalyzer._handle_modification() on the empty array.

POC

The following code will make the compiler panic:

@external
def bar():
    a:uint128 = empty(DynArray[uint128,2]).pop() # CompilerPanic: unhandled exception 
@external
def bar():
    empty(DynArray[uint128,2]).append(1) # CompilerPanic: unhandled exception