File tree Expand file tree Collapse file tree 3 files changed +10
-16
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 3 files changed +10
-16
lines changed Original file line number Diff line number Diff line change @@ -275,13 +275,13 @@ object Parsers {
275
275
/** If at end of file, issue an incompleteInputError.
276
276
* Otherwise issue a syntax error and skip to next safe point.
277
277
*/
278
- def syntaxErrorOrIncomplete (msg : => Message ): Unit =
278
+ def syntaxErrorOrIncomplete (msg : => Message , offset : Int = in.offset ): Unit =
279
279
if (in.token == EOF ) incompleteInputError(msg)
280
280
else {
281
- syntaxError(msg)
281
+ syntaxError(msg, offset )
282
282
skip()
283
283
lastErrorOffset = in.offset
284
- } // DEBUG
284
+ }
285
285
286
286
/** Consume one token of the specified type, or
287
287
* signal an error if it is not there.
@@ -1456,7 +1456,7 @@ object Parsers {
1456
1456
case _ =>
1457
1457
if (isLiteral) literal()
1458
1458
else {
1459
- syntaxErrorOrIncomplete(IllegalStartSimpleExpr (tokenString(in.token)))
1459
+ syntaxErrorOrIncomplete(IllegalStartSimpleExpr (tokenString(in.token)), in.lastOffset )
1460
1460
errorTermTree
1461
1461
}
1462
1462
}
Original file line number Diff line number Diff line change @@ -569,19 +569,9 @@ object messages {
569
569
case class IllegalStartSimpleExpr (illegalToken : String )(implicit ctx : Context )
570
570
extends Message (IllegalStartSimpleExprID ) {
571
571
val kind : String = " Syntax"
572
- val msg : String = " Illegal start of simple expression"
572
+ val msg : String = " expression expected "
573
573
val explanation : String = {
574
- hl """ |An expression yields a value. In the case of the simple expression, this error
575
- |commonly occurs when there's a missing parenthesis or brace. The reason being
576
- |that a simple expression is one of the following:
577
- |
578
- |- Block
579
- |- Expression in parenthesis
580
- |- Identifier
581
- |- Object creation
582
- |- Literal
583
- |
584
- |which cannot start with ${Red (illegalToken)}. """
574
+ hl """ |An expression cannot start with ${Red (illegalToken)}. """
585
575
}
586
576
}
587
577
Original file line number Diff line number Diff line change
1
+ object Test {
2
+ val x = // error: expression expected
3
+ val y = 2 // error: ';' expected
4
+ }
You can’t perform that action at this time.
0 commit comments