mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-20 15:27:45 +03:00
constrain the default
This commit is contained in:
parent
29c3eebace
commit
36574e6ff7
@ -246,7 +246,9 @@ pub fn constrain_pattern(
|
||||
|
||||
state.vars.push(*expr_var);
|
||||
|
||||
constrain_expr(env, loc_expr.region, &loc_expr.value, expr_expected);
|
||||
let expr_con =
|
||||
constrain_expr(env, loc_expr.region, &loc_expr.value, expr_expected);
|
||||
state.constraints.push(expr_con);
|
||||
|
||||
RecordField::Optional(pat_type)
|
||||
}
|
||||
|
@ -2641,4 +2641,32 @@ mod solve_expr {
|
||||
"{ x : Num a, y ? Num a }* -> Num a",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn optional_field_let() {
|
||||
infer_eq_without_problem(
|
||||
indoc!(
|
||||
r#"
|
||||
{ x, y ? 0 } = { x: 32 }
|
||||
|
||||
x + y
|
||||
"#
|
||||
),
|
||||
"Num *",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn optional_field_when() {
|
||||
infer_eq_without_problem(
|
||||
indoc!(
|
||||
r#"
|
||||
\r ->
|
||||
when r is
|
||||
{ x, y ? 0 } -> x + y
|
||||
"#
|
||||
),
|
||||
"{ x : Num a, y ? Num a }* -> Num a",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user