mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
fix final list test
This commit is contained in:
parent
1ee1a8114b
commit
d25b1dc549
4 changed files with 36 additions and 26 deletions
|
@ -144,12 +144,10 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
);
|
||||
|
||||
// sub or (-) : Num a, Num a -> Num a
|
||||
add_type!(
|
||||
add_top_level_function_type!(
|
||||
Symbol::NUM_SUB,
|
||||
top_level_function(
|
||||
vec![num_type(flex(TVAR1)), num_type(flex(TVAR1))],
|
||||
Box::new(num_type(flex(TVAR1))),
|
||||
),
|
||||
);
|
||||
|
||||
// subWrap : Int range, Int range -> Int range
|
||||
|
@ -391,12 +389,10 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
);
|
||||
|
||||
// mod : Int a, Int a -> Result (Int a) [ DivByZero ]*
|
||||
add_type!(
|
||||
add_top_level_function_type!(
|
||||
Symbol::NUM_MOD_INT,
|
||||
top_level_function(
|
||||
vec![int_type(flex(TVAR1)), int_type(flex(TVAR1))],
|
||||
Box::new(result_type(int_type(flex(TVAR1)), div_by_zero.clone())),
|
||||
),
|
||||
);
|
||||
|
||||
// isMultipleOf : Int a, Int a -> Bool
|
||||
|
@ -850,9 +846,11 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
});
|
||||
|
||||
// keepErrs: List before, (before -> Result * after) -> List after
|
||||
add_type!(Symbol::LIST_KEEP_ERRS, {
|
||||
{
|
||||
let_tvars! { star, cvar, before, after};
|
||||
top_level_function(
|
||||
|
||||
add_top_level_function_type!(
|
||||
Symbol::LIST_KEEP_ERRS,
|
||||
vec![
|
||||
list_type(flex(before)),
|
||||
closure(
|
||||
|
@ -863,7 +861,7 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
],
|
||||
Box::new(list_type(flex(after))),
|
||||
)
|
||||
});
|
||||
};
|
||||
|
||||
// range : Int a, Int a -> List (Int a)
|
||||
add_type!(Symbol::LIST_RANGE, {
|
||||
|
@ -910,11 +908,12 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
)
|
||||
});
|
||||
|
||||
// map3 : List a, List b, List c, (a, b, c -> d) -> List d
|
||||
add_type!(Symbol::LIST_MAP3, {
|
||||
{
|
||||
let_tvars! {a, b, c, d, cvar};
|
||||
|
||||
top_level_function(
|
||||
// map3 : List a, List b, List c, (a, b, c -> d) -> List d
|
||||
add_top_level_function_type!(
|
||||
Symbol::LIST_MAP3,
|
||||
vec![
|
||||
list_type(flex(a)),
|
||||
list_type(flex(b)),
|
||||
|
@ -923,7 +922,7 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
],
|
||||
Box::new(list_type(flex(d))),
|
||||
)
|
||||
});
|
||||
};
|
||||
|
||||
// append : List elem, elem -> List elem
|
||||
add_type!(
|
||||
|
@ -1263,15 +1262,13 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
);
|
||||
|
||||
// mapErr : Result a x, (x -> y) -> Result a x
|
||||
add_type!(
|
||||
add_top_level_function_type!(
|
||||
Symbol::RESULT_MAP_ERR,
|
||||
top_level_function(
|
||||
vec![
|
||||
result_type(flex(TVAR1), flex(TVAR3)),
|
||||
closure(vec![flex(TVAR3)], TVAR4, Box::new(flex(TVAR2))),
|
||||
],
|
||||
Box::new(result_type(flex(TVAR1), flex(TVAR2))),
|
||||
),
|
||||
);
|
||||
|
||||
// after : Result a err, (a -> Result b err) -> Result b err
|
||||
|
|
|
@ -3069,6 +3069,8 @@ pub fn build_proc_header_new<'a, 'ctx, 'env>(
|
|||
) -> FunctionValue<'ctx> {
|
||||
let layout = env.arena.alloc(layout).full();
|
||||
|
||||
dbg!(symbol, layout);
|
||||
|
||||
build_proc_header(env, layout_ids, symbol, &layout, proc)
|
||||
}
|
||||
|
||||
|
|
|
@ -7524,6 +7524,7 @@ fn lowlevel_match_on_lambda_set<'a, F>(
|
|||
where
|
||||
F: Fn(Symbol, Symbol) -> Call<'a> + Copy,
|
||||
{
|
||||
dbg!(lambda_set);
|
||||
match dbg!(lambda_set.runtime_representation()) {
|
||||
Layout::Union(_) => {
|
||||
let closure_tag_id_symbol = env.unique_symbol();
|
||||
|
|
|
@ -1807,10 +1807,20 @@ fn list_keep_errs() {
|
|||
assert_evals_to!("List.keepErrs [] (\\x -> x)", 0, i64);
|
||||
assert_evals_to!("List.keepErrs [1,2] (\\x -> Err x)", &[1, 2], &[i64]);
|
||||
assert_evals_to!(
|
||||
"List.keepErrs [0,1,2] (\\x -> x % 0 |> Result.mapErr (\\_ -> 32))",
|
||||
indoc!(
|
||||
r#"
|
||||
mapErr = \result, f ->
|
||||
when result is
|
||||
Err e -> Err ( f e )
|
||||
Ok v -> Ok v
|
||||
|
||||
List.keepErrs [0,1,2] (\x -> x % 0 |> mapErr (\_ -> 32))
|
||||
"#
|
||||
),
|
||||
&[32, 32, 32],
|
||||
&[i64]
|
||||
);
|
||||
|
||||
assert_evals_to!("List.keepErrs [Ok 1, Err 2] (\\x -> x)", &[2], &[i64]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue