fix[codegen]: remove silent fallback for bool kwargs in venom pipeline#4984
Conversation
|
i think it's worse that we are falling back to something rather than not unfolding. we should remove the |
31b2ebb to
deda489
Compare
|
Updated. The helpers still return the default when the kwarg is absent, but a provided bool kwarg that cannot be interpreted after folding now raises |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4984 +/- ##
==========================================
+ Coverage 92.71% 92.81% +0.09%
==========================================
Files 187 187
Lines 27626 27629 +3
Branches 4776 4776
==========================================
+ Hits 25614 25644 +30
+ Misses 1363 1336 -27
Partials 649 649 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
deda489 to
8530645
Compare
|
Updated to use |
| if isinstance(kw_node, vy_ast.Int): | ||
| return bool(kw_node.value) | ||
| return default | ||
| raise CompilerPanic(f"unfoldable boolean kwarg: {kwarg_name}") |
There was a problem hiding this comment.
| raise CompilerPanic(f"unfoldable boolean kwarg: {kwarg_name}") | |
| raise CompilerPanic(f"unfoldable boolean kwarg: {kwarg_name}", kw_node) |
| if isinstance(kw_node, vy_ast.Int): | ||
| return bool(kw_node.value) | ||
| return default | ||
| raise CompilerPanic(f"unfoldable boolean kwarg: {kwarg_name}") |
There was a problem hiding this comment.
| raise CompilerPanic(f"unfoldable boolean kwarg: {kwarg_name}") | |
| raise CompilerPanic(f"unfoldable boolean kwarg: {kwarg_name}", kw_node) |
|
Applied the suggestion in both bool-kwarg helpers: the CompilerPanic now carries the offending kwarg node. Validated with the focused bool-kwarg, abi_decode, print tests, and ruff check. |
|
Correction: #4984 was merged while this follow-up was being pushed, so the branch update is not part of the merged PR. I opened the audited follow-up as #5001: #5001 Summary of the follow-up:
Validated with focused Venom helper, abi_encode, abi_decode, print, constants, create, raw_call, and send tests; ruff check is clean on all touched files. |
What I did
Fixed Venom builtin lowering for boolean keyword arguments that semantic analysis already accepted as folded constants.
This covers
abi_decode(..., unwrap_tuple=CONST_FALSE)andprint(..., hardhat_compat=CONST_TRUE).How I did it
Updated the Venom bool kwarg extraction helpers in the ABI and debug-print builtins to use
kw_node.reduced()before checking for boolean or integer literals.If a provided bool kwarg still cannot be recognized after reduction, the helper raises a compiler panic instead of silently falling back to the default. That keeps the absent-kwarg default path, but avoids masking unexpected accepted input.
How to verify it
uv run --python 3.12 pytest tests/unit/compiler/venom/test_builtin_kwargs.py tests/functional/builtins/codegen/test_abi_decode.py::test_abi_decode_folded_unwrap_tuple_kwarg tests/functional/syntax/test_print.py::test_print_folded_hardhat_compat_kwarg -quv run --python 3.12 ruff check vyper/codegen_venom/builtins/abi.py vyper/codegen_venom/builtins/misc.py tests/unit/compiler/venom/test_builtin_kwargs.py tests/functional/builtins/codegen/test_abi_decode.py tests/functional/syntax/test_print.pyCommit message
Description for the changelog
Fix Venom builtin lowering for folded constant boolean keyword arguments.