Skip to content

Macro with Unit type splicing non Unit fails with splice outside quotes #3912

Closed
@nicolasstucki

Description

@nicolasstucki
import scala.quoted._
object Macros {
  inline def foo(): Unit = ~impl()
  def impl(): Expr[Int] = '(1)
}
import scala.quoted._
import Macros._
class Test {
  val a: Unit = foo()
}

fails with

5 |    ~impl()
  |    ^^^^^^^
  |    splice outside quotes

because inline def foo(): Unit = ~impl() is transformed to
inline def foo(): Unit = { ~impl(); () }, which is correct.

We need a better error message for this.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions