From d141237a17296cdd9ead3c1e73d1225a542f2f53 Mon Sep 17 00:00:00 2001 From: caryoscelus Date: Mon, 27 Nov 2023 19:10:24 +0000 Subject: [PATCH] Report lacking `to` while parsing app header --- crates/reporting/src/error/parse.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/crates/reporting/src/error/parse.rs b/crates/reporting/src/error/parse.rs index 2631bdf1f5..c4b03f8623 100644 --- a/crates/reporting/src/error/parse.rs +++ b/crates/reporting/src/error/parse.rs @@ -3515,6 +3515,31 @@ fn to_provides_report<'a>( EProvides::Space(error, pos) => to_space_report(alloc, lines, filename, &error, pos), + EProvides::IndentTo(pos) => { + let surroundings = Region::new(start, pos); + let region = LineColumnRegion::from_pos(lines.convert_pos(pos)); + + let doc = alloc.stack([ + alloc.reflow(r"I am partway through parsing a header, but I got stuck here:"), + alloc.region_with_subregion(lines.convert_region(surroundings), region), + alloc.concat([ + alloc.reflow("I am expecting the "), + alloc.keyword("to"), + alloc.reflow(" keyword next, like"), + ]), + alloc + .parser_suggestion("to pf") + .indent(4), + ]); + + Report { + filename, + doc, + title: "WEIRD PROVIDES".to_string(), + severity: Severity::RuntimeError, + } + } + _ => todo!("unhandled parse error {:?}", parse_problem), } }