Skip to content

Quote evaluation order (debugging) #5434

Closed
@nicolasstucki

Description

@nicolasstucki

When debugging the following code

import scala.quoted._
object Test {
  def main(args: Array[String]): Unit = {
    implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make

    println("start")

    {
      println("start e")
      val e = '{
        ~{
          println("splice")
          '(3)
        }
      }
      println("end e")
      e.run
    }

    println("end")
  }
}

the output will be

start
start e
end e
splice
end

where the natural order would be

start
start e
splice
end e
end

This makes debugging quite hard. The source of the issue is the laziness of the evaluation of the contents of a quote. Making the evaluation eager fixes this.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions