Skip to content

Mistyped Loop Iterable #3988

@cyberthirst

Description

@cyberthirst

Version Information

  • vyper Version (output of vyper --version): commit 4b4e188

Issue description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug - type 0compiler halts or panics instead of generating code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions