mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00:00
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:
parent
ef89ff15a1
commit
df8ab829a6
4 changed files with 33 additions and 17 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue