Fix unifying optional fields

This commit is contained in:
Richard Feldman 2020-07-18 14:16:46 -04:00
parent eb3ee8ffa3
commit 98a8bb8115
2 changed files with 43 additions and 2 deletions

View file

@ -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 }",
);
}
}