Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add -Wnonunit-statement and -Wnonunit-if
Warn about any interesting value in statement position, for some definition of interest. Generalizes the current warning for "pure" expressions. By default, warns about unibranch if, which lack an else in user code. Specify -Wnonunit-if:false to turn off warning about unibranch if. (That also turns off -Wvalue-discard for those cases.) Improve explicit Unit check Accommodate field when method is this.type debug Handle Match
- Loading branch information
Showing
15 changed files
with
637 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
nonunit-if.scala:58: warning: discarded non-Unit value | ||
if (!isEmpty) f(a) // warn, check is on | ||
^ | ||
nonunit-if.scala:62: warning: discarded non-Unit value | ||
f(a) // warn, check is on | ||
^ | ||
nonunit-if.scala:13: warning: unused value | ||
improved // warn | ||
^ | ||
nonunit-if.scala:20: warning: unused value | ||
new E().toString // warn | ||
^ | ||
nonunit-if.scala:26: warning: unused value | ||
Future(42) // warn | ||
^ | ||
nonunit-if.scala:30: warning: unused value | ||
copy() // warn | ||
^ | ||
nonunit-if.scala:37: warning: unused value | ||
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 | ||
if (!isEmpty) f(a) // warn, check is on | ||
^ | ||
nonunit-if.scala:62: warning: unused value | ||
f(a) // warn, check is on | ||
^ | ||
nonunit-if.scala:73: warning: unused value | ||
if (!fellback) action(z) // warn, check is on | ||
^ | ||
nonunit-if.scala:81: warning: unused value | ||
g // warn, check is on | ||
^ | ||
nonunit-if.scala:79: warning: unused value | ||
g // warn block statement | ||
^ | ||
nonunit-if.scala:86: warning: unused value | ||
g // warn | ||
^ | ||
nonunit-if.scala:84: warning: unused value | ||
g // warn | ||
^ | ||
nonunit-if.scala:96: warning: unused value | ||
if (b) { // warn, at least one branch looks interesting | ||
^ | ||
nonunit-if.scala:116: warning: unused value | ||
set += a // warn because cannot know whether the `set` was supposed to be consumed or assigned | ||
^ | ||
nonunit-if.scala:146: warning: unused value | ||
while (it.hasNext) it.next() // warn | ||
^ | ||
error: No warnings can be incurred under -Werror. | ||
18 warnings | ||
1 error |
Oops, something went wrong.