Report ingested file name syntax error

This commit is contained in:
Agus Zubiaga 2024-05-06 23:42:28 -03:00
parent 755e16cb10
commit 27a9f6051e
No known key found for this signature in database
2 changed files with 34 additions and 2 deletions

View file

@ -5044,6 +5044,27 @@ mod test_reporting {
import Svg exposing [Path, arc, rx] import Svg exposing [Path, arc, rx]
"###); "###);
test_report!(
unfinished_ingested_file_name,
indoc!(
r#"
import "example.json" as
"#
),
@r###"
UNFINISHED IMPORT in tmp/unfinished_ingested_file_name/Test.roc
I was partway through parsing an `import`, but I got stuck here:
4 import "example.json" as
^
I was expecting to see a name next, like:
import "users.json" as users : Str
"###
);
test_report!( test_report!(
ingested_file_import_ann_syntax_err, ingested_file_import_ann_syntax_err,
indoc!( indoc!(

View file

@ -1566,8 +1566,19 @@ fn to_import_report<'a>(
severity: Severity::RuntimeError, severity: Severity::RuntimeError,
} }
} }
IndentIngestedName(_) => todo!(), IndentIngestedName(pos) | IngestedName(pos) => to_unfinished_import_report(
IngestedName(_) => todo!(), alloc,
lines,
filename,
*pos,
start,
alloc.stack([
alloc.reflow("I was expecting to see a name next, like:"),
alloc
.parser_suggestion("import \"users.json\" as users : Str")
.indent(4),
]),
),
IndentAnnotation(_) => todo!(), IndentAnnotation(_) => todo!(),
Annotation(problem, pos) => to_type_report(alloc, lines, filename, problem, *pos), Annotation(problem, pos) => to_type_report(alloc, lines, filename, problem, *pos),
IndentColon(_) => todo!(), IndentColon(_) => todo!(),