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

fix: typechecking for folding of literal ops #3201

Closed
wants to merge 15 commits into from

Conversation

tserg
Copy link
Collaborator

@tserg tserg commented Dec 17, 2022

What I did

Fix #2830, and supersedes #2832. Hacky because it performs some typechecking during AST folding, but it should be a better option than typechecking in AST construction (original approach in 2832), and definitely a lot simpler than reordering AST folding after semantics validation (subsequent approach in 2832), which seems to add complexity in other areas too.

Not too sure if it works - will check CI when it's completed CI passes so I think this could work.

How I did it

Check for the types of the operands when folding literal ops. If there are two types, check for type mismatch and raise an error. Otherwise, if there is at least one type and the node is a BinOp, set that as the type of the folded node, which can then be used for typechecking in the semantics stage.

How to verify it

See tests.

Commit message

fix: typechecking for literal ops folding

Description for the changelog

Fix typechecking for literal ops folding.

Cute Animal Picture

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

@codecov-commenter
Copy link

codecov-commenter commented Dec 17, 2022

Codecov Report

Merging #3201 (0e541fa) into master (7ff8f30) will increase coverage by 0.03%.
The diff coverage is 100.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##           master    #3201      +/-   ##
==========================================
+ Coverage   88.87%   88.90%   +0.03%     
==========================================
  Files          84       84              
  Lines       10594    10612      +18     
  Branches     2211     2220       +9     
==========================================
+ Hits         9415     9435      +20     
+ Misses        770      769       -1     
+ Partials      409      408       -1     
Impacted Files Coverage Δ
vyper/ast/folding.py 93.93% <100.00%> (+0.66%) ⬆️
vyper/ast/nodes.py 93.83% <100.00%> (+0.04%) ⬆️
vyper/builtins/functions.py 90.59% <0.00%> (+0.16%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@tserg tserg marked this pull request as ready for review December 19, 2022 05:17
@tserg
Copy link
Collaborator Author

tserg commented Mar 5, 2023

Note: to change to known_type once #3213 is merged

@tserg tserg closed this Nov 19, 2023
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.

Type of integer constant is ignored during folding of literal ops
2 participants