-
Notifications
You must be signed in to change notification settings - Fork 21
"match may not be exhaustive" warning for LazyList (but not for List) #12243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think we need to fix this by adding the same kind of rewrite that is used for List. |
During the pattern matcher's analysis, it rewrites Which is why at first I thought this was because it was using |
Side note, to workaround the immediate issue, if you don't want to add an
Another exhaustive variation available now is
Though I'll give you that explicitly calling unapply on the symbolic extractor is really ugly. This would become a bit less ugly if LazyList had that unapply method as an instance method, maybe called
|
Is the now the "match exhaustiveness of unapplySeq is not tracked over arities of irrefutably extracted seqs, or is that (or should it be) a separate one? |
Something's wrong with your sentence, but it sounds like you're describing your #12252. No? To me this ticket is now "why doesn't this linked list have the same exhaustivity properties that I get with |
Yes, I am describing my own #12252, but that was like several days ago. If this isn't a duplicate of that, then I don't think this is a bug per your analysis: the expectation that the compiler should know SomeCollection() should be complementary with some head -> tail destructuring, the only thing actionable here, I think, is finding (and correcting) what causes that false expectation -- which may actually be the rewrite of List() to Nil itself |
Maybe I can teach the analysis that I still think it's a legit issue because it's not just SomeCollection, it's in the standard library... 😦 |
My thinking is, for the general case, we should get varargs exhaustiveness to work per #12252 -- conceptually it's clear: a set of "irrefutable" varargs extractors is actually exhaustive if all arities are covered. Then the user could write this case in terms of varargs extractors to be exhaustive. I intend to work on that, but can't make any promises I'll succeed in that. If you don't want to call it good just yet then, because you also kind of want |
Uh oh!
There was an error while loading. Please reload this page.
reproduction steps
using Scala 2.13.4,
problem
Compiling this code result in a warning
While the same code with List replacing LazyList and "::" replacing "#::" compile without error.
The text was updated successfully, but these errors were encountered: