Skip to content

Commit cdb83f9

Browse files
authored
Merge pull request #1613 from jyotman94/error_message_Parsers.scala-1180
Add error message - Parsers.scala:1180
2 parents 0e3b4aa + 65f7ea9 commit cdb83f9

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,7 @@ object Parsers {
11771177
case _ =>
11781178
if (isLiteral) literal()
11791179
else {
1180-
syntaxErrorOrIncomplete("illegal start of simple expression")
1180+
syntaxErrorOrIncomplete(IllegalStartSimpleExpr(tokenString(in.token)))
11811181
errorTermTree
11821182
}
11831183
}

src/dotty/tools/dotc/reporting/diagnostic/messages.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,4 +482,22 @@ object messages {
482482
|but an uninitialized var definition
483483
""".stripMargin
484484
}
485+
486+
case class IllegalStartSimpleExpr(illegalToken: String)(implicit ctx: Context) extends Message(17) {
487+
val kind = "Syntax"
488+
val msg = "illegal start of simple expression"
489+
val explanation = {
490+
hl"""|An expression yields a value. In the case of the simple expression, this error
491+
|commonly occurs when there's a missing parenthesis or brace. The reason being
492+
|that a simple expression is one of the following:
493+
|
494+
|- Block
495+
|- Expression in parenthesis
496+
|- Identifier
497+
|- Object creation
498+
|- Literal
499+
|
500+
|which cannot start with ${Red(illegalToken)}.""".stripMargin
501+
}
502+
}
485503
}

0 commit comments

Comments
 (0)