Skip to content

Commit a8040df

Browse files
offset correction for stringlit interpolation
1 parent c691beb commit a8040df

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,12 +1245,16 @@ object Parsers {
12451245
}
12461246
})
12471247

1248-
if (in.token == STRINGPART)
1249-
nextSegment(in.offset + (if (isTripleQuoted) 3 else 1))
1248+
var offsetCorrection = if isTripleQuoted then 3 else 1
1249+
def offset = {
1250+
val result = in.offset + offsetCorrection
1251+
offsetCorrection = 0
1252+
result
1253+
}
12501254
while (in.token == STRINGPART)
1251-
nextSegment(in.offset)
1255+
nextSegment(offset)
12521256
if (in.token == STRINGLIT)
1253-
segmentBuf += literal(inPattern = inPattern, negOffset = in.offset, inStringInterpolation = true)
1257+
segmentBuf += literal(inPattern = inPattern, negOffset = offset, inStringInterpolation = true)
12541258

12551259
InterpolatedString(interpolator, segmentBuf.toList)
12561260
}

0 commit comments

Comments
 (0)