From 77b0be5c15bd772a3987f9f87555d3ef15e38e81 Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Sat, 22 Aug 2026 16:22:54 +0000 Subject: [PATCH] Lift shallower sources in the layout union --- node-graph/libraries/core-types/src/record.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/node-graph/libraries/core-types/src/record.rs b/node-graph/libraries/core-types/src/record.rs index e61f92ad4d..7f4c9e09ee 100644 --- a/node-graph/libraries/core-types/src/record.rs +++ b/node-graph/libraries/core-types/src/record.rs @@ -252,10 +252,12 @@ impl Layout { /// The union of several layouts over the same element and depth. pub fn union(layouts: &[&Layout]) -> Layout { let first = layouts.first().expect("a union needs at least one layout"); - let mut union = Layout::default().with_writes(first.depth, first.element, &[]); + // A shallower source joins the union lifted: a scalar concatenates as + // one lane, its fields sitting at the innermost level like any lane's. + let depth = layouts.iter().map(|layout| layout.depth).max().unwrap_or(first.depth); + let mut union = Layout::default().with_writes(depth, first.element, &[]); for layout in layouts { assert_eq!(union.element, layout.element, "union layouts must share the element"); - assert_eq!(union.depth, layout.depth, "union layouts must share the depth"); let writes: Vec = layout .fields .iter()