Skip to content

Add explanation to error when using nested quotes. #17338

Closed
@steinybot

Description

@steinybot

Compiler version

3.3.0-RC4

Minimized code

import scala.quoted.*

def test(using quotes: Quotes): Expr[Expr[Int]] =
  '{ '{ 1 } }

Reproduction: https://github.com/steinybot/bug-reports/tree/dotty/wrong-staging-level-multi-stage

Output

[error] 4 |  '{ '{ 1 } }
[error]   |     ^
[error]   |     access to parameter quotes from wrong staging level:
[error]   |      - the definition is at level 0,
[error]   |      - but the access is at level 1.

Expectation

According to the docs:

If the number of quotes exceeds the number of splices by more than one (effectively handling at run-time values of type Expr[Expr[T]], Expr[Expr[Expr[T]]], ...) then we talk about Multi-Stage Programming.

I thought that this example should have compiled and produces an Expr[Expr[Int]] which I could then evaluate twice with run.

Perhaps I have misunderstood, but if that is the case then I think the docs are misleading.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions