Recognize a reducer's IList input level in build

This commit is contained in:
Dennis Kobert
2026-08-14 10:13:53 +00:00
parent 8f265e7660
commit 65e0969721

View File

@@ -754,6 +754,18 @@ mod tests {
assert_eq!(node.output.shape.depth as i8 - subject_depth as i8, 1, "creator level_delta is +1");
}
#[test]
fn reducer_ilist_input_collapses_a_level() {
let mut parsed = parse_node_fn(quote!(category("")), quote!(fn sum(_: impl Ctx, items: IList<f64>) -> f64 { items.into_iter().sum() })).unwrap();
parsed.replace_impl_trait_in_input();
let node = build(&parsed);
// The `IList` input is a depth-1 subject; the scalar output collapses it.
let subject = node.inputs.iter().find(|input| input.subject).expect("the reduced input is the subject");
assert_eq!(subject.shape.depth, 1);
assert_eq!(node.output.shape.depth, 0);
assert_eq!(node.output.shape.depth as i8 - subject.shape.depth as i8, -1, "the reducer collapses one level");
}
#[test]
fn monomorphizations_key_by_generic() {
let node = assert_bridge(