From b982f8f090e0a3b0a23ef7fcf9270c9655ae6811 Mon Sep 17 00:00:00 2001 From: Wojciech Mazur Date: Fri, 21 Jun 2024 23:57:41 +0200 Subject: [PATCH 1/3] Improve message for discarded pure non-Unit values Fixes #18408 Fixes #18722 [Cherry-picked 7451a18e91026b651f355ea1a279222e26b81f8d][modified] --- .../dotty/tools/dotc/reporting/messages.scala | 10 +++++ .../src/dotty/tools/dotc/typer/Typer.scala | 6 ++- tests/neg-custom-args/captures/real-try.check | 6 +-- tests/neg/i18408a.check | 18 ++++++++ tests/neg/i18408a.scala | 4 ++ tests/neg/i18408b.check | 18 ++++++++ tests/neg/i18408b.scala | 4 ++ tests/neg/i18408c.check | 18 ++++++++ tests/neg/i18408c.scala | 4 ++ tests/neg/i18722.check | 44 +++++++++++++++++++ tests/neg/i18722.scala | 9 ++++ tests/neg/spaces-vs-tabs.check | 4 +- tests/neg/syntax-error-recovery.check | 24 +++++----- 13 files changed, 150 insertions(+), 19 deletions(-) create mode 100644 tests/neg/i18408a.check create mode 100644 tests/neg/i18408a.scala create mode 100644 tests/neg/i18408b.check create mode 100644 tests/neg/i18408b.scala create mode 100644 tests/neg/i18408c.check create mode 100644 tests/neg/i18408c.scala create mode 100644 tests/neg/i18722.check create mode 100644 tests/neg/i18722.scala diff --git a/compiler/src/dotty/tools/dotc/reporting/messages.scala b/compiler/src/dotty/tools/dotc/reporting/messages.scala index 5da5bd187d69..bc87e40d5e42 100644 --- a/compiler/src/dotty/tools/dotc/reporting/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/messages.scala @@ -2386,6 +2386,16 @@ class PureExpressionInStatementPosition(stat: untpd.Tree, val exprOwner: Symbol) |It can be removed without changing the semantics of the program. This may indicate an error.""" } +class PureUnitExpression(stat: untpd.Tree, tpe: Type)(using Context) + extends Message(PureUnitExpressionID) { + def kind = MessageKind.PotentialIssue + def msg(using Context) = i"Discarded non-Unit value of type ${tpe.widen}. You may want to use `()`." + def explain(using Context) = + i"""As this expression is not of type Unit, it is desugared into `{ $stat; () }`. + |Here the `$stat` expression is a pure statement that can be discarded. + |Therefore the expression is effectively equivalent to `()`.""" +} + class UnqualifiedCallToAnyRefMethod(stat: untpd.Tree, method: Symbol)(using Context) extends Message(UnqualifiedCallToAnyRefMethodID) { def kind = MessageKind.PotentialIssue diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index dfb7fd4a442e..3a1406cfaf8c 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -4127,7 +4127,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer // local adaptation makes sure every adapted tree conforms to its pt // so will take the code path that decides on inlining val tree1 = adapt(tree, WildcardType, locked) - checkStatementPurity(tree1)(tree, ctx.owner) + checkStatementPurity(tree1)(tree, ctx.owner, isUnitExpr = true) if (!ctx.isAfterTyper && !tree.isInstanceOf[Inlined] && ctx.settings.WvalueDiscard.value && !isThisTypeResult(tree)) { report.warning(ValueDiscarding(tree.tpe), tree.srcPos) } @@ -4424,7 +4424,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer else false } - private def checkStatementPurity(tree: tpd.Tree)(original: untpd.Tree, exprOwner: Symbol)(using Context): Unit = + private def checkStatementPurity(tree: tpd.Tree)(original: untpd.Tree, exprOwner: Symbol, isUnitExpr: Boolean = false)(using Context): Unit = if !tree.tpe.isErroneous && !ctx.isAfterTyper && !tree.isInstanceOf[Inlined] @@ -4442,6 +4442,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer // sometimes we do not have the original anymore and use the transformed tree instead. // But taken together, the two criteria are quite accurate. missingArgs(tree, tree.tpe.widen) + case _ if isUnitExpr => + report.warning(PureUnitExpression(original, tree.tpe), original.srcPos) case _ => report.warning(PureExpressionInStatementPosition(original, exprOwner), original.srcPos) diff --git a/tests/neg-custom-args/captures/real-try.check b/tests/neg-custom-args/captures/real-try.check index c8df3777bcfa..f2cdf4b49b15 100644 --- a/tests/neg-custom-args/captures/real-try.check +++ b/tests/neg-custom-args/captures/real-try.check @@ -1,7 +1,7 @@ --- [E129] Potential Issue Warning: tests/neg-custom-args/captures/real-try.scala:30:4 ---------------------------------- -30 | b.x +-- [E190] Potential Issue Warning: tests/neg-custom-args/captures/real-try.scala:36:4 ---------------------------------- +36 | b.x | ^^^ - | A pure expression does nothing in statement position; you may be omitting necessary parentheses + | Discarded non-Unit value of type () -> Unit. You may want to use `()`. | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/real-try.scala:12:2 ----------------------------------------------------------- diff --git a/tests/neg/i18408a.check b/tests/neg/i18408a.check new file mode 100644 index 000000000000..fbd67ef3052a --- /dev/null +++ b/tests/neg/i18408a.check @@ -0,0 +1,18 @@ +-- [E103] Syntax Error: tests/neg/i18408a.scala:2:0 -------------------------------------------------------------------- +2 |fa(42) // error + |^^ + |Illegal start of toplevel definition + | + | longer explanation available when compiling with `-explain` +-- [E190] Potential Issue Warning: tests/neg/i18408a.scala:3:15 -------------------------------------------------------- +3 |def test1 = fa(42) + | ^^ + | Discarded non-Unit value of type Int. You may want to use `()`. + | + | longer explanation available when compiling with `-explain` +-- [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 + | + | longer explanation available when compiling with `-explain` diff --git a/tests/neg/i18408a.scala b/tests/neg/i18408a.scala new file mode 100644 index 000000000000..2ad64d94e2ce --- /dev/null +++ b/tests/neg/i18408a.scala @@ -0,0 +1,4 @@ +def fa(f: String ?=> Unit): Unit = ??? +fa(42) // error +def test1 = fa(42) +def test2 = fa({42; ()}) diff --git a/tests/neg/i18408b.check b/tests/neg/i18408b.check new file mode 100644 index 000000000000..2bfc8c24f1dd --- /dev/null +++ b/tests/neg/i18408b.check @@ -0,0 +1,18 @@ +-- [E103] Syntax Error: tests/neg/i18408b.scala:2:0 -------------------------------------------------------------------- +2 |fa(42) // error + |^^ + |Illegal start of toplevel definition + | + | longer explanation available when compiling with `-explain` +-- [E190] Potential Issue Warning: tests/neg/i18408b.scala:3:15 -------------------------------------------------------- +3 |def test1 = fa(42) + | ^^ + | Discarded non-Unit value of type Int. You may want to use `()`. + | + | longer explanation available when compiling with `-explain` +-- [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 + | + | longer explanation available when compiling with `-explain` diff --git a/tests/neg/i18408b.scala b/tests/neg/i18408b.scala new file mode 100644 index 000000000000..1cbe5474eb92 --- /dev/null +++ b/tests/neg/i18408b.scala @@ -0,0 +1,4 @@ +def fa(f: => Unit): Unit = ??? +fa(42) // error +def test1 = fa(42) +def test2 = fa({42; ()}) diff --git a/tests/neg/i18408c.check b/tests/neg/i18408c.check new file mode 100644 index 000000000000..2e8a279764d6 --- /dev/null +++ b/tests/neg/i18408c.check @@ -0,0 +1,18 @@ +-- [E103] Syntax Error: tests/neg/i18408c.scala:2:0 -------------------------------------------------------------------- +2 |fa(42) // error + |^^ + |Illegal start of toplevel definition + | + | longer explanation available when compiling with `-explain` +-- [E190] Potential Issue Warning: tests/neg/i18408c.scala:3:15 -------------------------------------------------------- +3 |def test1 = fa(42) + | ^^ + | Discarded non-Unit value of type Int. You may want to use `()`. + | + | longer explanation available when compiling with `-explain` +-- [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 + | + | longer explanation available when compiling with `-explain` diff --git a/tests/neg/i18408c.scala b/tests/neg/i18408c.scala new file mode 100644 index 000000000000..0ca80601c0c6 --- /dev/null +++ b/tests/neg/i18408c.scala @@ -0,0 +1,4 @@ +def fa(f: Unit): Unit = ??? +fa(42) // error +def test1 = fa(42) +def test2 = fa({42; ()}) diff --git a/tests/neg/i18722.check b/tests/neg/i18722.check new file mode 100644 index 000000000000..539e23787752 --- /dev/null +++ b/tests/neg/i18722.check @@ -0,0 +1,44 @@ +-- [E190] Potential Issue Error: tests/neg/i18722.scala:3:15 ----------------------------------------------------------- +3 |def f1: Unit = null // error + | ^^^^ + | Discarded non-Unit value of type Null. You may want to use `()`. + |--------------------------------------------------------------------------------------------------------------------- + | Explanation (enabled by `-explain`) + |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + | As this expression is not of type Unit, it is desugared into `{ null; () }`. + | Here the `null` expression is a pure statement that can be discarded. + | Therefore the expression is effectively equivalent to `()`. + --------------------------------------------------------------------------------------------------------------------- +-- [E190] Potential Issue Error: tests/neg/i18722.scala:4:15 ----------------------------------------------------------- +4 |def f2: Unit = 1 // error + | ^ + | Discarded non-Unit value of type Int. You may want to use `()`. + |--------------------------------------------------------------------------------------------------------------------- + | Explanation (enabled by `-explain`) + |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + | As this expression is not of type Unit, it is desugared into `{ 1; () }`. + | Here the `1` expression is a pure statement that can be discarded. + | Therefore the expression is effectively equivalent to `()`. + --------------------------------------------------------------------------------------------------------------------- +-- [E190] Potential Issue Error: tests/neg/i18722.scala:5:15 ----------------------------------------------------------- +5 |def f3: Unit = "a" // error + | ^^^ + | Discarded non-Unit value of type String. You may want to use `()`. + |--------------------------------------------------------------------------------------------------------------------- + | Explanation (enabled by `-explain`) + |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + | As this expression is not of type Unit, it is desugared into `{ "a"; () }`. + | Here the `"a"` expression is a pure statement that can be discarded. + | Therefore the expression is effectively equivalent to `()`. + --------------------------------------------------------------------------------------------------------------------- +-- [E190] Potential Issue Error: tests/neg/i18722.scala:7:15 ----------------------------------------------------------- +7 |def f4: Unit = i // error + | ^ + | Discarded non-Unit value of type Int. You may want to use `()`. + |--------------------------------------------------------------------------------------------------------------------- + | Explanation (enabled by `-explain`) + |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + | As this expression is not of type Unit, it is desugared into `{ i; () }`. + | Here the `i` expression is a pure statement that can be discarded. + | Therefore the expression is effectively equivalent to `()`. + --------------------------------------------------------------------------------------------------------------------- diff --git a/tests/neg/i18722.scala b/tests/neg/i18722.scala new file mode 100644 index 000000000000..c68390b76201 --- /dev/null +++ b/tests/neg/i18722.scala @@ -0,0 +1,9 @@ +//> using options -Werror -explain + +def f1: Unit = null // error +def f2: Unit = 1 // error +def f3: Unit = "a" // error +val i: Int = 1 +def f4: Unit = i // error +val u: Unit = () +def f5: Unit = u diff --git a/tests/neg/spaces-vs-tabs.check b/tests/neg/spaces-vs-tabs.check index 109503c2d557..f8374618f0fd 100644 --- a/tests/neg/spaces-vs-tabs.check +++ b/tests/neg/spaces-vs-tabs.check @@ -28,9 +28,9 @@ | The start of this line does not match any of the previous indentation widths. | Indentation width of current line : 1 tab, 2 spaces | This falls between previous widths: 1 tab and 1 tab, 4 spaces --- [E129] Potential Issue Warning: tests/neg/spaces-vs-tabs.scala:13:7 ------------------------------------------------- +-- [E190] Potential Issue Warning: tests/neg/spaces-vs-tabs.scala:13:7 ------------------------------------------------- 13 | 1 | ^ - | A pure expression does nothing in statement position; you may be omitting necessary parentheses + | Discarded non-Unit value of type Int. You may want to use `()`. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg/syntax-error-recovery.check b/tests/neg/syntax-error-recovery.check index 18d877833d79..8034aeb556c7 100644 --- a/tests/neg/syntax-error-recovery.check +++ b/tests/neg/syntax-error-recovery.check @@ -94,45 +94,45 @@ | Not found: bam | | longer explanation available when compiling with `-explain` --- [E129] Potential Issue Warning: tests/neg/syntax-error-recovery.scala:7:2 ------------------------------------------- +-- [E190] Potential Issue Warning: tests/neg/syntax-error-recovery.scala:7:2 ------------------------------------------- 6 | 2 7 | } | ^ - | A pure expression does nothing in statement position; you may be omitting necessary parentheses + | Discarded non-Unit value of type Null. You may want to use `()`. | | longer explanation available when compiling with `-explain` --- [E129] Potential Issue Warning: tests/neg/syntax-error-recovery.scala:15:2 ------------------------------------------ +-- [E190] Potential Issue Warning: tests/neg/syntax-error-recovery.scala:15:2 ------------------------------------------ 14 | 2 15 | println(baz) // error | ^ - | A pure expression does nothing in statement position; you may be omitting necessary parentheses + | Discarded non-Unit value of type Null. You may want to use `()`. | | longer explanation available when compiling with `-explain` --- [E129] Potential Issue Warning: tests/neg/syntax-error-recovery.scala:27:2 ------------------------------------------ +-- [E190] Potential Issue Warning: tests/neg/syntax-error-recovery.scala:27:2 ------------------------------------------ 26 | 2 27 | println(bam) // error | ^ - | A pure expression does nothing in statement position; you may be omitting necessary parentheses + | Discarded non-Unit value of type Null. You may want to use `()`. | | longer explanation available when compiling with `-explain` --- [E129] Potential Issue Warning: tests/neg/syntax-error-recovery.scala:36:2 ------------------------------------------ +-- [E190] Potential Issue Warning: tests/neg/syntax-error-recovery.scala:36:2 ------------------------------------------ 35 | 2 36 | } | ^ - | A pure expression does nothing in statement position; you may be omitting necessary parentheses + | Discarded non-Unit value of type Null. You may want to use `()`. | | longer explanation available when compiling with `-explain` --- [E129] Potential Issue Warning: tests/neg/syntax-error-recovery.scala:44:2 ------------------------------------------ +-- [E190] Potential Issue Warning: tests/neg/syntax-error-recovery.scala:44:2 ------------------------------------------ 43 | 2 44 | println(baz) // error | ^ - | A pure expression does nothing in statement position; you may be omitting necessary parentheses + | Discarded non-Unit value of type Null. You may want to use `()`. | | longer explanation available when compiling with `-explain` --- [E129] Potential Issue Warning: tests/neg/syntax-error-recovery.scala:56:2 ------------------------------------------ +-- [E190] Potential Issue Warning: tests/neg/syntax-error-recovery.scala:56:2 ------------------------------------------ 55 | 2 56 | println(bam) // error | ^ - | A pure expression does nothing in statement position; you may be omitting necessary parentheses + | Discarded non-Unit value of type Null. You may want to use `()`. | | longer explanation available when compiling with `-explain` From cd54d7f27853d79fe34379ea79ec9bc834320e05 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Fri, 20 Oct 2023 10:55:31 +0200 Subject: [PATCH 2/3] Cleanup pure statement warning 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. [Cherry-picked 7f48230aaee17be029412c7d6bfb5dbca4ac63f6] --- compiler/src/dotty/tools/dotc/reporting/messages.scala | 2 +- compiler/test-resources/repl/nowarn.scala | 2 +- .../test/dotty/tools/languageserver/DiagnosticsTest.scala | 2 +- tests/neg-macros/annot-suspend-cycle.check | 2 +- tests/neg/i18408a.check | 2 +- tests/neg/i18408b.check | 2 +- tests/neg/i18408c.check | 2 +- tests/neg/nowarn.check | 4 ++-- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/reporting/messages.scala b/compiler/src/dotty/tools/dotc/reporting/messages.scala index bc87e40d5e42..3b83bf9a1324 100644 --- a/compiler/src/dotty/tools/dotc/reporting/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/messages.scala @@ -2380,7 +2380,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.""" diff --git a/compiler/test-resources/repl/nowarn.scala b/compiler/test-resources/repl/nowarn.scala index 5038cda7094e..975f9c72a809 100644 --- a/compiler/test-resources/repl/nowarn.scala +++ b/compiler/test-resources/repl/nowarn.scala @@ -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 diff --git a/language-server/test/dotty/tools/languageserver/DiagnosticsTest.scala b/language-server/test/dotty/tools/languageserver/DiagnosticsTest.scala index 2e9009c011e3..8da01bd9ef97 100644 --- a/language-server/test/dotty/tools/languageserver/DiagnosticsTest.scala +++ b/language-server/test/dotty/tools/languageserver/DiagnosticsTest.scala @@ -30,7 +30,7 @@ class DiagnosticsTest { |}""" .diagnostics(m1, (m1 to m2, - "A pure expression does nothing in statement position; you may be omitting necessary parentheses", + "A pure expression does nothing in statement position", Warning, Some(PureExpressionInStatementPositionID))) @Test def diagnosticWorksheetPureExpression: Unit = diff --git a/tests/neg-macros/annot-suspend-cycle.check b/tests/neg-macros/annot-suspend-cycle.check index 237cbe4188b2..e3ecea7345fd 100644 --- a/tests/neg-macros/annot-suspend-cycle.check +++ b/tests/neg-macros/annot-suspend-cycle.check @@ -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. diff --git a/tests/neg/i18408a.check b/tests/neg/i18408a.check index fbd67ef3052a..ff278e6fe5cb 100644 --- a/tests/neg/i18408a.check +++ b/tests/neg/i18408a.check @@ -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` diff --git a/tests/neg/i18408b.check b/tests/neg/i18408b.check index 2bfc8c24f1dd..7c72833fe5ad 100644 --- a/tests/neg/i18408b.check +++ b/tests/neg/i18408b.check @@ -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` diff --git a/tests/neg/i18408c.check b/tests/neg/i18408c.check index 2e8a279764d6..078f42bb0006 100644 --- a/tests/neg/i18408c.check +++ b/tests/neg/i18408c.check @@ -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` diff --git a/tests/neg/nowarn.check b/tests/neg/nowarn.check index a8075335290a..636cabd44d07 100644 --- a/tests/neg/nowarn.check +++ b/tests/neg/nowarn.check @@ -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 -------------------------------------------------------------------------------- @@ -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 -------------------------------------------------------------------------------- From fb14996c0a76650ad5e5ae565cbdc02648e17235 Mon Sep 17 00:00:00 2001 From: Wojciech Mazur Date: Sat, 22 Jun 2024 12:09:31 +0200 Subject: [PATCH 3/3] Fix the expected outputs of neg-custom-args/captures/real-try test to match correct source line positions --- tests/neg-custom-args/captures/real-try.check | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/neg-custom-args/captures/real-try.check b/tests/neg-custom-args/captures/real-try.check index f2cdf4b49b15..2c209b52d489 100644 --- a/tests/neg-custom-args/captures/real-try.check +++ b/tests/neg-custom-args/captures/real-try.check @@ -1,5 +1,5 @@ --- [E190] Potential Issue Warning: tests/neg-custom-args/captures/real-try.scala:36:4 ---------------------------------- -36 | b.x +-- [E190] Potential Issue Warning: tests/neg-custom-args/captures/real-try.scala:30:4 ---------------------------------- +30 | b.x | ^^^ | Discarded non-Unit value of type () -> Unit. You may want to use `()`. |