Add error message when imports are missing

This commit is contained in:
Ananda Umamil 2022-03-27 13:46:27 +07:00
parent 1086189d76
commit 39feabe502
No known key found for this signature in database
GPG key ID: 163CE4CEA7F464B6
2 changed files with 27 additions and 1 deletions

View file

@ -3400,7 +3400,7 @@ fn to_imports_report<'a>(
}
}
EImports::Imports(pos) => {
EImports::Imports(pos) | EImports::IndentImports(pos) => {
let surroundings = Region::new(start, pos);
let region = LineColumnRegion::from_pos(lines.convert_pos(pos));

View file

@ -6138,6 +6138,32 @@ I need all branches in an `if` to have the same type!
)
}
#[test]
fn missing_imports() {
report_header_problem_as(
indoc!(
r#"
interface Foobar
exposes [ main, Foo ]
"#
),
indoc!(
r#"
WEIRD IMPORTS
I am partway through parsing a header, but I got stuck here:
2 exposes [ main, Foo ]
^
I am expecting the `imports` keyword next, like
imports [ Animal, default, tame ]
"#
),
)
}
#[test]
fn exposes_identifier() {
report_header_problem_as(