Skip to content

Add error message - Parsers.scala:1180 #1613

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}
}