Skip to content

Add an error message for incorrect sequence wildcard position Parsers.scala:1425 and Parsers.scala:1079 #1698

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
Nov 14, 2016
Merged

Add an error message for incorrect sequence wildcard position Parsers.scala:1425 and Parsers.scala:1079 #1698

merged 1 commit into from
Nov 14, 2016

Conversation

maseev
Copy link
Contributor

@maseev maseev commented Nov 10, 2016

This pull request is related to the following issue.

Copy link
Contributor

@felixmulder felixmulder left a comment

Choose a reason for hiding this comment

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

Overall good, let's just fix the formatting then we can merge this :)

@@ -787,4 +787,24 @@ object messages {
val msg = "unreachable code"
val explanation = ""
}

case class IncorrectSequenceWildcardPatternPosition()(implicit ctx: Context) extends Message(31) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we make this name a little shorter? How about: SeqWildcardPatternPos?

|def sumOfTheFirstTwo(list: List[Int]): Int = list match {
| case List(first, second, x:_*) => first + second
| case _ => 0
|}
Copy link
Contributor

Choose a reason for hiding this comment

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

To get highlighting on this part pull it out to a variable like:

val code = "def sumOfThe..."

hl"""|Sequence wildcard pattern is expected at the end of an argument list.
     |This pattern matches any remaining elements in a sequence.
     |Consider the following example:
     |
     |$code
     |
     |..."""

And for the code under Calling:

interpolate it like:

|Calling:
|
|${"sumOfTheFirstTwo(List(1, 2, 10))"}
|
|would give 3 as a result"""

this will highlight the code.

@maseev
Copy link
Contributor Author

maseev commented Nov 14, 2016

@felixmulder PTAL

@felixmulder
Copy link
Contributor

LGTM thanks!

@felixmulder felixmulder merged commit 2d18af6 into scala:master Nov 14, 2016
@maseev maseev deleted the iss1589-sequence-wildcard-pattern-message branch November 14, 2016 13:11
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.

3 participants