Skip to content

Commit 59d75a1

Browse files
committed
Fix #6219: Handle empty splice in string interpolation
1 parent cdb6250 commit 59d75a1

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,6 +1351,7 @@ object desugar {
13511351
case ts: Thicket => ts.trees.tail
13521352
case t => Nil
13531353
} map {
1354+
case Block(Nil, EmptyTree) => Literal(Constant(())) // for s"... ${} ..."
13541355
case Block(Nil, expr) => expr // important for interpolated string as patterns, see i1773.scala
13551356
case t => t
13561357
}

tests/run/i6219.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
object Test {
2+
def main(args: Array[String]): Unit = {
3+
assert(s"hello ${} world" == "hello () world")
4+
assert(s"hello ${ } world" == "hello () world")
5+
}
6+
}

0 commit comments

Comments
 (0)