-
-
Notifications
You must be signed in to change notification settings - Fork 807
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: iterator modification analysis #3764
fix: iterator modification analysis #3764
Conversation
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #3764 +/- ##
==========================================
- Coverage 84.94% 84.71% -0.24%
==========================================
Files 92 92
Lines 13594 13660 +66
Branches 3060 3067 +7
==========================================
+ Hits 11548 11572 +24
- Misses 1560 1596 +36
- Partials 486 492 +6 ☔ View full report in Codecov by Sentry. |
d3c5f29
to
4ffd3aa
Compare
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.
It is a nit, but I think we should use analyze
instead of analyse
in the names since the former is predominantly used.
Also, this contract fails to compile when the iterator is a struct member that is not modified by the loop, but another struct member is. Is this intended behaviour?
struct Foo:
a: uint256[2]
b: uint256
f: Foo
@deploy
def __init__():
self.f = Foo({a: [256, 512], b: 321})
@external
def bar():
for i: uint256 in self.f.a:
self._bar()
@internal
def _bar():
self.f.b = 123
vyper.exceptions.ImmutableViolation: Cannot modify loop variable `f`
contract "tmp/modify_struct_iter.vy:5", line 5:0
4
---> 5 f: Foo
-------^
6
contract "tmp/modify_struct_iter.vy:14", function "bar", line 14:8
13 for i: uint256 in self.f.a:
---> 14 self._bar()
----------------^
15
hm this seems like a false positive. i am less worried about false positives than false negatives, but i will look into it! |
i have a draft fix for the struct member issue, although it doesn't feel very clean yet: charles-cooper#22 |
it turns out it was not a very good idea
What I did
fix #3429
How I did it
How to verify it
Commit message
Description for the changelog
Cute Animal Picture