Skip to content

Commit 7058075

Browse files
committed
Harden position calculation for import clause
1 parent 4458da5 commit 7058075

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1929,7 +1929,10 @@ object Parsers {
19291929
commaSeparated(importExpr) match {
19301930
case t :: rest =>
19311931
// The first import should start at the position of the keyword.
1932-
t.withPos(t.pos.withStart(offset)) :: rest
1932+
val firstPos =
1933+
if (t.pos.exists) t.pos.withStart(offset)
1934+
else Position(offset, in.lastOffset)
1935+
t.withPos(firstPos) :: rest
19331936
case nil => nil
19341937
}
19351938
}

tests/neg/parser-stability-9.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import // error

0 commit comments

Comments
 (0)