mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Support non-nullable-unwrapped recursive lambda sets
This commit is contained in:
parent
c1a7e7893b
commit
021cc6e506
3 changed files with 64 additions and 7 deletions
|
@ -898,7 +898,7 @@ impl<'a> LambdaSet<'a> {
|
|||
let runtime_repr = self.runtime_representation();
|
||||
debug_assert!(matches!(
|
||||
runtime_repr,
|
||||
Layout::Union(UnionLayout::Recursive(_))
|
||||
Layout::Union(UnionLayout::Recursive(_) | UnionLayout::NullableUnwrapped { .. })
|
||||
));
|
||||
Layout::LambdaSet(*self)
|
||||
} else {
|
||||
|
@ -909,7 +909,7 @@ impl<'a> LambdaSet<'a> {
|
|||
let runtime_repr = self.runtime_representation();
|
||||
debug_assert!(matches!(
|
||||
runtime_repr,
|
||||
Layout::Union(UnionLayout::Recursive(_))
|
||||
Layout::Union(UnionLayout::Recursive(_) | UnionLayout::NullableUnwrapped { .. })
|
||||
));
|
||||
Layout::LambdaSet(*self)
|
||||
} else {
|
||||
|
@ -964,15 +964,31 @@ impl<'a> LambdaSet<'a> {
|
|||
union_layout: *union,
|
||||
}
|
||||
}
|
||||
UnionLayout::NullableUnwrapped {
|
||||
nullable_id: _,
|
||||
other_fields: _,
|
||||
} => {
|
||||
let (index, (name, fields)) = self
|
||||
.set
|
||||
.iter()
|
||||
.enumerate()
|
||||
.find(|(_, (s, layouts))| comparator(*s, layouts))
|
||||
.unwrap();
|
||||
|
||||
let closure_name = *name;
|
||||
|
||||
ClosureRepresentation::Union {
|
||||
tag_id: index as TagIdIntType,
|
||||
alphabetic_order_fields: fields,
|
||||
closure_name,
|
||||
union_layout: *union,
|
||||
}
|
||||
}
|
||||
UnionLayout::NonNullableUnwrapped(_) => todo!("recursive closures"),
|
||||
UnionLayout::NullableWrapped {
|
||||
nullable_id: _,
|
||||
other_tags: _,
|
||||
} => todo!("recursive closures"),
|
||||
UnionLayout::NullableUnwrapped {
|
||||
nullable_id: _,
|
||||
other_fields: _,
|
||||
} => todo!("recursive closures"),
|
||||
}
|
||||
}
|
||||
Layout::Struct { .. } => {
|
||||
|
@ -1187,6 +1203,20 @@ impl<'a> LambdaSet<'a> {
|
|||
Layout::Union(UnionLayout::Recursive(tag_arguments.into_bump_slice()))
|
||||
}
|
||||
|
||||
NullableUnwrapped {
|
||||
nullable_id,
|
||||
nullable_name: _,
|
||||
other_name,
|
||||
other_fields,
|
||||
} => {
|
||||
debug_assert!(matches!(other_name, TagOrClosure::Closure(_)));
|
||||
|
||||
Layout::Union(UnionLayout::NullableUnwrapped {
|
||||
nullable_id,
|
||||
other_fields,
|
||||
})
|
||||
}
|
||||
|
||||
layout => panic!("handle recursive layout: {:?}", layout),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue