From 2d1a1621c32db9ba0ef51bf1cc94f29f04545b4b Mon Sep 17 00:00:00 2001 From: Folkert Date: Tue, 7 Apr 2020 13:35:38 +0200 Subject: [PATCH] add NoExpectation type error --- compiler/reporting/src/type_error.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/compiler/reporting/src/type_error.rs b/compiler/reporting/src/type_error.rs index f228535b17..3f46285e95 100644 --- a/compiler/reporting/src/type_error.rs +++ b/compiler/reporting/src/type_error.rs @@ -130,7 +130,23 @@ fn to_expr_report( match expected { Expected::NoExpectation(expected_type) => { - todo!("hit no expectation with type {:?}", expected_type) + let comparison = type_comparison( + found, + expected_type, + add_category(plain_text("It is"), &category), + plain_text("But you are trying to use it as:"), + Concat(vec![]), + ); + + Report { + filename, + title: "TYPE MISMATCH".to_string(), + text: Concat(vec![ + plain_text("This expression is used in an unexpected way:"), + Region(expr_region), + comparison, + ]), + } } Expected::FromAnnotation(name, _arity, annotation_source, expected_type) => { use roc_types::types::AnnotationSource::*;