mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 07:14:46 +00:00
try harder to find a list element type
This commit is contained in:
parent
86ebad4d95
commit
b4f86c449f
1 changed files with 28 additions and 5 deletions
|
@ -1,8 +1,8 @@
|
||||||
use self::InProgressProc::*;
|
use self::InProgressProc::*;
|
||||||
use crate::exhaustive::{Ctor, Guard, RenderAs, TagId};
|
use crate::exhaustive::{Ctor, Guard, RenderAs, TagId};
|
||||||
use crate::layout::{
|
use crate::layout::{
|
||||||
BuildClosureData, Builtin, ClosureLayout, Layout, LayoutCache, LayoutProblem, UnionLayout,
|
BuildClosureData, Builtin, ClosureLayout, Layout, LayoutCache, LayoutProblem, MemoryMode,
|
||||||
WrappedVariant, TAG_SIZE,
|
UnionLayout, WrappedVariant, TAG_SIZE,
|
||||||
};
|
};
|
||||||
use bumpalo::collections::Vec;
|
use bumpalo::collections::Vec;
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
|
@ -3357,11 +3357,34 @@ pub fn with_hole<'a>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List { loc_elems, .. } if loc_elems.is_empty() => {
|
List {
|
||||||
|
loc_elems,
|
||||||
|
elem_var,
|
||||||
|
..
|
||||||
|
} if loc_elems.is_empty() => {
|
||||||
// because an empty list has an unknown element type, it is handled differently
|
// because an empty list has an unknown element type, it is handled differently
|
||||||
|
let opt_elem_layout = layout_cache.from_var(env.arena, elem_var, env.subs);
|
||||||
|
|
||||||
|
match opt_elem_layout {
|
||||||
|
Ok(elem_layout) => {
|
||||||
|
let expr = Expr::EmptyArray;
|
||||||
|
Stmt::Let(
|
||||||
|
assigned,
|
||||||
|
expr,
|
||||||
|
Layout::Builtin(Builtin::List(
|
||||||
|
MemoryMode::Refcounted,
|
||||||
|
env.arena.alloc(elem_layout),
|
||||||
|
)),
|
||||||
|
hole,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Err(LayoutProblem::UnresolvedTypeVar(_)) => {
|
||||||
let expr = Expr::EmptyArray;
|
let expr = Expr::EmptyArray;
|
||||||
Stmt::Let(assigned, expr, Layout::Builtin(Builtin::EmptyList), hole)
|
Stmt::Let(assigned, expr, Layout::Builtin(Builtin::EmptyList), hole)
|
||||||
}
|
}
|
||||||
|
Err(LayoutProblem::Erroneous) => panic!("list element is error type"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List {
|
List {
|
||||||
list_var,
|
list_var,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue