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 {
275275 /** If at end of file, issue an incompleteInputError.
276276 * Otherwise issue a syntax error and skip to next safe point.
277277 */
278- def syntaxErrorOrIncomplete (msg : => Message ): Unit =
278+ def syntaxErrorOrIncomplete (msg : => Message , offset : Int = in.offset ): Unit =
279279 if (in.token == EOF ) incompleteInputError(msg)
280280 else {
281- syntaxError(msg)
281+ syntaxError(msg, offset )
282282 skip()
283283 lastErrorOffset = in.offset
284- } // DEBUG
284+ }
285285
286286 /** Consume one token of the specified type, or
287287 * signal an error if it is not there.
@@ -1456,7 +1456,7 @@ object Parsers {
14561456 case _ =>
14571457 if (isLiteral) literal()
14581458 else {
1459- syntaxErrorOrIncomplete(IllegalStartSimpleExpr (tokenString(in.token)))
1459+ syntaxErrorOrIncomplete(IllegalStartSimpleExpr (tokenString(in.token)), in.lastOffset )
14601460 errorTermTree
14611461 }
14621462 }
Original file line number Diff line number Diff line change @@ -569,19 +569,9 @@ object messages {
569569 case class IllegalStartSimpleExpr (illegalToken : String )(implicit ctx : Context )
570570 extends Message (IllegalStartSimpleExprID ) {
571571 val kind : String = " Syntax"
572- val msg : String = " Illegal start of simple expression"
572+ val msg : String = " expression expected "
573573 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)}. """
585575 }
586576 }
587577
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