Skip to content

Expr.ofTupleFromSeq return incorrect value if TupleXXL #21779

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

Closed
xuwei-k opened this issue Oct 16, 2024 · 1 comment · Fixed by #21782
Closed

Expr.ofTupleFromSeq return incorrect value if TupleXXL #21779

xuwei-k opened this issue Oct 16, 2024 · 1 comment · Fixed by #21782
Milestone

Comments

@xuwei-k
Copy link
Contributor

xuwei-k commented Oct 16, 2024

Compiler version

  • 3.6.1-RC1-bin-20241014-69ac5fb-NIGHTLY
  • 3.5.1
  • 3.3.4

Minimized code

build.sbt

scalaVersion := "3.5.1"

libraryDependencies += "org.scala-lang" %% "scala3-staging" % scalaVersion.value

Main.scala

import scala.quoted.*
import scala.quoted.staging.{withQuotes, Compiler}

object Main {

  given Compiler = Compiler.make(getClass.getClassLoader)

  def main(args: Array[String]): Unit = {
    withQuotes {
      import quotes.reflect.*
      val x1 = Expr.ofTupleFromSeq(
        Seq(
          Expr("a"),
          Expr(2),
          Expr(3),
          Expr(4),
          Expr(5),
          Expr(6),
          Expr(7),
          Expr(8),
          Expr(9),
          Expr(10),
          Expr(11),
          Expr(12),
          Expr(13),
          Expr(14),
          Expr(15),
          Expr(16),
          Expr(17),
          Expr(18),
          Expr(19),
          Expr(20),
          Expr(21),
          Expr(22),
        )
      )

      val x2 = Expr.ofTupleFromSeq(
        Seq(
          Expr("a"),
          Expr(2),
          Expr(3),
          Expr(4),
          Expr(5),
          Expr(6),
          Expr(7),
          Expr(8),
          Expr(9),
          Expr(10),
          Expr(11),
          Expr(12),
          Expr(13),
          Expr(14),
          Expr(15),
          Expr(16),
          Expr(17),
          Expr(18),
          Expr(19),
          Expr(20),
          Expr(21),
          Expr(22),
          Expr(23),
        )
      )
      println(x1.asTerm.tpe.show)
      println(x2.asTerm.tpe.show)

      assert(x1.asTerm.tpe =:= TypeRepr.of[("a", 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22)])

      // success !?!?!?
      // expect `TypeRepr.of[("a", 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23)]`
      assert(x2.asTerm.tpe =:= TypeRepr.of[(23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, "a")])
    }
  }
}

Output

Expectation

@joroKr21
Copy link
Member

foldLeft vs foldRight

@Gedochao Gedochao added area:typer area:metaprogramming:quotes Issues related to quotes and splices area:tuples and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Oct 16, 2024
@WojciechMazur WojciechMazur added this to the 3.6.3 milestone Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants