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

@ -182,6 +182,14 @@ fn index_var(
return Ok(field_types);
}
FlatType::Tuple(elems, ext) => {
let elem_types = elems
.sorted_iterator(subs, *ext)
.map(|(_, elem)| elem)
.collect();
return Ok(elem_types);
}
FlatType::TagUnion(tags, ext) | FlatType::RecursiveTagUnion(_, tags, ext) => {
let tag_ctor = match ctor {
IndexCtor::Tag(name) => name,
@ -213,6 +221,9 @@ fn index_var(
};
return Ok(std::iter::repeat(Variable::NULL).take(num_fields).collect());
}
FlatType::EmptyTuple => {
return Ok(std::iter::repeat(Variable::NULL).take(0).collect());
}
FlatType::EmptyTagUnion => {
internal_error!("empty tag unions are not indexable")
}