forked from chapel-lang/chapel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chplcheck: warn for unused pattern matching like
(_, _)
(chapel-lan…
…g#24859) Fixes chapel-lang#24838. I believe it's better to warn about unused pattern matching separately from unused loop indices (one might avoid one but not the other), so this PR adds a new rule. This rule has an auto-fixit so you can turn unused `(_, _)` into `_` automatically. Reviewed by @jabraham17 -- thanks! ## Testing - [x] dyno tests - [x] `test/chplcheck`
- Loading branch information
Showing
7 changed files
with
90 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
foreach (i, _) in zip(1..10, 1..10) { i; } | ||
foreach (_, j) in zip(1..10, 1..10) { j; } | ||
foreach (_, _) in zip(1..10, 1..10) {} | ||
foreach (i, (_, _)) in zip(1..10, foreach pair in zip(1..10, 1..10) do pair) { i; } | ||
foreach (_, (_, _)) in zip(1..10, foreach pair in zip(1..10, 1..10) do pair) { i; } | ||
foreach ((_, _), _) in zip(foreach pair in zip(1..10, 1..10) do pair, 1..10) { i; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
UnusedTupleUnpack.chpl:1: node violates rule UseExplicitModules | ||
UnusedTupleUnpack.chpl:3: node violates rule UnusedTupleUnpack | ||
UnusedTupleUnpack.chpl:4: node violates rule UnusedTupleUnpack | ||
UnusedTupleUnpack.chpl:5: node violates rule UnusedTupleUnpack | ||
UnusedTupleUnpack.chpl:5: node violates rule UnusedTupleUnpack | ||
UnusedTupleUnpack.chpl:6: node violates rule UnusedTupleUnpack | ||
UnusedTupleUnpack.chpl:6: node violates rule UnusedTupleUnpack | ||
[Success matching fixit for UnusedTupleUnpack] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
foreach (i, _) in zip(1..10, 1..10) { i; } | ||
foreach (_, j) in zip(1..10, 1..10) { j; } | ||
foreach zip(1..10, 1..10) {} | ||
foreach (i, _) in zip(1..10, foreach pair in zip(1..10, 1..10) do pair) { i; } | ||
foreach (_, _) in zip(1..10, foreach pair in zip(1..10, 1..10) do pair) { i; } | ||
foreach (_, _) in zip(foreach pair in zip(1..10, 1..10) do pair, 1..10) { i; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters