Initial implementation of tuples in type checking

This leaves in place a bunch of TODOs and likely many bugs - notably, I haven't tested codegen/layout at all here.
This commit is contained in:
Joshua Warner 2022-12-25 19:26:32 -08:00
parent d57cb50425
commit de828416bf
No known key found for this signature in database
GPG key ID: 89AD497003F93FDD
32 changed files with 1785 additions and 112 deletions

View file

@ -2078,6 +2078,13 @@ fn lambda_set_size(subs: &Subs, var: Variable) -> (usize, usize, usize) {
}
stack.push((*ext, depth_any + 1, depth_lset));
}
FlatType::Tuple(elems, ext) => {
for var_index in elems.iter_variables() {
let var = subs[var_index];
stack.push((var, depth_any + 1, depth_lset));
}
stack.push((*ext, depth_any + 1, depth_lset));
}
FlatType::FunctionOrTagUnion(_, _, ext) => {
stack.push((ext.var(), depth_any + 1, depth_lset));
}
@ -2098,7 +2105,7 @@ fn lambda_set_size(subs: &Subs, var: Variable) -> (usize, usize, usize) {
}
stack.push((ext.var(), depth_any + 1, depth_lset));
}
FlatType::EmptyRecord | FlatType::EmptyTagUnion => {}
FlatType::EmptyRecord | FlatType::EmptyTuple | FlatType::EmptyTagUnion => {}
},
Content::FlexVar(_)
| Content::RigidVar(_)
@ -3176,6 +3183,9 @@ fn layout_from_flat_type<'a>(
Cacheable(result, criteria)
}
Tuple(_elems, _ext_var) => {
todo!();
}
TagUnion(tags, ext_var) => {
let (tags, ext_var) = tags.unsorted_tags_and_ext(subs, ext_var);
@ -3205,6 +3215,7 @@ fn layout_from_flat_type<'a>(
}
EmptyTagUnion => cacheable(Ok(Layout::VOID)),
EmptyRecord => cacheable(Ok(Layout::UNIT)),
EmptyTuple => cacheable(Ok(Layout::UNIT)),
}
}