Skip to content

False “match may not be exhaustive warning” #10961

Open
@julienrf

Description

@julienrf

Minimized code

def f(xs: List[Int]) =
  xs match
    case init :+ last => ()
    case Nil => ()

@main def run = f(List(1, 2))

https://scastie.scala-lang.org/NVdH00JGS36HLzTs7F8vhw

Output

[warn] 60 |    case init :+ last =>
[warn]    |    ^
[warn]    |    match may not be exhaustive.
[warn]    |
[warn]    |    It would fail on pattern case: List(_, _: _*)
[warn] one warning found

Expectation

There is no warning.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions