False “match may not be exhaustive warning”
See original GitHub issueMinimized 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.
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (15 by maintainers)
Top Results From Across the Web
Scala warning match may not be exhaustive - Stack Overflow
Match may not be exhaustive warning is incorrect · 2 · pattern match weird behavior with scala 2.13.4 · Hot Network Questions.
Read more >False "match may not be exhaustive" warning in pattern ...
False "match may not be exhaustive" warning in pattern matching #12377 ... It's interesting to see that Scala 3 also (falsely) warns, ...
Read more >[Solved]-Warning Match may not be exhaustive-scala
Why does Scala 2.10 give 'match may not be exhaustive' warning when matching on singleton types? ... How should I handle 'match may...
Read more >Scala Enumerations hell. Motivation | by Yurii Gorbylov | Medium
... but if you want to use scala.Enumeration in pattern matching, you won't get a “match may not be exhaustive” warning: ...
Read more >User danielnixon - Stack Exchange
Match may not be exhaustive warning is incorrect · stackoverflow.com · 5 · How to get sbt to stop trying to pull latest...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@dwijnand Dotty currently has some support for irrefutable
unapplySeq
:https://scastie.scala-lang.org/H6VaTJyeSVuvZ7Y8kz4Qag
It can be specified like the following (with the hypothetical
@irrefutableFor[T]
):Or, lie a little bit: