add final expression tip

This commit is contained in:
Anton-4 2024-09-26 20:17:35 +02:00 committed by GitHub
parent b003d716a9
commit 0a0bc897f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 3 deletions

View File

@ -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.
"###
);

View File

@ -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 {