-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
"Wrong number of parameters" error in for
expression under -source: future
#14626
Comments
So LazyZip2 has a foreach method that takes a Tuple2: object LazyZip2 {
implicit def lazyZip2ToIterable[El1, El2](zipped2: LazyZip2[El1, El2, _]): View[(El1, El2)] = zipped2.toIterable
} So before Reading the spec (SLS §6.19 For Comprehensions and For Loops) it says:
Which it seems to stop doing under
Which, again, isn't going to work with LazyZip2's foreach. Looking at Scala 2, it also converts when using lazyZip in a for comprehension. @odersky Are for-comprehension in Scala 3 meant to desugar to using a Function2 foreach if available, or is it a bug that the implicit conversion isn't still used? |
The difference comes from the fact that under source:future the for expression is treated as an irrefutable pattern match, so no withFilter is inserted. There's no special provision for for comprehensions to use Function2. The type of the scala.collection.LazyZip2[String, Int, ?1.CAP]
|
From the meeting: Martin is trying to fix the arity in desugaring, which means that we won't create tuples! |
With the change in #14294, which makes this fail to compile without |
If a function argument is a synthetic term of the form x$1 => x$1 match case (a_1, ..., a_n) => e and the expected type is an n-ary function type, rewrite the argument to (a_1, ..., a_n) => e Fixes scala#14626. The example in scala#14626 now compiles without an implicit tupling conversion. Such a conversion was inserted before in 2.13, 3.0 and 3.1.
Martin's fix removes the need for this workaround This reverts commit 36e0c29.
Martin's fix removes the need for this workaround This reverts commit 36e0c29.
Compiler version
3.1.2-RC1
Minimized code
Output
Expectation
Noticed at #14294 (comment)
The text was updated successfully, but these errors were encountered: