Skip to content

Spurious unreachable case warning #16123

Closed
@Bersier

Description

@Bersier

Compiler version

3.2.0

Minimized code

sealed trait Nat
case class Zero() extends Nat
case class Succ[N <: Nat](n: N) extends Nat

def foo(n: Nat): Int = n match
  case Zero() => 0
  case Succ(Zero()) => 1
  case _ => 2 // warning for this line

foo(Succ(Succ(Zero()))) // evaluates to 2

Compiler warning

Unreachable case except for null (if this is intentional, consider writing case null => instead).

Expectation

No warning

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions