From a4bb6879bccfa112c5423e535855b71938a65210 Mon Sep 17 00:00:00 2001 From: Ayaz Hafiz Date: Tue, 9 Aug 2022 14:43:36 -0700 Subject: [PATCH] Resolve recursive pointer lambda set layouts when unpacking captures --- crates/compiler/mono/src/ir.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/compiler/mono/src/ir.rs b/crates/compiler/mono/src/ir.rs index 8812e9b897..e1d45db79c 100644 --- a/crates/compiler/mono/src/ir.rs +++ b/crates/compiler/mono/src/ir.rs @@ -3130,7 +3130,10 @@ fn specialize_external<'a>( tag_id, .. } => { - debug_assert!(matches!(union_layout, UnionLayout::NonRecursive(_))); + debug_assert!(matches!( + union_layout, + UnionLayout::NonRecursive(_) | UnionLayout::Recursive(_) + )); debug_assert_eq!(field_layouts.len(), captured.len()); // captured variables are in symbol-alphabetic order, but now we want @@ -3149,7 +3152,9 @@ fn specialize_external<'a>( size2.cmp(&size1) }); - for (index, (symbol, layout)) in combined.iter().enumerate() { + for (index, (symbol, _)) in combined.iter().enumerate() { + let layout = union_layout.layout_at(tag_id, index); + let expr = Expr::UnionAtIndex { tag_id, structure: Symbol::ARG_CLOSURE, @@ -3162,7 +3167,7 @@ fn specialize_external<'a>( specialized_body = Stmt::Let( symbol, expr, - **layout, + layout, env.arena.alloc(specialized_body), ); }