-
-
Notifications
You must be signed in to change notification settings - Fork 788
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 incorrect compile_to_assembly call args #1619
Fix incorrect compile_to_assembly call args #1619
Conversation
Would this have been caught with MyPy? |
Probably - |
Nice fix, thanks. While we're at it, could you please change the assertions to |
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.
These two asserts could be CompilerPanic
@charles-cooper good call 👍 see new commit |
vyper/compile_lll.py
Outdated
@@ -88,11 +91,13 @@ def apply_line_no_wrapper(*args, **kwargs): | |||
def compile_to_assembly(code, withargs=None, existing_labels=None, break_dest=None, height=0): | |||
if withargs is None: | |||
withargs = {} | |||
assert isinstance(withargs, dict) | |||
elif not isinstance(withargs, dict): |
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.
kind of a nitpick but to preserve the semantics I think these should be standalone if
statements, not elif
statements. Somebody could come in later and change the body of the previous branch to read withargs = []
and then we would no longer have the guarantee after this line that withargs
is a dict.
vyper/compile_lll.py
Outdated
|
||
if existing_labels is None: | ||
existing_labels = set() | ||
assert isinstance(existing_labels, set) | ||
elif not isinstance(existing_labels, set): |
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.
ditto
e83a6e5
to
7f63da6
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.
LGTM, will merge once CI passes
The Issue
As discovered by @michwill and reported on Gitter, the following code was not compiling due to an assertion error:
The issue was in
vyper/compile_lll.py
- several calls tocompile_to_assembly
were not including theexisting_labels
argument:https://github.com/ethereum/vyper/blob/089d0c4046a5e71412b46205788a89e76d7646ea/vyper/compile_lll.py#L273-L275
What I did
Added
existing_labels
as an argument incompile_to_assembly
calls where it was missing.How to verify it
See the new test cases in
tests/parser/features/test_assert.py
. I also added checks for proper behavior of the iterated assertions.Cute Animal Picture