-
-
Notifications
You must be signed in to change notification settings - Fork 830
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
feat: allow range with two arguments and bound #3679
feat: allow range with two arguments and bound #3679
Conversation
Fixes vyperlang#3678 Adds test coverage for touched code
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 #3679 +/- ##
==========================================
+ Coverage 83.92% 83.97% +0.05%
==========================================
Files 92 92
Lines 13065 13044 -21
Branches 2934 2928 -6
==========================================
- Hits 10965 10954 -11
+ Misses 1666 1661 -5
+ Partials 434 429 -5 ☔ View full report in Codecov by Sentry. |
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.
looks nice! nice refactoring of that range functionality too. left a couple comments, i think we also want to clarify the behavior of the bounds check in the docs (i.e., end - start <= bound
as opposed to, for instance, end <= bound
).
tests need to be updated to use the new |
vyper/codegen/stmt.py
Outdated
else: | ||
arg1 = self.stmt.iter.args[1] | ||
rounds = self._get_range_const_value(arg1.right) | ||
raise InvalidOperation("Invalid number of arguments to range()") |
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.
this should be a panic really
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!
- allow range where both start and end arguments are variables, so long as a bound is supplied - ban range expressions of the form `range(x, x + N)` since the new form is cleaner and supersedes it. - also do a bit of refactoring of the codegen for range --------- Co-authored-by: Charles Cooper <cooper.charles.m@gmail.com>
Fixes #3678
What I did
range
with 2 argumentsHow I did it
How to verify it
Tests are included
Commit message
Allow range(x, y, bound=N)
Description for the changelog
Add support for range with start/end runtime arguments as long as a
bound
argument is given.Cute Animal Picture