-
-
Notifications
You must be signed in to change notification settings - Fork 907
fix[lang]: abi-encode with expr CompilerPanic #5154
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
base: master
Are you sure you want to change the base?
Changes from all commits
522c1c6
2f10e1e
7aad857
b3d1132
7eb702e
39e1b34
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| import pytest | ||
|
|
||
| from vyper import compiler | ||
| from vyper.exceptions import InvalidLiteral, TypeMismatch | ||
| from vyper.exceptions import InvalidLiteral, TypeMismatch, UnfoldableNode | ||
|
|
||
| fail_list = [ | ||
| ( | ||
|
|
@@ -119,9 +119,24 @@ def foo(x: Bytes[1]) -> Bytes[68]: | |
| def foo() -> Bytes[224]: | ||
| return _abi_encode(BAR) | ||
| """, | ||
| """ | ||
| @external | ||
| def foo(x: Bytes[1]) -> Bytes[96]: | ||
| return _abi_encode(x, ensure_tuple=(0 < 1)) | ||
| """, | ||
| ] | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("good_code", valid_list) | ||
| def test_abi_encode_success(good_code): | ||
| assert compiler.compile_code(good_code) is not None | ||
|
|
||
|
|
||
| @pytest.mark.xfail(raises=UnfoldableNode) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When the CI matrix runs the experimental pipeline ( Useful? React with 👍 / 👎.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is empirically wrong, the venom tests pass |
||
| def test_abi_encode_ensure_tuple_foldable_expr(): | ||
| code = """ | ||
| @external | ||
| def f(x: uint256) -> Bytes[64]: | ||
| return abi_encode(x, ensure_tuple=empty(bool)) | ||
| """ | ||
| assert compiler.compile_code(code) is not None | ||
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.
where is the compiler panic from?
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.
CompilerPanic: unfoldable boolean kwarg: unwrap_tupleFrom
_get_bool_kwargin misc.pyI tried to make it raise an UnfoldableNode as well, but actually the proper fix is to fix #5153
The front-end checks that this is a Constant, so we should never be in a situation were we need to raise in the first place
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.
can we fix the venom pipeline too so that it doesn't panic? what is the point of "fixing" the panic in one pipeline but not the other?
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 PR fixes the panic on both backends for cases like:
This xfail test is instead due to #5153
I did not want to burden this PR with some codegen changes just to change the type of
VyperInternalExceptionwhich is reportedThere 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.
Claude-authored explanation of why this happens here (and not on abi_encode):
Semantic analysis passes cleanly, and the kwarg is only consumed at codegen: