aboutsummaryrefslogtreecommitdiff
path: root/tests/untried/neg/t5702-neg-bad-and-wild.scala
diff options
context:
space:
mode:
Diffstat (limited to 'tests/untried/neg/t5702-neg-bad-and-wild.scala')
-rw-r--r--tests/untried/neg/t5702-neg-bad-and-wild.scala29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/untried/neg/t5702-neg-bad-and-wild.scala b/tests/untried/neg/t5702-neg-bad-and-wild.scala
new file mode 100644
index 000000000..aadda37da
--- /dev/null
+++ b/tests/untried/neg/t5702-neg-bad-and-wild.scala
@@ -0,0 +1,29 @@
+
+object Test {
+ case class K(i: Int)
+
+ def main(args: Array[String]) {
+ val k = new K(9)
+ val is = List(1,2,3)
+
+ is match {
+ case List(1, _*,) => // bad use of _* (a sequence pattern must be the last pattern)
+ // illegal start of simple pattern
+ case List(1, _*3,) => // illegal start of simple pattern
+ //case List(1, _*3:) => // poor recovery by parens
+ case List(1, x*) => // use _* to match a sequence
+ case List(x*, 1) => // trailing * is not a valid pattern
+ case (1, x*) => // trailing * is not a valid pattern
+ case (1, x@_*) => // bad use of _* (sequence pattern not allowed)
+ }
+
+// good syntax, bad semantics, detected by typer
+//gowild.scala:14: error: star patterns must correspond with varargs parameters
+ val K(is @ _*) = k
+ val K(ns @ _*, x) = k // bad use of _* (a sequence pattern must be the last pattern)
+ val (b, _ * ) = (5,6) // bad use of _* (sequence pattern not allowed)
+// no longer complains
+//bad-and-wild.scala:15: error: ')' expected but '}' found.
+ }
+}
+