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
Spec for name based and irrefutable patterns #9351
Spec for name based and irrefutable patterns #9351
Conversation
Name-based extractors for multiple parameters is not yet right. |
FYI, Dotty also has some documentation about this: http://dotty.epfl.ch/docs/reference/changed-features/pattern-matching.html |
Thanks, I'll take a look @liufengyun What I did wrong here is the n > 1 case for unapply with _1 to _n rather than a tuple. |
In Scala 3, it currently only checks |
@liufengyun Requiring The scala 2 compiler team at Lightbend and the dotty teams may want to discuss whether and how that should be aligned -- I'm just a random community passer-by trying to align the spec with the implementation and scala 3. When it's decision making time, it's up to the Powers that Be. |
I'm not sure if we are talking about the same thing. By product-based matches, I mean this feature, which seems not supported by Scala 2. This might be a relief for the concern about migration. |
Doesn't Name-based Match (which is supported already) subsume Product Match? |
They are different, {
def isEmpty: Boolean
def get: S
} In product match, the return type of |
Ah, I see - thank you. Seems a little redundant, language-wise, but perhaps it's very practical and convenient. Do you know what the motivation for it was? (Sorry for the tangential discussion but I've been wanting to know what Scala 3 changed/added here.) |
It's used in case classes, the |
Ah right, yeah. It's good that the pattern matcher would, therefore, use the real, generated |
should this still be marked as "draft"? |
@SethTisue yes, I still want to double-check some of it vs the implementation and scala3's implementation |
f754321
to
caf5eb1
Compare
caf5eb1
to
b72ff83
Compare
remaining steps here, afaict:
|
Draft because of the PR dependency. Also needs a rebase it seems. |
b72ff83
to
36fa494
Compare
A fairly painful rebase... Only partially reviewed it, focussed more on just completing the rebase so we can review it together. |
... so I might've made some mistakes rebasing, feel free to amend and push. |
Source wise nothing stands out as mis-rebased, but I haven't looked at the generated pdf and html yet. |
OK, I plan on reviewing the change overall and getting it merged by Monday, Seth-time. |
I know Seth travels a lot, but I didn't realize they'd given him his own timezone. @liufengyun might still have something to comment about whether this is right from the dotty side of things too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
f4c7e33
to
28765ed
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed a rebase error in duplicating the n>1 section. LGTM, asking Seth if there are any spec-ese mistakes or any other improvements.
Name based patterns were unspecced, and irrefutable patterns were underspecced.
This brings the spec beyond the current implementation, to where, I think, it should be.
Some
-based irrefutable extractors and name-based extractors were part of scalac but unspecced, and are now part of the spec.Name-based irrefutable extractors are pending per #9343
true
-based irrefutable extractors may be broken/may have never worked per this comment: scala/bug#12232 (comment) and should probably be looked in to further.