diff --git a/compiler/mono/src/expand_rc.rs b/compiler/mono/src/expand_rc.rs index edfef880dd..fecdfd240a 100644 --- a/compiler/mono/src/expand_rc.rs +++ b/compiler/mono/src/expand_rc.rs @@ -441,7 +441,7 @@ fn expand_and_cancel<'a>(env: &mut Env<'a, '_>, stmt: &'a Stmt<'a>) -> &'a Stmt< structure, index, field_layouts, - .. + wrapped, } => { let entry = env .alias_map @@ -450,6 +450,15 @@ fn expand_and_cancel<'a>(env: &mut Env<'a, '_>, stmt: &'a Stmt<'a>) -> &'a Stmt< entry.insert(*index, symbol); + // fixes https://github.com/rtfeldman/roc/issues/1099 + if matches!( + wrapped, + Wrapped::SingleElementRecord | Wrapped::RecordOrSingleTagUnion + ) { + env.layout_map + .insert(*structure, Layout::Struct(field_layouts)); + } + // if the field is a struct, we know its constructor too! let field_layout = &field_layouts[*index as usize]; env.try_insert_struct_info(symbol, field_layout);