Merge remote-tracking branch 'origin/trunk' into list-get

This commit is contained in:
Richard Feldman 2020-04-26 08:46:24 -04:00
commit 9cc9789738
3 changed files with 22 additions and 8 deletions

View file

@ -371,9 +371,22 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
// List module
// #getUnsafe : List elem, Int -> elem
// get : List elem, Int -> Result elem [ IndexOutOfBounds ]*
let index_out_of_bounds = SolvedType::TagUnion(
vec![(TagName::Global("IndexOutOfBounds".into()), vec![])],
Box::new(SolvedType::Wildcard),
);
add_type(
Symbol::LIST_GET_UNSAFE,
Symbol::LIST_GET,
SolvedType::Func(
vec![list_type(flex(TVAR1)), int_type()],
Box::new(result_type(flex(TVAR1), index_out_of_bounds)),
),
);
add_type(
Symbol::LIST_GET_UNSAFE, // TODO remove this once we can code gen Result
SolvedType::Func(
vec![list_type(flex(TVAR1)), int_type()],
Box::new(flex(TVAR1)),

View file

@ -301,11 +301,6 @@ mod gen_builtins {
assert_evals_to!("List.isEmpty []", true, bool);
}
// #[test]
// fn get_0_int_list() {
// assert_evals_to!("List.get [ 12, 9, 6, 3 ] 0", (1, 12), (u64, i64));
// }
#[test]
fn head_int_list() {
assert_evals_to!("List.first [ 12, 9, 6, 3 ]", (1, 12), (u64, i64));

View file

@ -495,7 +495,13 @@ impl FieldAccess {
}
pub fn list_seen() -> Self {
Self::default()
use Mark::*;
use Usage::*;
let mut result = Self::default();
result.fields.insert(LIST_ELEM.into(), Simple(Seen));
result
}
pub fn list_update() -> Self {