Skip to content

Macro values do not support X with Singleton upper-bound #12975

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
soronpo opened this issue Jun 28, 2021 · 2 comments
Closed

Macro values do not support X with Singleton upper-bound #12975

soronpo opened this issue Jun 28, 2021 · 2 comments
Assignees

Comments

@soronpo
Copy link
Contributor

soronpo commented Jun 28, 2021

Compiler version

v3.0.1-RC2 (also tested on nightly)

Minimized code

import scala.quoted.*
inline def foo[T <: Int with Singleton](value : T) : Unit = ${fooMacro('value)}
def fooMacro[T <: Int with Singleton](value : Expr[T]) : Expr[Unit] = ???

Output

access to parameter value from wrong staging level:
 - the definition is at level 0,
 - but the access is at level -1.

Expectation

No error.

@nicolasstucki
Copy link
Contributor

Minimized

import scala.quoted.*
inline def foo(x : Any) : Unit = ${fooMacro[x.type]}
def fooMacro[T] : Expr[Unit] = ???
2 |inline def foo(x : Any) : Unit = ${fooMacro[x.type]}
  |                                            ^
  |                           access to parameter x from wrong staging level:
  |                            - the definition is at level 0,
  |                            - but the access is at level -1.

As x is used in a type and is erased at runtime it should be a staging level error. This must be fixed in PCPCheckAndHeal.

@nicolasstucki
Copy link
Contributor

Duplicate of #8887. See last minimization.

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

3 participants