Skip to content

Commit

Permalink
add final expression tip
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton-4 authored Sep 26, 2024
1 parent b003d71 commit 0a0bc89
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
8 changes: 8 additions & 0 deletions crates/compiler/load/tests/test_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4339,6 +4339,14 @@ mod test_reporting {
However, I already saw the final expression in that series of
definitions.
Tip: An expression like `4`, `"hello"`, or `functionCall MyThing` is
like `return 4` in other programming languages. To me, it seems like
you did `return 4` followed by more code in the lines after, that code
would never be executed!
Tip: If you are working with `Task`, this error can happen if you
forgot a `!` somewhere.
"###
);

Expand Down
16 changes: 13 additions & 3 deletions crates/reporting/src/error/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,9 +653,19 @@ fn to_expr_report<'a>(
r"and this line is indented as if it's intended to be part of that expression:",
),
alloc.region_with_subregion(lines.convert_region(surroundings), region, severity),
alloc.concat([alloc.reflow(
"However, I already saw the final expression in that series of definitions.",
)]),
alloc.reflow(
"However, I already saw the final expression in that series of definitions."
),
alloc.tip().append(
alloc.reflow(
"An expression like `4`, `\"hello\"`, or `functionCall MyThing` is like `return 4` in other programming languages. To me, it seems like you did `return 4` followed by more code in the lines after, that code would never be executed!"
)
),
alloc.tip().append(
alloc.reflow(
"If you are working with `Task`, this error can happen if you forgot a `!` somewhere."
)
)
]);

Report {
Expand Down

0 comments on commit 0a0bc89

Please sign in to comment.