Closed
Description
Minimized code
@main
def f = List(42) match { case List(xs @ (ys: _*)) => xs }
Output
$ ~/bin/dotc noseq.scala
-- [E029] Pattern Match Exhaustivity Warning: noseq.scala:3:12 -----------------
3 |def f = List(42) match { case List(xs @ (ys: _*)) => xs }
| ^^^^^^^^
| match may not be exhaustive.
|
| It would fail on pattern case: List(_, _: _*), Nil
longer explanation available when compiling with `-explain`
one warning found
$ ~/bin/dotr f
Exception in thread "main" java.lang.ClassCastException: class scala.collection.immutable.$colon$colon cannot be cast to class java.lang.Integer (scala.collection.immutable.$colon$colon is in unnamed module of loader 'app'; java.lang.Integer is in module java.base of loader 'bootstrap')
at scala.runtime.BoxesRunTime.unboxToInt(BoxesRunTime.java:99)
at noseq$package$.f(noseq.scala:3)
at f.main(noseq.scala:2)
Expectation
scala 2.13.1> def f = List(42) match { case List(xs @ (ys @ _*)) => xs }
^
error: bad simple pattern: bad use of _* (sequence pattern not allowed)
The exhaustivity warning is also misguided, also in the correct case.