Skip to content

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

Conversation

karolchmist
Copy link
Contributor

Part of #1589.

Uses new format of error messages in Parsers.scala:2500

The new error is IllegalStartOfStatement

@karolchmist
Copy link
Contributor Author

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))
Copy link
Contributor

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 ""
Copy link
Contributor

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
"""
Copy link
Contributor

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 ) }
|}
|
Copy link
Contributor

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
"""

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove blank line

@karolchmist karolchmist force-pushed the illegal-start-of-statement-error-messages branch 3 times, most recently from 8ff1da0 to f2a9eab Compare November 4, 2017 21:39
@karolchmist
Copy link
Contributor Author

Thanks @allanrenucci, I've committed the requested changes.

@allanrenucci allanrenucci merged commit 187ced3 into scala:master Nov 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants