Skip to content

Whitebox macros and recursion do not go along well #8779

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
letalvoj opened this issue Apr 23, 2020 · 1 comment
Closed

Whitebox macros and recursion do not go along well #8779

letalvoj opened this issue Apr 23, 2020 · 1 comment

Comments

@letalvoj
Copy link

letalvoj commented Apr 23, 2020

Minimized code

import scala.compiletime._, scala.annotation.tailrec, scala.deriving.productElement

@tailrec inline def mapRec[T <: Tuple, A, B](p:Product)(i:Int)(f: A => B) <: Tuple = inline erasedValue[T] match
  case _: (A *: tt) => (f(productElement[A](p,i)) *: mapRec[tt,A,B](p)(i+1)(f))
  case _: (t *: tt) => (productElement[t](p,i) *: mapRec[tt,A,B](p)(i+1)(f))
  case _: Unit => () : Unit

mapRec[(Int,String),Int,String]((1,"lol"))(0)(_.toString)

Output

val res1: String *: Tuple = (1,lol)

Expectation

val res1: String *: String *: Unit = (1,lol)
@odersky
Copy link
Contributor

odersky commented Apr 23, 2020

Duplicate of #8739

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants