pub enum FusedPattern<'a> {
RangeSum {
start: Option<&'a Node>,
end: &'a Node,
},
}Expand description
A high-level fusion pattern recognised at the AST level. Each variant
borrows the relevant sub-expressions straight off the AST so consumers can
re-evaluate / re-lower them in their own context (interpreter scope or IR
LowerCtx).
Variants§
RangeSum
list.sum(range(end)) or list.sum(range(start, end)) with no
intervening .map(...) / .filter(...) stages.
Equivalent fused semantics (the byte-exact contract every back-end and the interpreter must honour):
acc: i64 = 0
for i in start..end { // empty when start >= end
acc = acc.checked_add(i)? // NumericOverflow on overflow
}
result = Int(acc)This is a fusion (drop the intermediate Vec<Value> allocation), not
a closed-form substitution: the same additions happen in the same order
with the same checked-overflow behaviour as
[start, .., end-1].sum() — the first overflowing partial sum raises
NumericOverflow. start defaults to 0 for the one-arg
range(end) form.