Skip to content
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

-Ywarn-value-discard incompatible with Matchers #1717

Open
mjdiloreto opened this issue Oct 16, 2019 · 2 comments
Open

-Ywarn-value-discard incompatible with Matchers #1717

mjdiloreto opened this issue Oct 16, 2019 · 2 comments

Comments

@mjdiloreto
Copy link

// example.scala
import org.scalatest.Matchers

class foo extends Matchers {
  def test(): Unit = {
    1 should equal(1)
  }
}

object Main {
  new foo().test()
}

Compiled with
scalac -Ywarn-value-discard -classpath scalatest_2.12-3.0.8.jar:scalactic_2.12-3.0.8.jar example.scala

returns

scalatest_bug.scala:5: warning: discarded non-Unit value
    1 should equal(1)
      ^
one warning found

I saw #764 was fixed a while ago in 3.0.0, but was this case not addressed?
I also noticed https://groups.google.com/forum/#!topic/scalatest-users/mltBJPFiWiQ had a very similar example (I am not using FunSuite though, just Matchers), but that person seems not to have responded, so I can only imagine it didn't work for them either.

@hearnadam
Copy link

Though not ideal, this should silence the warnings (2.12/2.13):
"-Wconf:cat=w-flag-value-discard&msg=discarded non-Unit value of type org\\.scalatest\\.Assertion:s"

@SethTisue
Copy link
Contributor

Note that the canonical form of the flag is -Wvalue-discard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants