Skip to content
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

for yield with nested pattern does not adapt correctly for lazyZip #19576

Closed
bishabosha opened this issue Jan 31, 2024 · 3 comments · Fixed by #19620
Closed

for yield with nested pattern does not adapt correctly for lazyZip #19576

bishabosha opened this issue Jan 31, 2024 · 3 comments · Fixed by #19620
Assignees
Labels
area:desugar Desugaring happens after parsing but before typing, see desugar.scala area:typer itype:bug regression This worked in a previous version but doesn't anymore
Milestone

Comments

@bishabosha
Copy link
Member

bishabosha commented Jan 31, 2024

Compiler Version

3.4.1-RC1-bin-20240130-7a5cb6e-NIGHTLY

Minimised Code

val a = Seq(0 -> 1, 2 -> 3)
val c = Seq("A", "B")
val z =  for ((beg, end), c) <- a.lazyZip(a) yield c

Output

Wrong number of parameters, expected: 2
for (((beg, end), c) <- a.lazyZip(a)) yield c

Expectation

I am not sure if the error is supposed to happen or not, not understanding all 3.4 deprecations.

It might be related to #18842.

Originally posted by @OndrejSpanel in #19560 (comment)

@bishabosha
Copy link
Member Author

with -Xprint:typer you can see that the closure to a.lazyZip(a).map(...) does not have the correct number of arguments (2 are expected):

[[syntax trees at end of                     typer]] // rs$line$6
package <empty> {
  final lazy module val rs$line$6: rs$line$6 = new rs$line$6()
  final module class rs$line$6() extends Object() { this: rs$line$6.type =>
    val a: Seq[(Int, Int)] =
      Seq.apply[(Int, Int)](
        [ArrowAssoc[Int](0).->[Int](1),ArrowAssoc[Int](2).->[Int](3) :
          (Int, Int)]*
      )
    val c: Seq[String] = Seq.apply[String](["A","B" : String]*)
    val z: <error unspecified error> =
      a.lazyZip[(Int, Int)](a).map[Seq[String], Any](
        {
          def $anonfun(x$1: <error Wrong number of parameters, expected: 2>):
            Seq[String] =
            x$1:<error Wrong number of parameters, expected: 2> @unchecked
               match 
              {
                case 
                  Tuple2.unapply[Nothing, Nothing](
                    Tuple2.unapply[Nothing, Nothing](beg @ _, end @ _), c @ _)
                   => c
              }
          closure($anonfun)
        }
      )
  }
}

@bishabosha bishabosha added the regression This worked in a previous version but doesn't anymore label Jan 31, 2024
@bishabosha
Copy link
Member Author

bishabosha commented Jan 31, 2024

I put regression because it originally compiles in 3.3.1 with the old for-comprehension desugaring (crashes with -source:future)

@bishabosha bishabosha added area:desugar Desugaring happens after parsing but before typing, see desugar.scala area:typer itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Jan 31, 2024
@Gedochao Gedochao removed the stat:needs triage Every issue needs to have an "area" and "itype" label label Feb 1, 2024
@EugeneFlesselle
Copy link
Contributor

Related #14651

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:desugar Desugaring happens after parsing but before typing, see desugar.scala area:typer itype:bug regression This worked in a previous version but doesn't anymore
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants