You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Oh that issue says -Wvalue-discard does warn at the line in question.
The two warnings are non "synonymous" because "value discard" is a discarded "expression", but "nonunit statement" checks for an expression in a syntactic statement.
In Scala 2, if (b) e is typechecked as if (b) e else (), which is a value that warns under "nonunit statement".
In Scala 3, e has expected type Unit, so it warns under value discard.
That much is "won't fix", but maybe the desired behavior is that the "nonunit statement" warning also enables "value discard", as it is the more expensive check and the user surely wants both.
Thanks for the explanation. Truth is I was not aware of -Wvalue-discard existence, I did not pay much attention to documentation, I just saw -Wnonunit-statement and though this is what I want.
That much is "won't fix", but maybe the desired behavior is that the "nonunit statement" warning also enables "value discard", as it is the more expensive check and the user surely wants both.
Agreed, closing this as a won't fix.
We might want to consider unifying -Wvalue-discard with -Wnonunit-statement, but that's a separate thing.
Feel free to raise it as a separate issue.
Compiler version
3.5.2, 3.6.2
Minimized code
Compile with
-Wnonunit-statement
Output
Expectation
The warning should be given both on lines 4 and 6, but the discarded value on line 6 is silently ignored.
The text was updated successfully, but these errors were encountered: