Skip to main content

primitive_conversion_call

Function primitive_conversion_call 

Source
pub fn primitive_conversion_call<'a>(
    node: &'a AIRNode,
    callee: &'a AIRNode,
    args: &'a [AirArg],
) -> Option<(&'a str, &'a str, &'a AIRNode)>
Expand description

Q-prim-assoc: when node is a primitive associated-conversion call (Float.from(x) / Int.try_from(s) / String.from(c)), returns (target_prim_name, method, arg), where method is "from" or "try_from" and arg is the single source-value argument.

Such a call is stamped is_associated_call and has the callee shape FieldAccess(Identifier(Prim), method) where Prim is a PRIMITIVE_CONVERSION_TARGETS name. Backends emit each target’s native conversion rather than the generic associated-call form (Float.from(x)), which references a non-existent member on the host primitive (float.from is a syntax error in Python; Float/Float_from are undefined in JS/Go/Rust). Returns None for any other call, including user-type associated calls (Fahrenheit.from(c)) and non-conversion methods, which keep their existing lowering.