From 65e096972131e5ffc24e43efc4538301c4971cbd Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Fri, 14 Aug 2026 10:13:53 +0000 Subject: [PATCH] Recognize a reducer's IList input level in build --- node-graph/node-macro/src/codegen/ir.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/node-graph/node-macro/src/codegen/ir.rs b/node-graph/node-macro/src/codegen/ir.rs index 918c06c363..44507c704b 100644 --- a/node-graph/node-macro/src/codegen/ir.rs +++ b/node-graph/node-macro/src/codegen/ir.rs @@ -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 { 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(