diff --git a/crates/compiler/load/tests/test_reporting.rs b/crates/compiler/load/tests/test_reporting.rs index a0934600af..4b22355a93 100644 --- a/crates/compiler/load/tests/test_reporting.rs +++ b/crates/compiler/load/tests/test_reporting.rs @@ -5024,6 +5024,26 @@ mod test_reporting { I just saw the `exposing` keyword, so I was expecting to see `[` next. "###); + test_report!( + unfinished_import_exposing_name, + indoc!( + r" + import svg.Path exposing [3 + " + ), + @r###" + ── WEIRD EXPOSING in tmp/unfinished_import_exposing_name/Test.roc ────────────── + + I'm partway through parsing an exposing list, but I got stuck here: + + 4│ import svg.Path exposing [3 + ^ + + I was expecting a type, value, or function name next, like: + + import Svg exposing [Path, arc, rx] + "###); + test_report!( ingested_file_import_ann_syntax_err, indoc!( diff --git a/crates/reporting/src/error/parse.rs b/crates/reporting/src/error/parse.rs index f2c10d7b2c..0f638cf297 100644 --- a/crates/reporting/src/error/parse.rs +++ b/crates/reporting/src/error/parse.rs @@ -1545,8 +1545,27 @@ fn to_import_report<'a>( alloc.reflow(" next."), ]), ), - ExposedName(_) => todo!(), - ExposingListEnd(_) => todo!(), + ExposedName(pos) | ExposingListEnd(pos) => { + let surroundings = Region::new(start, *pos); + let region = LineColumnRegion::from_pos(lines.convert_pos(*pos)); + + let doc = alloc.stack([ + alloc + .reflow(r"I'm partway through parsing an exposing list, but I got stuck here:"), + alloc.region_with_subregion(lines.convert_region(surroundings), region), + alloc.reflow(r"I was expecting a type, value, or function name next, like:"), + alloc + .parser_suggestion("import Svg exposing [Path, arc, rx]") + .indent(4), + ]); + + Report { + filename, + doc, + title: "WEIRD EXPOSING".to_string(), + severity: Severity::RuntimeError, + } + } IndentIngestedName(_) => todo!(), IngestedName(_) => todo!(), IndentAnnotation(_) => todo!(),