diff --git a/crates/reporting/src/error/parse.rs b/crates/reporting/src/error/parse.rs index 88f8430899..c2bb472208 100644 --- a/crates/reporting/src/error/parse.rs +++ b/crates/reporting/src/error/parse.rs @@ -529,6 +529,24 @@ fn to_expr_report<'a>( EExpr::Ability(err, pos) => to_ability_def_report(alloc, lines, filename, err, *pos), + EExpr::IndentEnd(pos) => { + let surroundings = Region::new(start, *pos); + let region = LineColumnRegion::from_pos(lines.convert_pos(*pos)); + let doc = alloc.stack(vec![ + alloc.reflow(r"I am partway through parsing an expression, but I got stuck here:"), + alloc.region_with_subregion(lines.convert_region(surroundings), region), + alloc.concat(vec![alloc.reflow( + "Looks like the indentation ends prematurely after an expression", + )]), + ]); + + Report { + filename, + doc, + title: "INDENT ENDS AFTER EXPRESSION".to_string(), + severity: Severity::RuntimeError, + } + } _ => todo!("unhandled parse error: {:?}", parse_problem), } } diff --git a/crates/reporting/tests/test_reporting.rs b/crates/reporting/tests/test_reporting.rs index b51897eed5..7da6281105 100644 --- a/crates/reporting/tests/test_reporting.rs +++ b/crates/reporting/tests/test_reporting.rs @@ -4586,6 +4586,28 @@ mod test_reporting { "### ); + test_report!( + expression_indentation_end, + indoc!( + r#" + f <- Foo.foo + "# + ), + @r###" + ── INDENT ENDS AFTER EXPRESSION ────── tmp/expression_indentation_end/Test.roc ─ + + I am partway through parsing an expression, but I got stuck here: + + 1│ app "test" provides [main] to "./platform" + 2│ + 3│ main = + 4│ f <- Foo.foo + ^ + + Looks like the indentation ends prematurely after an expression + "### + ); + test_report!( type_inline_alias, indoc!(