Merge pull request #7408 from jaredramirez/jared/improve-module-error

Handle parse error for bad head exposes list
This commit is contained in:
Sam Mohr 2025-01-03 05:10:07 -05:00 committed by GitHub
commit 786488fc34
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 135 additions and 17 deletions

View file

@ -6432,6 +6432,82 @@ All branches in an `if` must have the same type!
)
}
#[test]
fn exposes_start() {
report_header_problem_as(
indoc!(
r"
module foobar []
"
),
indoc!(
r#"
WEIRD EXPOSES in /code/proj/Main.roc
I am partway through parsing a header, but I got stuck here:
1 module foobar []
^
I was expecting an `exposes` list like
[Animal, default, tame]
"#
),
)
}
#[test]
fn exposes_missing_comma() {
report_header_problem_as(
indoc!(
r"
module [value func]
"
),
indoc!(
r#"
WEIRD EXPOSES in /code/proj/Main.roc
I am partway through parsing an `exposes` list, but I got stuck here:
1 module [value func]
^
I was expecting a type name, value name or function name next, like
[Animal, default, tame]
"#
),
)
}
#[test]
fn exposes_end() {
report_header_problem_as(
indoc!(
r"
module [value
"
),
indoc!(
r#"
WEIRD EXPOSES in /code/proj/Main.roc
I am partway through parsing an `exposes` list, but I got stuck here:
1 module [value
2
^
I was expecting a type name, value name or function name next, like
[Animal, default, tame]
"#
),
)
}
#[test]
fn invalid_app_name() {
report_header_problem_as(