Skip to content

3.1.3 regression: spurious unreachable warning #15522

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

Closed
armanbilge opened this issue Jun 25, 2022 · 0 comments · Fixed by #15553
Closed

3.1.3 regression: spurious unreachable warning #15522

armanbilge opened this issue Jun 25, 2022 · 0 comments · Fixed by #15553

Comments

@armanbilge
Copy link
Contributor

Compiler version

  • 3.1.3
  • 3.2.1-RC1-bin-20220623-5a8a61d-NIGHTLY

Minimized code

//> using scala "3.2.1-RC1-bin-20220623-5a8a61d-NIGHTLY"

sealed trait Coverage {
  import Coverage.{ Empty, Range }

  def (other: Coverage): Coverage =
    (this, other) match {
      case (Empty, _) => Empty
      case (_, Empty) => 
        println("unreachable")
        Empty
      case (Range(a, b), Range(aʹ, bʹ)) => Coverage(a max aʹ, b min bʹ)
    }
}

object Coverage {

  def apply(min: Double, max: Double): Coverage =
    if (min < max) new Range(min, max) {} else Empty

  case object Empty extends Coverage

  sealed abstract case class Range(min: Double, max: Double) extends Coverage
}

@main def main =
  Coverage(0, 1).(Coverage.Empty)

Output

$ scala-cli bug.scala 
Compiling project (Scala 3.2.1-RC1-bin-20220623-5a8a61d-NIGHTLY, JVM)
[warn] ./bug.scala:10:12: Unreachable case
[warn]       case (_, Empty) => 
[warn]            ^^^^^^^^^^
Compiled project (Scala 3.2.1-RC1-bin-20220623-5a8a61d-NIGHTLY, JVM)
unreachable

Expectation

This is a regression since 3.1.2.

@armanbilge armanbilge added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Jun 25, 2022
@OlivierBlanvillain OlivierBlanvillain added area:pattern-matching and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jun 25, 2022
@dwijnand dwijnand self-assigned this Jun 27, 2022
@dwijnand dwijnand linked a pull request Jun 29, 2022 that will close this issue
@Kordyjan Kordyjan added this to the 3.2.1 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants