From c4e606bcc6c776ddcbff8f8b6581d7b7c1b9e497 Mon Sep 17 00:00:00 2001 From: Folkert Date: Sun, 14 Feb 2021 16:09:59 +0100 Subject: [PATCH] fix formatting issue --- compiler/reporting/src/error/type.rs | 4 +-- compiler/reporting/tests/test_reporting.rs | 34 ++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/compiler/reporting/src/error/type.rs b/compiler/reporting/src/error/type.rs index c80e4088bd..2ed9c4c437 100644 --- a/compiler/reporting/src/error/type.rs +++ b/compiler/reporting/src/error/type.rs @@ -1620,8 +1620,8 @@ fn to_diff<'b>( pair => { // We hit none of the specific cases where we give more detailed information - let left = to_doc(alloc, Parens::Unnecessary, type1); - let right = to_doc(alloc, Parens::Unnecessary, type2); + let left = to_doc(alloc, parens, type1); + let right = to_doc(alloc, parens, type2); let is_int = |t: &ErrorType| match t { ErrorType::Type(Symbol::NUM_INT, _) => true, diff --git a/compiler/reporting/tests/test_reporting.rs b/compiler/reporting/tests/test_reporting.rs index 80b455d3b2..f4f9c0f8b2 100644 --- a/compiler/reporting/tests/test_reporting.rs +++ b/compiler/reporting/tests/test_reporting.rs @@ -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 + "# + ), + ) + } }