diff options
author | Miron Aseev <aseev.miron@gmail.com> | 2016-11-11 02:44:51 +0700 |
---|---|---|
committer | Miron Aseev <aseev.miron@gmail.com> | 2016-11-14 19:21:34 +0700 |
commit | 759dcf3f903a75fccfcb9e5039e537f8f08a4858 (patch) | |
tree | fcab9a040499e1d952c5a6212c8e90be164c96b8 /src/dotty/tools/dotc/reporting | |
parent | 816fbd0d4cf6cefc93e02e4cf5bd067c517eea48 (diff) | |
download | dotty-759dcf3f903a75fccfcb9e5039e537f8f08a4858.tar.gz dotty-759dcf3f903a75fccfcb9e5039e537f8f08a4858.tar.bz2 dotty-759dcf3f903a75fccfcb9e5039e537f8f08a4858.zip |
Add an error message for incorrect sequence wildcard pattern position
Diffstat (limited to 'src/dotty/tools/dotc/reporting')
-rw-r--r-- | src/dotty/tools/dotc/reporting/diagnostic/messages.scala | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/src/dotty/tools/dotc/reporting/diagnostic/messages.scala index 4ee27c852..e8f2ab8b7 100644 --- a/src/dotty/tools/dotc/reporting/diagnostic/messages.scala +++ b/src/dotty/tools/dotc/reporting/diagnostic/messages.scala @@ -789,4 +789,27 @@ object messages { val msg = "unreachable code" val explanation = "" } + + case class SeqWildcardPatternPos()(implicit ctx: Context) extends Message(31) { + val kind = "Syntax" + val msg = "`_*' can be used only for last argument" + val explanation = { + val code = + """def sumOfTheFirstTwo(list: List[Int]): Int = list match { + | case List(first, second, x:_*) => first + second + | case _ => 0 + |}""" + 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 + | + |Calling: + | + |${"sumOfTheFirstTwo(List(1, 2, 10))"} + | + |would give 3 as a result""" + } + } } |