mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00:00
Merge remote-tracking branch 'origin/trunk' into list-get
This commit is contained in:
commit
9cc9789738
3 changed files with 22 additions and 8 deletions
|
@ -371,9 +371,22 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
||||||
|
|
||||||
// List module
|
// 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(
|
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(
|
SolvedType::Func(
|
||||||
vec![list_type(flex(TVAR1)), int_type()],
|
vec![list_type(flex(TVAR1)), int_type()],
|
||||||
Box::new(flex(TVAR1)),
|
Box::new(flex(TVAR1)),
|
||||||
|
|
|
@ -301,11 +301,6 @@ mod gen_builtins {
|
||||||
assert_evals_to!("List.isEmpty []", true, bool);
|
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]
|
#[test]
|
||||||
fn head_int_list() {
|
fn head_int_list() {
|
||||||
assert_evals_to!("List.first [ 12, 9, 6, 3 ]", (1, 12), (u64, i64));
|
assert_evals_to!("List.first [ 12, 9, 6, 3 ]", (1, 12), (u64, i64));
|
||||||
|
|
|
@ -495,7 +495,13 @@ impl FieldAccess {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_seen() -> Self {
|
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 {
|
pub fn list_update() -> Self {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue