Skip to main content

desugared_list_mutating_method

Function desugared_list_mutating_method 

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

Recognise a desugared in-place List mutator call (push/append, DQ18).

The mutating sibling of desugared_list_method: same desugared shape (Call { callee: FieldAccess(recv, method), args: [recv, x] }), same recv_kind-gating (a recv_kind = "List" stamp or an absent stamp; any other stamp — a user record, a Map/Set, a primitive — is rejected so a same-named user method is not shadowed), but the method must be one of MUTATING_LIST_METHODS. Returns the receiver, the validated method name, and the remaining (non-self) arguments (the single pushed element).

The checker types these calls as Void and the ownership pass guarantees the receiver is a mut lvalue, so each backend wires this into its Call arm (alongside desugared_list_method) and lowers it to the target’s in-place idiom in statement position.