Skip to main content

is_list_concat

Function is_list_concat 

Source
pub fn is_list_concat(node: &AIRNode, left: &AIRNode, right: &AIRNode) -> bool
Expand description

True when a BinaryOp { op: Add, left, right } is list concatenation and must be lowered to the target’s concat idiom rather than a native +.

Two independent signals, either of which suffices:

  1. The checker’s bock_types::checker::LIST_CONCAT_META_KEY stamp — set on a + whose operands resolved to List[T]. This is the precise signal for every + the checker’s body pass reaches.
  2. A syntactic fallback: one operand is a list literal (xs + [todo] / [head] + tail). A list literal can only be +-combined with another list (numeric/string + never has a [...] operand), so this is unambiguous — and it covers + sites the checker’s body pass does not currently visit (e.g. inside impl method bodies, which are not yet type-checked), where the stamp is absent.

Each backend calls this from its NodeKind::BinaryOp { op: Add, .. } arm. See the metadata key’s docs for the per-target lowering rationale.