fix formatting issue

This commit is contained in:
Folkert 2021-02-14 16:09:59 +01:00
parent 02e161f839
commit c4e606bcc6
2 changed files with 36 additions and 2 deletions

View file

@ -1620,8 +1620,8 @@ fn to_diff<'b>(
pair => { pair => {
// We hit none of the specific cases where we give more detailed information // We hit none of the specific cases where we give more detailed information
let left = to_doc(alloc, Parens::Unnecessary, type1); let left = to_doc(alloc, parens, type1);
let right = to_doc(alloc, Parens::Unnecessary, type2); let right = to_doc(alloc, parens, type2);
let is_int = |t: &ErrorType| match t { let is_int = |t: &ErrorType| match t {
ErrorType::Type(Symbol::NUM_INT, _) => true, ErrorType::Type(Symbol::NUM_INT, _) => true,

View file

@ -4703,4 +4703,38 @@ mod test_reporting {
), ),
) )
} }
#[test]
fn dict_type_formatting() {
// TODO could do better by pointing out we're parsing a function type
report_problem_as(
indoc!(
r#"
myDict : Dict I64 Str
myDict = Dict.insert Dict.empty "foo" 42
myDict
"#
),
indoc!(
r#"
TYPE MISMATCH
Something is off with the body of the `myDict` definition:
1 myDict : Dict I64 Str
2 myDict = Dict.insert Dict.empty "foo" 42
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This `insert` call produces:
Dict Str (Num a)
But the type annotation on `myDict` says it should be:
Dict I64 Str
"#
),
)
}
} }