mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 13:59:08 +00:00
Fix unifying optional fields
This commit is contained in:
parent
eb3ee8ffa3
commit
98a8bb8115
2 changed files with 43 additions and 2 deletions
|
@ -2565,4 +2565,34 @@ mod solve_expr {
|
|||
"should fail",
|
||||
);
|
||||
}
|
||||
|
||||
// OPTIONAL RECORD FIELDS
|
||||
|
||||
#[test]
|
||||
fn optional_field_unifies_with_missing() {
|
||||
infer_eq_without_problem(
|
||||
indoc!(
|
||||
r#"
|
||||
negatePoint : { x : Int, y : Int, z ? Num c } -> { x : Int, y : Int, z : Num c }
|
||||
|
||||
negatePoint { x: 1, y: 2 }
|
||||
"#
|
||||
),
|
||||
"{ x : Int, y : Int, z : Num c }",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn optional_field_unifies_with_present() {
|
||||
infer_eq_without_problem(
|
||||
indoc!(
|
||||
r#"
|
||||
negatePoint : { x : Num a, y : Num b, z ? c } -> { x : Num a, y : Num b, z : c }
|
||||
|
||||
negatePoint { x: 1, y: 2.1, z: 0x3 }
|
||||
"#
|
||||
),
|
||||
"{ x : Num a, y : Float, z : Int }",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue