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
Arity-1 name-based extractors should work like arity 2+ #9836
Comments
Imported From: https://issues.scala-lang.org/browse/SI-9836?orig=1 |
@som-snytt said: |
@dwijnand said: |
@som-snytt said: Uniformity was discussed in comments to #7897 It's inconvenient to special-case Product1 just because n == 1. |
@dwijnand said: It returns |
@dwijnand said:
|
Tested on Dotty and the same problem exists there: https://scastie.scala-lang.org/kVbcuVRFQ7ScUjx5VehItA. |
I started looking at this and the linked tickets about so-called "auto-tupling in patterns". I think the first example below is perfectly fine and should not warn (as it currently does). I almost had a fix last week, but The code is commented "don't unwrap Tuple1", but maybe there is a useful cue for whether to unwrap, for example,
|
Studying scala/scala3#15230 I realised why it's important that you can bind the result of the get in the arity-1 case. |
For clarity, I expected
res0
to beArray[Int]
notArray[Foo1]
.I believe this is as specced, but I submit as counter-proof that @adriaanm expected it to work as well: "Looks like it doesn't work for Product1":
https://issues.scala-lang.org/browse/SI-8989?focusedCommentId=71182
The text was updated successfully, but these errors were encountered: