Update Dict.walk to match List.walk

This commit is contained in:
Richard Feldman 2021-08-30 23:04:49 -04:00
parent 91165e1230
commit 71a678c092
3 changed files with 5 additions and 5 deletions

View file

@ -1090,17 +1090,17 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
Box::new(dict_type(flex(TVAR1), flex(TVAR2))),
);
// Dict.walk : Dict k v, (k, v, accum -> accum), accum -> accum
// Dict.walk : Dict k v, state, (state, k, v -> state) -> state
add_top_level_function_type!(
Symbol::DICT_WALK,
vec![
dict_type(flex(TVAR1), flex(TVAR2)),
flex(TVAR3),
closure(
vec![flex(TVAR1), flex(TVAR2), flex(TVAR3)],
vec![flex(TVAR3), flex(TVAR1), flex(TVAR2)],
TVAR4,
Box::new(flex(TVAR3)),
),
flex(TVAR3),
],
Box::new(flex(TVAR3)),
);

View file

@ -2371,7 +2371,7 @@ fn dict_intersection(symbol: Symbol, var_store: &mut VarStore) -> Def {
lowlevel_2(symbol, LowLevel::DictIntersection, var_store)
}
/// Dict.walk : Dict k v, (k, v, accum -> accum), accum -> accum
/// Dict.walk : Dict k v, state, (state, k, v -> state) -> state
fn dict_walk(symbol: Symbol, var_store: &mut VarStore) -> Def {
lowlevel_3(symbol, LowLevel::DictWalk, var_store)
}

View file

@ -502,7 +502,7 @@ fn walk_sum_keys() {
|> Dict.insert 4 4
|> Dict.insert 5 5
Dict.walk dict1 (\k, _, a -> k + a) 0
Dict.walk dict1 0 \k, _, a -> k + a
"#
),
15,