Skip to content

Commit

Permalink
Cleanup pure statement warning
Browse files Browse the repository at this point in the history
The `you may be omitting necessary parentheses` hint in the message was
added when we used to get method references that became lambdas in statement
positions. Now these are an error and never reach this warning.
  • Loading branch information
nicolasstucki committed Oct 20, 2023
1 parent 7451a18 commit 5c43c66
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/reporting/messages.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2403,7 +2403,7 @@ class MemberWithSameNameAsStatic()(using Context)
class PureExpressionInStatementPosition(stat: untpd.Tree, val exprOwner: Symbol)(using Context)
extends Message(PureExpressionInStatementPositionID) {
def kind = MessageKind.PotentialIssue
def msg(using Context) = "A pure expression does nothing in statement position; you may be omitting necessary parentheses"
def msg(using Context) = "A pure expression does nothing in statement position"
def explain(using Context) =
i"""The pure expression $stat doesn't have any side effect and its result is not assigned elsewhere.
|It can be removed without changing the semantics of the program. This may indicate an error."""
Expand Down
2 changes: 1 addition & 1 deletion compiler/test-resources/repl/nowarn.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ scala> def f = { 1; 2 }
-- [E129] Potential Issue Warning: ---------------------------------------------
1 | def f = { 1; 2 }
| ^
|A pure expression does nothing in statement position; you may be omitting necessary parentheses
| A pure expression does nothing in statement position
|
| longer explanation available when compiling with `-explain`
def f: Int
2 changes: 1 addition & 1 deletion tests/neg-macros/annot-suspend-cycle.check
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- [E129] Potential Issue Warning: tests/neg-macros/annot-suspend-cycle/Macro.scala:7:4 --------------------------------
7 | new Foo
| ^^^^^^^
| A pure expression does nothing in statement position; you may be omitting necessary parentheses
| A pure expression does nothing in statement position
|
| longer explanation available when compiling with `-explain`
Cyclic macro dependencies in tests/neg-macros/annot-suspend-cycle/Test.scala.
Expand Down
2 changes: 1 addition & 1 deletion tests/neg/i18408a.check
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
-- [E129] Potential Issue Warning: tests/neg/i18408a.scala:4:16 --------------------------------------------------------
4 |def test2 = fa({42; ()})
| ^^
| A pure expression does nothing in statement position; you may be omitting necessary parentheses
| A pure expression does nothing in statement position
|
| longer explanation available when compiling with `-explain`
2 changes: 1 addition & 1 deletion tests/neg/i18408b.check
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
-- [E129] Potential Issue Warning: tests/neg/i18408b.scala:4:16 --------------------------------------------------------
4 |def test2 = fa({42; ()})
| ^^
| A pure expression does nothing in statement position; you may be omitting necessary parentheses
| A pure expression does nothing in statement position
|
| longer explanation available when compiling with `-explain`
2 changes: 1 addition & 1 deletion tests/neg/i18408c.check
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
-- [E129] Potential Issue Warning: tests/neg/i18408c.scala:4:16 --------------------------------------------------------
4 |def test2 = fa({42; ()})
| ^^
| A pure expression does nothing in statement position; you may be omitting necessary parentheses
| A pure expression does nothing in statement position
|
| longer explanation available when compiling with `-explain`
4 changes: 2 additions & 2 deletions tests/neg/nowarn.check
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Matching filters for @nowarn or -Wconf:
-- [E129] Potential Issue Warning: tests/neg/nowarn.scala:15:11 --------------------------------------------------------
15 |def t2 = { 1; 2 } // warning (the invalid nowarn doesn't silence anything)
| ^
| A pure expression does nothing in statement position; you may be omitting necessary parentheses
| A pure expression does nothing in statement position
|
| longer explanation available when compiling with `-explain`
-- Warning: tests/neg/nowarn.scala:14:8 --------------------------------------------------------------------------------
Expand All @@ -43,7 +43,7 @@ Matching filters for @nowarn or -Wconf:
-- [E129] Potential Issue Warning: tests/neg/nowarn.scala:18:12 --------------------------------------------------------
18 |def t2a = { 1; 2 } // warning (invalid nowarn doesn't silence)
| ^
| A pure expression does nothing in statement position; you may be omitting necessary parentheses
| A pure expression does nothing in statement position
|
| longer explanation available when compiling with `-explain`
-- Warning: tests/neg/nowarn.scala:17:8 --------------------------------------------------------------------------------
Expand Down

0 comments on commit 5c43c66

Please sign in to comment.