Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mistyped Loop Iterable #3988

Open
cyberthirst opened this issue May 2, 2024 · 0 comments
Open

Mistyped Loop Iterable #3988

cyberthirst opened this issue May 2, 2024 · 0 comments

Comments

@cyberthirst
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant