Skip to content

Quotes sometimes needs a name in Scala 3 macros #13905

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
markehammons opened this issue Nov 7, 2021 · 4 comments
Closed

Quotes sometimes needs a name in Scala 3 macros #13905

markehammons opened this issue Nov 7, 2021 · 4 comments
Assignees
Labels

Comments

@markehammons
Copy link

Compiler version

3.1.0

Minimized code

note: I'll add minimized code later, this bug seems hard to trigger

image
as you see, there's an error highlighted in this code.

Giving Quotes a name resolves the error.

image

Output

core/src/io/gitlab/mhammons/slinc/nativepieces.scala:362:16
[E]      Found:    (x$1 : (String, quoted.Type[? <: AnyKind]))
[E]      Required: quoted.Quotes
[E]      L362:                '{

Expectation

I shouldn't need a name for Quotes here.

@markehammons
Copy link
Author

markehammons commented Nov 15, 2021

Sorry for the wait on this, been busy as a bee on my own projects. So far, the common trigger for this bug seems to be using quotes that use a matched type inside of a partial function.

I'll see if I can quickly put together a minimal example tonight.

@markehammons
Copy link
Author

markehammons commented Nov 16, 2021

https://github.com/markehammons/macro-bug-13905

Here's a minimized version of the bug. The issue appears when doing a map-match.

  //naming Quotes resolves the compilation error
  def testImpl(using Quotes) =
    import quotes.reflect.*
    List(TypeRepr.of[Int].asType)
      .map { case '[r] =>
        '{ ${ Expr(Type.show[r]) } }
      }

  def testImpl2(using q: Quotes) =
    import quotes.reflect.*
    List(TypeRepr.of[Int].asType)
      .map { case '[r] =>
        '{ ${ Expr(Type.show[r]) } }
      }

@bishabosha
Copy link
Member

^ error with the anonymous using parameter:

-- Error:
5 |        '{ ${ Expr(Type.show[r]) } }
  |        ^
  |Found:    quoted.Type[?1.CAP]
  |Required: quoted.Quotes
  |
  |where:    ?1 is an unknown value of type scala.runtime.TypeBox[Nothing, AnyKind]

@smarter
Copy link
Member

smarter commented Jul 12, 2023

Fixed in 3.3.1-RC1 and up as reported in #18059

@smarter smarter closed this as completed Jul 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants