Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give better error messages when provides is missing in header #5623

Merged
merged 3 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/reporting/src/error/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3469,7 +3469,7 @@ fn to_provides_report<'a>(
}
}

EProvides::Provides(pos) => {
EProvides::Provides(pos) | EProvides::IndentProvides(pos) => {
let surroundings = Region::new(start, pos);
let region = LineColumnRegion::from_pos(lines.convert_pos(pos));

Expand Down
34 changes: 34 additions & 0 deletions crates/reporting/tests/test_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5938,6 +5938,40 @@ In roc, functions are always written as a lambda, like{}
)
}

#[test]
fn missing_provides_in_app_header() {
report_header_problem_as(
indoc!(
r#"
app "broken"
packages {
pf: "https://github.com/roc-lang/basic-cli/releases/download/0.3.2/tE4xS_zLdmmxmHwHih9kHWQ7fsXtJr7W7h3425-eZFk.tar.br",
}
imports [
pf.Stdout,
]

main =
Stdout.line "answer"
"#
),
indoc!(
r#"
── WEIRD PROVIDES ──────────────────────────────────────── /code/proj/Main.roc ─

I am partway through parsing a header, but I got stuck here:

7│ ]
^

I am expecting the `provides` keyword next, like

provides [Animal, default, tame]
"#
),
)
}

#[test]
fn platform_requires_rigids() {
report_header_problem_as(
Expand Down