Skip to content

Compiler crash when referencing type in quotes #18125

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
WojciechMazur opened this issue Jul 3, 2023 · 2 comments · Fixed by #18133
Closed

Compiler crash when referencing type in quotes #18125

WojciechMazur opened this issue Jul 3, 2023 · 2 comments · Fixed by #18133
Assignees
Labels
area:metaprogramming:quotes Issues related to quotes and splices itype:bug itype:crash regression This worked in a previous version but doesn't anymore
Milestone

Comments

@WojciechMazur
Copy link
Contributor

Compiler version

Regression found in the Open Community Build in:

  • tinkoff/phobos - build logs - reproduction below

Compiler version

3.3.2-RC1-bin-20230629-90c59bd-NIGHTLY
Bisect points to b7b13e5

If you're not sure what version you're using, run print scalaVersion from sbt
(if you're running scalac manually, use scalac -version instead).

Minimized code

//> using scala 3.nightly

package oolong.phobos

import scala.quoted.*
import scala.compiletime.*
import scala.annotation.StaticAnnotation

final class xmlns[T](ns: T) extends StaticAnnotation
trait Namespace[T]{
    val getNamespace: String
}

object common{
  private def extractFeildNamespace(using Quotes)(
      fieldAnnotations: List[Expr[Any]],
  ): Expr[Option[String]] = {
    import quotes.reflect.*

    fieldAnnotations.collect { case '{ xmlns($namespace: b) } =>
      '{ Some(summonInline[Namespace[b]].getNamespace) }
    }
    ???
  }
}

Output (click arrow to expand)

//> using scala 3.nightly

package oolong.phobos

import scala.quoted.*
import scala.compiletime.*
import scala.annotation.StaticAnnotation

final class xmlns[T](ns: T) extends StaticAnnotation
trait Namespace[T]{
    val getNamespace: String
}

object common{
  private def extractFeildNamespace(using Quotes)(
      fieldAnnotations: List[Expr[Any]],
  ): Expr[Option[String]] = {
    import quotes.reflect.*

    fieldAnnotations.collect { case '{ xmlns($namespace: b) } =>
      '{ Some(summonInline[Namespace[b]].getNamespace) }
    }
    ???
  }
}
@WojciechMazur WojciechMazur added itype:bug itype:crash regression This worked in a previous version but doesn't anymore area:metaprogramming:quotes Issues related to quotes and splices labels Jul 3, 2023
@nicolasstucki
Copy link
Contributor

Workaround

-    fieldAnnotations.collect { case '{ xmlns($namespace: b) } =>
+    fieldAnnotations.collect { case '{ xmlns[b]($namespace: b) } =>

@nicolasstucki
Copy link
Contributor

Minimization

import scala.quoted.*

final class Foo[T](ns: T)

def foo(using Quotes)(x: Expr[Any]): Unit =
  x match
    case '{ new Foo($y: b) } =>

nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 4, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 4, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 4, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 4, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 4, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 4, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 4, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 13, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 13, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 18, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 19, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 19, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 19, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 19, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 20, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 20, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 20, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 20, 2023
@nicolasstucki nicolasstucki added this to the 3.3.1 milestone Jul 24, 2023
@Kordyjan Kordyjan modified the milestones: 3.3.1, 3.4.0 Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:metaprogramming:quotes Issues related to quotes and splices itype:bug itype:crash regression This worked in a previous version but doesn't anymore
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants