mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 20:28:02 +00:00
Unify ranged numbers with flex able, modulo obligation checking
Closes #4594
This commit is contained in:
parent
2a27d3c05f
commit
0bae0aafb6
2 changed files with 38 additions and 1 deletions
|
@ -650,7 +650,18 @@ fn unify_ranged_number<M: MetaCollector>(
|
|||
// Int a vs Int <range>, the rigid wins
|
||||
merge(env, ctx, RigidVar(*name))
|
||||
}
|
||||
RecursionVar { .. } | Alias(..) | Structure(..) | RigidAbleVar(..) | FlexAbleVar(..) => {
|
||||
FlexAbleVar(_, abilities) => {
|
||||
// Range wins, modulo obligation checking.
|
||||
merge_flex_able_with_concrete(
|
||||
env,
|
||||
ctx,
|
||||
ctx.second,
|
||||
*abilities,
|
||||
RangedNumber(range_vars),
|
||||
Obligated::Adhoc(ctx.first),
|
||||
)
|
||||
}
|
||||
RecursionVar { .. } | Alias(..) | Structure(..) | RigidAbleVar(..) => {
|
||||
check_and_merge_valid_range(env, pool, ctx, ctx.first, range_vars, ctx.second)
|
||||
}
|
||||
&RangedNumber(other_range_vars) => match range_vars.intersection(&other_range_vars) {
|
||||
|
|
|
@ -12572,4 +12572,30 @@ I recommend using camelCase. It's the standard style in Roc code!
|
|||
`crash` must be given exacly one message to crash with.
|
||||
"###
|
||||
);
|
||||
|
||||
test_no_problem!(
|
||||
resolve_eq_for_unbound_num,
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [main] to "./platform"
|
||||
|
||||
n : Num *
|
||||
|
||||
main = n == 1
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
test_no_problem!(
|
||||
resolve_hash_for_unbound_num,
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [main] to "./platform"
|
||||
|
||||
n : Num *
|
||||
|
||||
main = \hasher -> Hash.hash hasher n
|
||||
"#
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue