Closed
Description
We should disallow statements before the call to the top level splice of the macro such as
inline def foo: Int = {
println("foo") // should be an error
~impl()
}
def impl(): Expr[Int] = '(1)
The correct way to inline the statements would be to put them in the quoted code itself
inline def foo: Int = ~impl()
def impl(): Expr[Int] = '{
println("foo")
1
}
or
inline def foo: Int = ~{
'{
println("foo")
~impl()
}
}
def impl(): Expr[Int] = '(1)
The motivation for this is to always know statically all the arguments of the top level splice. These argouments are the arguments of the inline macro.
It is not enough to check if the rhs is a splice as the following code should work and may generate a block without statements
inline def foo: Int = {
~impl()
}