-
-
Notifications
You must be signed in to change notification settings - Fork 837
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
Conversation
Codecov Report
📣 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
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
…constant_folding
…constant_folding
Note: to change to |
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 completedCI 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
Description for the changelog
Fix typechecking for literal ops folding.
Cute Animal Picture