Skip to content

Commit fe05020

Browse files
authored
Merge pull request #8267 from som-snytt/forward/7919
Fix line-ending empty interpolation
2 parents 3182f1e + 5936dcd commit fe05020

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

compiler/src/dotty/tools/dotc/parsing/Scanners.scala

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -749,17 +749,22 @@ object Scanners {
749749
if (token == INTERPOLATIONID) {
750750
nextRawChar()
751751
if (ch == '\"') {
752-
nextRawChar()
753-
if (ch == '\"') {
752+
if (lookaheadChar() == '\"') {
753+
nextRawChar()
754+
//offset += 3 // first part is positioned at the quote
754755
nextRawChar()
755756
stringPart(multiLine = true)
756757
}
757758
else {
759+
nextChar()
758760
token = STRINGLIT
759761
strVal = ""
760762
}
761763
}
762-
else stringPart(multiLine = false)
764+
else {
765+
//offset += 1 // first part is positioned at the quote
766+
stringPart(multiLine = false)
767+
}
763768
}
764769
else {
765770
nextChar()

tests/pos/t7919.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
object X {
3+
val x = s""
4+
val y = true
5+
}
6+
7+
/* was:
8+
4 | val y = true
9+
| ^^^
10+
| end of statement expected but 'val' found
11+
*/

0 commit comments

Comments
 (0)