fix(semantic): evaluate const !, &, |, ^ on bool operands - #10212
Conversation
Const bitwise ops on bool operands (`ConstValue::Enum`) fell through to the numeric path, where `NumericArg::try_new` rejects them, dropping the value to `Missing` and surfacing later as a sierra-generation ICE. Handle bool operands directly alongside the existing `eq`/`ne` cases: `not`, `bitand`, `bitor`, `bitxor`. Integer operands still take the numeric path.
PR SummaryLow Risk Overview In Adds Reviewed by Cursor Bugbot for commit f84e76a. Bugbot is set up for automated code reviews on this repo. Configure here. |
TomerStarkware
left a comment
There was a problem hiding this comment.
@TomerStarkware reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on eytan-starkware).

Summary
Adds support for evaluating
boolbitwise operations (&,|,^) at compile time in constant expressions. Thenot_fnhandling is also refactored to sit alongside the new bitwise operations under a shared guard that ensures all arguments are valid boolean constants.Type of change
Please check one:
Why is this change needed?
Previously, constant expressions involving boolean bitwise operations (
&,|,^) were not evaluated at compile time, causing them to fail or be rejected inconstcontexts. Only!(not),==, and!=were handled.What was the behavior or documentation before?
Boolean bitwise operations such as
true & false,true | false, andtrue ^ falsecould not be used inconstdeclarations.What is the behavior or documentation after?
constdeclarations can now use boolean bitwise operations. For example:These are correctly evaluated at compile time to
false,true, andtruerespectively.Related issue or discussion (if any)
Additional context
A new test
test_const_bool_bitwiseis added toconst_test.cairoto verify the correct compile-time evaluation of all three boolean bitwise operations.