Skip to content

Commit

Permalink
Add explanation for "illegal start of simple expression"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jyotman Singh committed Oct 23, 2016
1 parent 0e3b4aa commit 65f7ea9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ object Parsers {
case _ =>
if (isLiteral) literal()
else {
syntaxErrorOrIncomplete("illegal start of simple expression")
syntaxErrorOrIncomplete(IllegalStartSimpleExpr(tokenString(in.token)))
errorTermTree
}
}
Expand Down
18 changes: 18 additions & 0 deletions src/dotty/tools/dotc/reporting/diagnostic/messages.scala
Original file line number Diff line number Diff line change
Expand Up @@ -482,4 +482,22 @@ object messages {
|but an uninitialized var definition
""".stripMargin
}

case class IllegalStartSimpleExpr(illegalToken: String)(implicit ctx: Context) extends Message(17) {
val kind = "Syntax"
val msg = "illegal start of simple expression"
val explanation = {
hl"""|An expression yields a value. In the case of the simple expression, this error
|commonly occurs when there's a missing parenthesis or brace. The reason being
|that a simple expression is one of the following:
|
|- Block
|- Expression in parenthesis
|- Identifier
|- Object creation
|- Literal
|
|which cannot start with ${Red(illegalToken)}.""".stripMargin
}
}
}

0 comments on commit 65f7ea9

Please sign in to comment.