forked from vyperlang/vyper
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: require type annotations for loop variables (vyperlang#3596)
this commit changes the vyper language to require type annotations for loop variables. that is, before, the following was allowed: ```vyper for i in [1, 2, 3]: pass ``` now, `i` is required to have a type annotation: ```vyper for i: uint256 in [1, 2, 3]: pass ``` this makes the annotation of loop variables consistent with the rest of vyper (it was previously a special case, that loop variables did not need to be annotated). the approach taken in this commit is to add a pre-parsing step which lifts out the type annotation into a separate data structure, and then splices it back in during the post-processing steps in `vyper/ast/parse.py`. this commit also simplifies a lot of analysis regarding for loops. notably, the possible types for the loop variable no longer needs to be iterated over, we can just propagate the type provided by the user. for this reason we also no longer need to use the typechecker speculation machinery for inferring the type of the loop variable. however, the NodeMetadata code is not removed because it might come in handy at a later date. --------- Co-authored-by: Charles Cooper <cooper.charles.m@gmail.com>
- Loading branch information
1 parent
0c82d0b
commit ddfce52
Showing
40 changed files
with
432 additions
and
330 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.