-
-
Notifications
You must be signed in to change notification settings - Fork 836
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
bug: calls to state-modifying functions in range
expressions are not caught
#3504
Comments
Note that with commit d48438e The codegen no longer prevent the bug in certain case, leading contracts with side effect in Line 268 in cfda16c
interface A:
def foo()-> uint256: nonpayable
@external
def bar(x:address):
a: A = A(x)
for i in range(a.foo(), bound = 12):
pass |
This may not be as big of a deal, since it is only called once |
@trocher thanks for finding, will fix before release |
Also this one would currently compile even if it is really an edge case: @external
def bar(x:address):
for i in range(1 if raw_call(x, b'', revert_on_failure=False) else 2 , bound = 12):
pass Spent some time compiling a list of state modifying expressions:
For |
@trocher i think this is a feature, not a bug? there isn't really any ambiguity about side effect ordering or anything here. |
Yes I agree, in this case there is no ambiguity or anything, my concern was rather about the semantics of vyper/vyper/codegen/context.py Lines 96 to 97 in 728a276
|
ah interesting -- do you think this can lead to any bugs? |
I don't see how it could lead to an issue in this specific case, it is really only about the semantics of
And now something along those lines:
Note that I use here the term |
as of 194d60a, this triggers a compiler panic (slightly modified code for 0.4.x): interface A:
def foo()-> uint256: nonpayable
@external
def bar(x:address):
a: A = A(x)
for i: uint256 in range(extcall a.foo(), bound = 12):
pass the panic looks like
|
(the panic looks like a duplicate of / related to #3867 actually) |
Version Information
vyper --version
): 9e3b9a2python --version
): 3.10.4What's your issue about?
The type checker does not catch the use of a state-modifying function call in a range expression, this leads the code generator to fail due to an assertion:
assert use_staticcall, "typechecker missed this"
h/t @trocher
How can it be fixed?
Fill this in if you know how to fix it.
The text was updated successfully, but these errors were encountered: