Skip to content

Commit f190103

Browse files
committed
Honor lastErrorOffset in incompleteInoutError
As for the other errors, don't issue an incomplete input error if the last error offset is the current offset.
1 parent 9cd7006 commit f190103

9 files changed

+8
-11
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,19 +267,22 @@ object Parsers {
267267

268268
/** Issue an error at current offset that input is incomplete */
269269
def incompleteInputError(msg: Message): Unit =
270-
report.incompleteInputError(msg, source.atSpan(Span(in.offset)))
270+
if in.offset != lastErrorOffset then
271+
report.incompleteInputError(msg, source.atSpan(Span(in.offset)))
271272

272273
/** If at end of file, issue an incompleteInputError.
273274
* Otherwise issue a syntax error and skip to next safe point.
274275
*/
275276
def syntaxErrorOrIncomplete(msg: Message, offset: Int = in.offset): Unit =
276-
if (in.token == EOF) incompleteInputError(msg)
277+
if in.token == EOF then
278+
incompleteInputError(msg)
277279
else
278280
syntaxError(msg, offset)
279281
skip()
280282

281283
def syntaxErrorOrIncomplete(msg: Message, span: Span): Unit =
282-
if (in.token == EOF) incompleteInputError(msg)
284+
if in.token == EOF then
285+
incompleteInputError(msg)
283286
else
284287
syntaxError(msg, span)
285288
skip()

tests/neg/i2494.scala

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

tests/neg/i4373c.scala

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

tests/neg/i4934.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ object Main {
88

99
object Foo {
1010
val a = ""); // error: `}` expected but `)` found
11-
}
11+
} // error: eof expected but `}` found

tests/neg/i8731a.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ object test:
77
for
88
a <- Seq()
99
end for // error: `yield` or `do` expected
10-
do () // error: expression expected but eof found
10+
do ()

tests/neg/parser-stability-1.scala

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

tests/neg/parser-stability-18.scala

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

tests/neg/parser-stability-19.scala

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

tests/neg/parser-stability-2.scala

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

0 commit comments

Comments
 (0)