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

Array being iterated over can be modified in another function #1707

Closed
smarx opened this issue Nov 9, 2019 · 1 comment
Closed

Array being iterated over can be modified in another function #1707

smarx opened this issue Nov 9, 2019 · 1 comment
Labels
bug Bug that shouldn't change language semantics when fixed.

Comments

@smarx
Copy link
Contributor

smarx commented Nov 9, 2019

Modifying the array directly in the loop body is disallowed, so this could be considered a bug:

x: uint256[1]

@private
def store_in_x(index: uint256, value: uint256):
    self.x[index] = value

@public
def foo():
    for n in self.x:
        # self.x[0] = n * 2 # blocked with "Altering list 'self.x' which is being iterated!"
        self.store_in_x(0, n * 2) # BUG: allowed
@fubuloubu fubuloubu added the bug Bug that shouldn't change language semantics when fixed. label Nov 10, 2019
cbraem added a commit to viperproject/2vyper that referenced this issue May 15, 2020
Due to a bug in vyper we cannot store the array we loop over in a variable ( vyperlang/vyper#1707 ).
@fubuloubu fubuloubu added this to the v0.2 Release milestone Jun 22, 2020
@iamdefinitelyahuman
Copy link
Contributor

Fixed in #2028

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug that shouldn't change language semantics when fixed.
Projects
None yet
Development

No branches or pull requests

3 participants