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

tests/neg/parser-stability-14.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
object x0 {
22
{
33
val x1 x0 // error
4-
object x1 // error // error
4+
object x1 // error
5+
// error

tests/neg/parser-stability-15.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ class x0 {
33
def x1 =
44
x2 match // error
55
] // error
6-
case x3[] => x0 // error // error // error // error
6+
case x3[] => x0 // error // error // error
7+
// error

tests/neg/parser-stability-16.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ class x0[x0] {
22
val x1 : x0
33
}
44
trait x3 extends x0 {
5-
x1 = 0 object // error // error
5+
x1 = 0 object // error
6+
// error

tests/neg/parser-stability-18.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
trait x0 {
22
class x1 (x1:x0
33
{
4-
type x1 <: List[x1 <: // error // error
4+
type x1 <: List[x1 <: // error
5+
// error

tests/neg/parser-stability-19.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
object x0 {
22
case class x0[] // error // error
33
def x0( ) ] // error // error
4-
def x0 ( x0:x0 ):x0.type = x1 x0 // error // error // error
4+
def x0 ( x0:x0 ):x0.type = x1 x0 // error // error
5+
// error

tests/neg/parser-stability-2.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
trait x0 {
2-
new _ // error // error
2+
new _ // error
3+
// error

tests/neg/parser-stability-20.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ object x0 {
22
def unapply= Array
33
x0 match
44
x0 // error
5-
case x0( // error // error
5+
case x0( // error
6+
// error

tests/neg/parser-stability-21.scala

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

tests/neg/parser-stability-22.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
package x0.x0 {}
22
object x0 {
3-
def x0 (implicit // error // error
3+
def x0 (implicit // error
4+
// error

tests/neg/parser-stability-3.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
object x0 {
22
def x0(x1: x2 = 0, x1 x3) x4 = // error // error // error
33
x5 x6 x7[x8[x9 x2]] = x0
4-
val x10 = x0( ) // error // error
4+
val x10 = x0( ) // error
5+
// error

tests/neg/parser-stability-4.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
class x0{
2-
def x0: x0 = (x0 => x0) => x0) // error // error
2+
def x0: x0 = (x0 => x0) => x0) // error
3+
// error

tests/neg/parser-stability-5.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
trait x0 {
22
x1 : { // error
3-
var x2 // error // error
3+
var x2 // error
4+
// error

tests/neg/parser-stability-9.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
import // error
1+
import
2+
// error

tests/neg/parser-stability.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
class I2[I2] {
2-
def I2: I2 = (I2 => I2) => I2 // error // error
2+
def I2: I2 = (I2 => I2) => I2 // error
3+
// error

0 commit comments

Comments
 (0)