Closed
Description
Compiler version
3.1.1
Minimized code
import scala.quoted.*
def q1(using Quotes): Expr[Int] = '{ 1 }
def q2(using Quotes): Expr[Int] = ' { 1 } // compiles but should not
def q3(using Quotes): Expr[Int] = '{ ${ foo } }
def q4(using Quotes): Expr[Int] = '{ $ { foo } } // compiles but should not
Expectation
They should have the same syntactic rules as string interpolators. '
or $
must be immediately followed by a {
.
For examples the equivalent string interpolators
def s1 = s"abc"
def s2 = s "abc" // does not compile
def s3 = s"<${"abc"}>"
def s4 = s"<$ {"abc"}>" // does not compile
Also see
- https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/parsing/Parsers.scala#L2247-L2248
- https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/parsing/Parsers.scala#L2232
- https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/parsing/Parsers.scala#L1569-L1570