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)),