vyperlang / vyper

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

Mistyped Loop Iterable #3988

Open cyberthirst opened 3 months ago

cyberthirst commented 3 months ago

Version Information

If a loop is defined over some non-literal static or dynamic array, the type obtained from the annotation of the iterator is not used to type-check the iterable. If the iterable's value type does not match the annotation, the type-checker will miss it and the compiler will later panic during code generation due to some assertion.

POC

For example, the following code crashes the compiler with vyper.exceptions.CodegenPanic: unhandled exception , parse_For.

@external
@pure
def foo() :
    s:int256[3] = [1,-1,1]
    for i:uint256 in s:
        print(i)

credits: @trocher