fix one element struct unpacking

I think this broke when we decided that we want to not drop empty fields from layouts?
This commit is contained in:
Folkert 2021-01-21 21:40:04 +01:00
parent ef89ff15a1
commit df8ab829a6
4 changed files with 33 additions and 17 deletions

View file

@ -1250,24 +1250,12 @@ pub fn build_exp_expr<'a, 'ctx, 'env>(
index,
structure,
wrapped: Wrapped::SingleElementRecord,
field_layouts,
..
} => {
match load_symbol_and_layout(env, scope, structure) {
(StructValue(argument), Layout::Struct(fields)) if fields.len() > 1 =>
// TODO so sometimes a value gets Wrapped::SingleElementRecord
// but still has multiple fields...
{
env.builder
.build_extract_value(
argument,
*index as u32,
env.arena
.alloc(format!("struct_field_access_single_element{}", index)),
)
.unwrap()
}
(other, _) => other,
}
debug_assert_eq!(field_layouts.len(), 1);
debug_assert_eq!(*index, 0);
load_symbol(env, scope, structure)
}
AccessAtIndex {