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

[draft] refactor: constant folding #1

Commits on Jan 7, 2024

  1. 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>
    tserg and charles-cooper authored Jan 7, 2024
    Configuration menu
    Copy the full SHA
    ddfce52 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7b5da3b View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    d73caa7 View commit details
    Browse the repository at this point in the history
  4. fix some small bugs

    charles-cooper committed Jan 7, 2024
    Configuration menu
    Copy the full SHA
    a13086f View commit details
    Browse the repository at this point in the history
  5. fix more bugs

    charles-cooper committed Jan 7, 2024
    Configuration menu
    Copy the full SHA
    e0b689d View commit details
    Browse the repository at this point in the history