Skip to content

Commit

Permalink
parser: correctly highlight the redundant parenthesees when emitting …
Browse files Browse the repository at this point in the history
…warnings
  • Loading branch information
feds01 committed Aug 31, 2023
1 parent 72beee8 commit 20a8df8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion compiler/hash-parser/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ impl<'stream, 'resolver> AstGen<'stream, 'resolver> {
if !matches!(expr.body(), Expr::BinaryExpr(_) | Expr::Cast(_) | Expr::FnDef(_)) {
self.add_warning(ParseWarning::new(
WarningKind::RedundantParenthesis(expr.body().into()),
expr.span(),
gen.span(),
));
}

Expand Down
12 changes: 6 additions & 6 deletions tests/cases/parser/blocks/parenthesised_match_statement.stderr
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
warn: unnecessary parentheses around block
--> $DIR/parenthesised_match_statement.hash:3:8
--> $DIR/parenthesised_match_statement.hash:3:7
2 |
3 | b := ((match some_struct {
| _________-
| ________-
4 | | Dog(name, age = 6) => match name {
5 | | "Viktor" => print("Viktor is 6"),
... |
10 | | Dog(name, age) => do_something_with_name(),
11 | | _ => unreachable()
12 | | }));
| |__-
| |___-

warn: unnecessary parentheses around block
--> $DIR/parenthesised_match_statement.hash:3:8
--> $DIR/parenthesised_match_statement.hash:3:6
2 |
3 | b := ((match some_struct {
| _________-
| _______-
4 | | Dog(name, age = 6) => match name {
5 | | "Viktor" => print("Viktor is 6"),
... |
10 | | Dog(name, age) => do_something_with_name(),
11 | | _ => unreachable()
12 | | }));
| |__-
| |____-

0 comments on commit 20a8df8

Please sign in to comment.