You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ ~/bin/dotc noseq.scala
-- [E029] PatternMatchExhaustivityWarning: noseq.scala:3:12-----------------3|deff=List(42) match { caseList(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:classscala.collection.immutable.$colon$colon cannot be cast to classjava.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.
The text was updated successfully, but these errors were encountered:
Previously we didn't check that _* is indeed the last argument,
checking for ")" is not enough, as ")" may be the closing parenthsis
of a nested pattern.
Previously we didn't check that _* is indeed the last argument,
checking for ")" is not enough, as ")" may be the closing parenthesis
of a nested pattern.
odersky
added a commit
to dotty-staging/dotty
that referenced
this issue
Apr 20, 2020
Minimized code
Output
Expectation
The exhaustivity warning is also misguided, also in the correct case.
The text was updated successfully, but these errors were encountered: