-
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1879,4 +1879,15 @@ object messages { | |
val msg = hl"Type parameter $undefinedName is undefined. Expected one of ${definedNames.map(_.show).mkString(", ")}." | ||
val explanation = "" | ||
} | ||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Make it a nested val: val msg = {
val addentum = ...
"..." + addentum
} |
||
val msg = hl"Illegal start of statement $addendum" | ||
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 commentThe 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." |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove blank line |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1132,4 +1132,24 @@ class ErrorMessagesTests extends ErrorMessagesTest { | |
assertEquals(tpParams, l2.map(_.show)) | ||
|
||
} | ||
|
||
@Test def illegalStartOfStatement = | ||
checkMessagesAfter("frontend") { | ||
""" | ||
|object Test { | ||
| { ) } | ||
| { private ) } | ||
|} | ||
| | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove blank line |
||
""".stripMargin | ||
} | ||
.expect { (ictx, messages) => | ||
implicit val ctx: Context = ictx | ||
|
||
assertMessageCount(2, messages) | ||
val errWithModifier :: err :: Nil = messages | ||
|
||
assertEquals(IllegalStartOfStatement(isModifier = false), err) | ||
assertEquals(IllegalStartOfStatement(isModifier = true), errWithModifier) | ||
} | ||
} |
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