From ac4542b356cc918da5e94dd11616c6d9f0d455cf Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Tue, 7 Jul 2009 17:42:06 +0000 Subject: Lots of work hardening matching on sequences. one long-standing bug which actually had a test case testing its bugginess (which is to say, when I fixed the bug, the test case failed.) This: - def doMatch4(xs:Seq[Char]) = xs match { - case Seq(x, y, _*) => x::y::Nil - case Seq(x, y, z, w) => List(z,w) // redundant! - } ...should never have compiled - which must have been recognized on some level given the "redundant!" comment, but it never made it into neg/. --- test/files/neg/pat_unreachable.scala | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 test/files/neg/pat_unreachable.scala (limited to 'test/files/neg/pat_unreachable.scala') diff --git a/test/files/neg/pat_unreachable.scala b/test/files/neg/pat_unreachable.scala new file mode 100644 index 0000000000..c07be8edf0 --- /dev/null +++ b/test/files/neg/pat_unreachable.scala @@ -0,0 +1,20 @@ + +object Test extends Application { + def unreachable1(xs:Seq[Char]) = xs match { + case Seq(x, y, _*) => x::y::Nil + case Seq(x, y, z, w) => List(z,w) // redundant! + } + def unreachable2(xs:Seq[Char]) = xs match { + case Seq(x, y, _*) => x::y::Nil + case Seq(x, y) => List(x, y) + } + + def not_unreachable(xs:Seq[Char]) = xs match { + case Seq(x, y, _*) => x::y::Nil + case Seq(x) => List(x) + } + def not_unreachable2(xs:Seq[Char]) = xs match { + case Seq(x, y) => x::y::Nil + case Seq(x, y, z, _*) => List(x,y) + } +} \ No newline at end of file -- cgit v1.2.3