fix bug with lists and * type variables

This commit is contained in:
Folkert 2021-11-27 16:57:50 +01:00
parent 48368f4fba
commit 3d1035a11f

View File

@ -581,16 +581,22 @@ impl Layout {
Self::from_content(layouts, subs, var, content)
}
/// Used in situations where an unspecialized variable is not a problem,
/// and we can substitute with `[]`, the empty tag union.
/// e.g. an empty list literal has type `List *`. We can still generate code
/// in those cases by just picking any concrete type for the list element,
/// and we pick the empty tag union in practice.
fn from_var_help_or_void(
layouts: &mut Layouts,
subs: &Subs,
var: Variable,
) -> Result<Layout, LayoutError> {
let content = &subs.get_ref(var).content;
match Self::from_content(layouts, subs, var, content) {
Ok(layout) => Ok(layout),
Err(LayoutError::UnresolvedVariable(_)) => Ok(Layout::VOID),
Err(other) => Err(other),
match content {
Content::FlexVar(_) | Content::RigidVar(_) => Ok(Layout::VOID),
_ => Self::from_content(layouts, subs, var, content),
}
}