Skip to content

Commit 776bf47

Browse files
authored
Merge pull request #5136 from dotty-staging/fix-EOF-offset
Fix offset of token EOF
2 parents c01ee13 + 47f4e3f commit 776bf47

24 files changed

+51
-27
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ abstract class CharArrayReader { self =>
3939
final def nextChar(): Unit = {
4040
val idx = charOffset
4141
lastCharOffset = idx
42+
charOffset = idx + 1
4243
if (idx >= buf.length) {
4344
ch = SU
4445
} else {
4546
val c = buf(idx)
4647
ch = c
47-
charOffset = idx + 1
4848
if (c == '\\') potentialUnicode()
4949
else if (c < ' ') { skipCR(); potentialLineEnd() }
5050
}
@@ -59,12 +59,12 @@ abstract class CharArrayReader { self =>
5959
final def nextRawChar(): Unit = {
6060
val idx = charOffset
6161
lastCharOffset = idx
62+
charOffset = idx + 1
6263
if (idx >= buf.length) {
6364
ch = SU
6465
} else {
65-
val c = buf(charOffset)
66+
val c = buf(idx)
6667
ch = c
67-
charOffset = idx + 1
6868
if (c == '\\') potentialUnicode()
6969
}
7070
}

compiler/test-resources/repl/i2213

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ scala> def x
22
1 | def x
33
| ^
44
| missing return type
5-
1 | def x
5+
6+
scala> def x: Int
7+
1 | def x: Int
68
| ^
7-
| '=' expected, but eof found
9+
|declaration of method x not allowed here: only classes can have declared but undefined members

tests/neg/i2494.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
enum
2-
object // error // error
2+
object // error
3+
// error

tests/neg/i4373a.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
// ==> 040fb47fbaf718cecb11a7d51ac5a48bf4f6a1fe.scala <==
22
object x0 {
3-
val x0 : _ with // error // error // error
3+
val x0 : _ with // error // error
4+
// error

tests/neg/i4373b.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// ==> 05bef7805687ba94da37177f7568e3ba7da1f91c.scala <==
22
class x0 {
33
x1: // error
4-
x0 | _ // error // error
4+
x0 | _ // error
5+
// error

tests/neg/i4373c.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
// ==> 18b253a4a89a84c5674165c6fc3efafad535eee3.scala <==
22
object x0 {
3-
def x1[x2 <:_[ // error // error // error
3+
def x1[x2 <:_[ // error // error
4+
// error

tests/neg/parser-stability-1.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
object x0 {
22
x1 match // error
3-
def this // error // error
3+
def this // error
4+
// error

tests/neg/parser-stability-10.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ def unapply(i1: Int)(i6: List[Int]): Int = {
1010
object i5 {
1111
import collection.mutable._
1212
try { ??? mutable { case i1(i5, i3, i4) => i5 }} // error // error // error
13-
} // error
13+
}
14+
// error

tests/neg/parser-stability-11.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ package x0 {
22
case class x0 // error // error
33
}
44
package x0
5-
class x0 // error // error
5+
class x0 // error
6+
// error

tests/neg/parser-stability-12.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
trait x0[] // error
22
trait x1[x1 <:x0]
3-
extends x1[ // error
3+
extends x1[
4+
// error

0 commit comments

Comments
 (0)