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

chore: fix loop variable typing #3571

Merged

Conversation

charles-cooper
Copy link
Member

@charles-cooper charles-cooper commented Aug 28, 2023

there is an inconsistency between codegen and typechecking types when a loop iterates over a literal list.

in this code, although it compiles, during typechecking, i is typed as a uint8 while [1,2,3] is annotated with int8[3]

@external
def foo():
for i in [1,2,3]:
    a: uint8 = i

since the iterator type is always correct, this commit is a chore since it fixes the discrepancy, but there is no known way to "abuse" the behavior to get a wrong codegen type.

chainsec june 2023 review 5.15

What I did

How I did it

How to verify it

Commit message

Commit message for the final, squashed PR. (Optional, but reviewers will appreciate it! Please see our commit message style guide for what we would ideally like to see in a commit message.)

Description for the changelog

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

there is an inconsistency between codegen and typechecking types when a
loop iterates over a literal list.

in this code, although it compiles, during typechecking, `i` is typed as
a `uint8` while `[1,2,3]` is annotated with `int8[3]`

```
@external
def foo():
for i in [1,2,3]:
    a: uint8 = i
```

since the iterator type is always correct, this commit is a chore since
it fixes the discrepancy, but there is no known way to "abuse" the
behavior to get a wrong codegen type.

chainsec june 2023 review 5.15
@charles-cooper charles-cooper merged commit c28f14f into vyperlang:master Aug 31, 2023
76 of 77 checks passed
@charles-cooper charles-cooper deleted the chore/fix-loop-variable-type branch August 31, 2023 16:59
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

Successfully merging this pull request may close these issues.

2 participants