-
-
Notifications
You must be signed in to change notification settings - Fork 905
fix[codegen]: remove silent fallback for bool kwargs in venom pipeline #4984
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
Merged
charles-cooper
merged 3 commits into
vyperlang:master
from
banteg:feat/venom-folded-bool-kwargs
May 21, 2026
+66
−3
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import pytest | ||
|
|
||
| from vyper import ast as vy_ast | ||
| from vyper.codegen_venom.builtins.abi import _get_bool_kwarg as get_abi_bool_kwarg | ||
| from vyper.codegen_venom.builtins.misc import _get_bool_kwarg as get_misc_bool_kwarg | ||
| from vyper.exceptions import CompilerPanic | ||
|
|
||
|
|
||
| def _call_node(source): | ||
| return vy_ast.parse_to_ast(source).body[0].value | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("get_bool_kwarg", [get_abi_bool_kwarg, get_misc_bool_kwarg]) | ||
| def test_bool_kwarg_uses_reduced_value(get_bool_kwarg): | ||
| call_node = _call_node("foo(flag=FLAG)") | ||
| call_node.keywords[0].value._set_folded_value(vy_ast.NameConstant(value=False)) | ||
|
|
||
| assert get_bool_kwarg(call_node, "flag", True) is False | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("get_bool_kwarg", [get_abi_bool_kwarg, get_misc_bool_kwarg]) | ||
| def test_bool_kwarg_rejects_unreduced_value(get_bool_kwarg): | ||
| call_node = _call_node("foo(flag=FLAG)") | ||
|
|
||
| with pytest.raises(CompilerPanic, match="unfoldable boolean kwarg: flag"): | ||
| get_bool_kwarg(call_node, "flag", True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -19,7 +19,7 @@ | |||||
| from vyper.codegen_venom.abi.abi_encoder import abi_encode_to_buf | ||||||
| from vyper.codegen_venom.constants import BLOCKHASH_LOOKBACK_LIMIT, ECRECOVER_PRECOMPILE | ||||||
| from vyper.evm.opcodes import version_check | ||||||
| from vyper.exceptions import EvmVersionException | ||||||
| from vyper.exceptions import CompilerPanic, EvmVersionException | ||||||
| from vyper.semantics.types import BytesT, DecimalT, StringT, TupleT | ||||||
| from vyper.utils import DECIMAL_DIVISOR, method_id_int | ||||||
| from vyper.venom.basicblock import IRLiteral, IROperand, IRVariable | ||||||
|
|
@@ -389,11 +389,12 @@ def _get_bool_kwarg(node: vy_ast.Call, kwarg_name: str, default: bool) -> bool: | |||||
| kw_node = _get_kwarg_value(node, kwarg_name) | ||||||
| if kw_node is None: | ||||||
| return default | ||||||
| kw_node = kw_node.reduced() | ||||||
| if isinstance(kw_node, vy_ast.NameConstant): | ||||||
| return kw_node.value | ||||||
| if isinstance(kw_node, vy_ast.Int): | ||||||
| return bool(kw_node.value) | ||||||
| return default | ||||||
| raise CompilerPanic(f"unfoldable boolean kwarg: {kwarg_name}") | ||||||
|
Member
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.
Suggested change
|
||||||
|
|
||||||
|
|
||||||
| def _create_tuple_in_memory( | ||||||
|
|
||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.