New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SI-9847 Nuance pure expr statement warning #5266
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
t1181.scala:8: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses | ||
case (Nil, Nil) => map | ||
^ | ||
t1181.scala:9: error: type mismatch; | ||
found : scala.collection.immutable.Map[Symbol,Symbol] | ||
required: Symbol | ||
_ => buildMap(map.updated(keyList.head, valueList.head), keyList.tail, valueList.tail) | ||
^ | ||
t1181.scala:8: warning: a pure expression does nothing in statement position; multiline expressions might require enclosing parentheses | ||
case (Nil, Nil) => map | ||
^ | ||
one warning found | ||
one error found |
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,45 @@ | ||
t9847.scala:4: warning: discarded non-Unit value | ||
def f(): Unit = 42 | ||
^ | ||
t9847.scala:4: warning: a pure expression does nothing in statement position | ||
def f(): Unit = 42 | ||
^ | ||
t9847.scala:5: warning: discarded non-Unit value | ||
def g = (42: Unit) | ||
^ | ||
t9847.scala:5: warning: a pure expression does nothing in statement position | ||
def g = (42: Unit) | ||
^ | ||
t9847.scala:7: warning: a pure expression does nothing in statement position; multiline expressions might require enclosing parentheses | ||
1 | ||
^ | ||
t9847.scala:12: warning: discarded non-Unit value | ||
+ 1 | ||
^ | ||
t9847.scala:12: warning: a pure expression does nothing in statement position | ||
+ 1 | ||
^ | ||
t9847.scala:11: warning: a pure expression does nothing in statement position; multiline expressions might require enclosing parentheses | ||
1 | ||
^ | ||
t9847.scala:12: warning: multiline expressions might require enclosing parentheses; a value can be silently discarded when Unit is expected | ||
+ 1 | ||
^ | ||
t9847.scala:16: warning: discarded non-Unit value | ||
x + 1 | ||
^ | ||
t9847.scala:19: warning: discarded non-Unit value | ||
def j(): Unit = x + 1 | ||
^ | ||
t9847.scala:21: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses | ||
class C { 42 } | ||
^ | ||
t9847.scala:22: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses | ||
class D { 42 ; 17 } | ||
^ | ||
t9847.scala:22: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses | ||
class D { 42 ; 17 } | ||
^ | ||
error: No warnings can be incurred under -Xfatal-warnings. | ||
14 warnings found | ||
one error found |
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 @@ | ||
-Xfatal-warnings -Ywarn-value-discard |
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,23 @@ | ||
|
||
trait T { | ||
|
||
def f(): Unit = 42 | ||
def g = (42: Unit) | ||
def h = { | ||
1 | ||
+ 1 | ||
} | ||
def hh(): Unit = { | ||
1 | ||
+ 1 | ||
} | ||
def i(): Unit = { | ||
val x = 1 | ||
x + 1 | ||
} | ||
def x = 42 | ||
def j(): Unit = x + 1 | ||
|
||
class C { 42 } | ||
class D { 42 ; 17 } | ||
} |
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
contrib674.scala:15: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses | ||
contrib674.scala:15: warning: a pure expression does nothing in statement position | ||
1 | ||
^ | ||
contrib674.scala:15: warning: multiline expressions might require enclosing parentheses; a value can be silently discarded when Unit is expected | ||
1 | ||
^ |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Test_2.scala:5: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses | ||
Test_2.scala:5: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses | ||
Macros.foo | ||
^ |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't there some logic in place to only report a single warning per position?
I wonder why we get both warnings here. With M5 I don't get the
discarded non-Unit value
one:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AbstractReporter suppresses multiple ERROR or lower-priority messages (warnings in presence of errors).
The value discard is a flag: