fix missed RC optimization opportunity

This commit is contained in:
Folkert 2021-03-30 14:09:46 +02:00
parent 4ce520fed6
commit 1ac7ed1bfd

View file

@ -441,7 +441,7 @@ fn expand_and_cancel<'a>(env: &mut Env<'a, '_>, stmt: &'a Stmt<'a>) -> &'a Stmt<
structure, structure,
index, index,
field_layouts, field_layouts,
.. wrapped,
} => { } => {
let entry = env let entry = env
.alias_map .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); 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! // if the field is a struct, we know its constructor too!
let field_layout = &field_layouts[*index as usize]; let field_layout = &field_layouts[*index as usize];
env.try_insert_struct_info(symbol, field_layout); env.try_insert_struct_info(symbol, field_layout);