Skip to main content

is_int_arith

Function is_int_arith 

Source
pub fn is_int_arith(node: &AIRNode) -> bool
Expand description

True when a BinaryOp { op: Div | Rem, .. } is integer division / remainder and must be lowered to DQ23’s cross-target integer semantics (§3.6) rather than the target’s native / / %.

The signal is the checker’s bock_types::checker::INT_ARITH_META_KEY stamp, set on a / or % whose two operands both resolved to an integer primitive. A purely syntactic codegen check cannot see that bare identifiers (a / b) are integer-typed, so — unlike is_list_concat, which has a list-literal fallback — there is no syntactic fallback here: the stamp is the sole signal.

Each backend that diverges from the contract on its native operator (JS/TS: float /, no zero-abort; Python: floor // and floor-%) calls this from its NodeKind::BinaryOp { op: Div | Rem, .. } arm. Rust and Go already match the contract with native / / %, so they ignore it. See the metadata key’s docs for the per-target lowering rationale.