-
-
Notifications
You must be signed in to change notification settings - Fork 804
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: prevent range over decimal #3798
fix: prevent range over decimal #3798
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #3798 +/- ##
==========================================
- Coverage 85.00% 84.99% -0.01%
==========================================
Files 92 92
Lines 13765 13771 +6
Branches 3083 3084 +1
==========================================
+ Hits 11701 11705 +4
- Misses 1575 1576 +1
- Partials 489 490 +1 ☔ View full report in Codecov by Sentry. |
vyper/semantics/analysis/local.py
Outdated
@@ -512,6 +513,10 @@ def visit_For(self, node): | |||
|
|||
iter_var = None | |||
if isinstance(node.iter, vy_ast.Call): | |||
if not isinstance(target_type, IntegerT): | |||
raise TypeCheckFailure( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'd prefer to reuse the exception handling / error message from validate_expected_type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should also raise TypeMismatch (a regular exception) rather than a TypeCheckFailure (which is a panic)
hm yea the naming is confusing, we should really rename TypeCheckFailure
to TypeCheckPanic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced TypeCheckFailure
by TypeMismatch
and now use validate_expected_type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
What I did
looping over a
range
was allowed if the iterator type wasdecimal
, this PR prevents this unintended behaviour.How I did it
IntegerT
.range()
expression are not onlyNum
butInt
.How to verify it
See tests
Commit message
Description for the changelog
Cute Animal Picture