-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New format of illegal start of statement error message (+tests) #3435
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
New format of illegal start of statement error message (+tests) #3435
Conversation
PS. I've signed the CLA |
@@ -2496,8 +2496,7 @@ object Parsers { | |||
} | |||
else if (!isStatSep && (in.token != CASE)) { | |||
exitOnError = mustStartStat | |||
val addendum = if (isModifier) " (no modifiers allowed here)" else "" | |||
syntaxErrorOrIncomplete("illegal start of statement" + addendum) | |||
syntaxErrorOrIncomplete(IllegalStartOfStatement(isModifier = isModifier)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Named argument is redundant here
|
||
case class IllegalStartOfStatement(isModifier: Boolean)(implicit ctx: Context) extends Message(IllegalStartOfStatementID) { | ||
val kind = "Syntax" | ||
private val addendum = if(isModifier) "(no modifiers allowed here)" else "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make it a nested val:
val msg = {
val addentum = ...
"..." + addentum
}
val explanation = hl""" | ||
| Expected an import, a statement or an expression at the start of a statement. | ||
| For a detailed list of allowed statements, please consult the syntax of BlockStat at http://dotty.epfl.ch/docs/internals/syntax.html#expressions | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, we don't include links. Suggested rephrasing:
val explanation = "A statement is either an import, a definition or an expression."
| { ) } | ||
| { private ) } | ||
|} | ||
| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove blank line
| Expected an import, a statement or an expression at the start of a statement. | ||
| For a detailed list of allowed statements, please consult the syntax of BlockStat at http://dotty.epfl.ch/docs/internals/syntax.html#expressions | ||
""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove blank line
8ff1da0
to
f2a9eab
Compare
Thanks @allanrenucci, I've committed the requested changes. |
Part of #1589.
Uses new format of error messages in Parsers.scala:2500
The new error is IllegalStartOfStatement