-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9893 from som-snytt/topic/warn-nonunit-statement
Add `-Wnonunit-statement` to warn about discarded values in statement position
- Loading branch information
Showing
19 changed files
with
695 additions
and
41 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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
nonunit-if.scala:58: warning: discarded non-Unit value of type U | ||
if (!isEmpty) f(a) // warn, check is on | ||
^ | ||
nonunit-if.scala:62: warning: discarded non-Unit value of type Boolean | ||
f(a) // warn, check is on | ||
^ | ||
nonunit-if.scala:13: warning: unused value of type scala.concurrent.Future[Int] (add `: Unit` to discard silently) | ||
improved // warn | ||
^ | ||
nonunit-if.scala:20: warning: unused value of type String (add `: Unit` to discard silently) | ||
new E().toString // warn | ||
^ | ||
nonunit-if.scala:26: warning: unused value of type scala.concurrent.Future[Int] (add `: Unit` to discard silently) | ||
Future(42) // warn | ||
^ | ||
nonunit-if.scala:30: warning: unused value of type K (add `: Unit` to discard silently) | ||
copy() // warn | ||
^ | ||
nonunit-if.scala:37: warning: unused value of type List[Int] (add `: Unit` to discard silently) | ||
27 +: xs // warn | ||
^ | ||
nonunit-if.scala:44: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses | ||
null // warn for purity | ||
^ | ||
nonunit-if.scala:58: warning: unused value of type U (add `: Unit` to discard silently) | ||
if (!isEmpty) f(a) // warn, check is on | ||
^ | ||
nonunit-if.scala:62: warning: unused value of type Boolean (add `: Unit` to discard silently) | ||
f(a) // warn, check is on | ||
^ | ||
nonunit-if.scala:73: warning: unused value of type U (add `: Unit` to discard silently) | ||
if (!fellback) action(z) // warn, check is on | ||
^ | ||
nonunit-if.scala:81: warning: unused value of type Int (add `: Unit` to discard silently) | ||
g // warn, check is on | ||
^ | ||
nonunit-if.scala:79: warning: unused value of type Int (add `: Unit` to discard silently) | ||
g // warn block statement | ||
^ | ||
nonunit-if.scala:86: warning: unused value of type Int (add `: Unit` to discard silently) | ||
g // warn | ||
^ | ||
nonunit-if.scala:84: warning: unused value of type Int (add `: Unit` to discard silently) | ||
g // warn | ||
^ | ||
nonunit-if.scala:96: warning: unused value of type Int (add `: Unit` to discard silently) | ||
if (b) { // warn, at least one branch looks interesting | ||
^ | ||
nonunit-if.scala:116: warning: unused value of type scala.collection.mutable.LinkedHashSet[A] (add `: Unit` to discard silently) | ||
set += a // warn because cannot know whether the `set` was supposed to be consumed or assigned | ||
^ | ||
nonunit-if.scala:146: warning: unused value of type String (add `: Unit` to discard silently) | ||
while (it.hasNext) it.next() // warn | ||
^ | ||
error: No warnings can be incurred under -Werror. | ||
18 warnings | ||
1 error |
Oops, something went wrong.