Merge pull request #1130 from rtfeldman/rc-missed-opt

fix missed RC optimization opportunity
This commit is contained in:
Richard Feldman 2021-03-30 23:06:41 -04:00 committed by GitHub
commit 4dc1018aee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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);