diff options
author | Paul Phillips <paulp@improving.org> | 2009-07-07 17:42:06 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-07-07 17:42:06 +0000 |
commit | ac4542b356cc918da5e94dd11616c6d9f0d455cf (patch) | |
tree | 881a3c9ad7e3ad42ae0df4810d486bd55fea3188 /test/files/neg | |
parent | 99ede604a0a16dc0a63383cd90f8b7d38c4f8fd3 (diff) | |
download | scala-ac4542b356cc918da5e94dd11616c6d9f0d455cf.tar.gz scala-ac4542b356cc918da5e94dd11616c6d9f0d455cf.tar.bz2 scala-ac4542b356cc918da5e94dd11616c6d9f0d455cf.zip |
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/.
Diffstat (limited to 'test/files/neg')
-rw-r--r-- | test/files/neg/pat_unreachable.check | 7 | ||||
-rw-r--r-- | test/files/neg/pat_unreachable.scala | 20 | ||||
-rw-r--r-- | test/files/neg/patternalts.scala | 5 |
3 files changed, 28 insertions, 4 deletions
diff --git a/test/files/neg/pat_unreachable.check b/test/files/neg/pat_unreachable.check new file mode 100644 index 0000000000..4e1463d591 --- /dev/null +++ b/test/files/neg/pat_unreachable.check @@ -0,0 +1,7 @@ +pat_unreachable.scala:5: error: unreachable code + case Seq(x, y, z, w) => List(z,w) // redundant! + ^ +pat_unreachable.scala:9: error: unreachable code + case Seq(x, y) => List(x, y) + ^ +two errors found 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 diff --git a/test/files/neg/patternalts.scala b/test/files/neg/patternalts.scala index 62d0325a8b..513b81eb5e 100644 --- a/test/files/neg/patternalts.scala +++ b/test/files/neg/patternalts.scala @@ -2,7 +2,4 @@ object Test { List(1) match { case List(x) | List() => Console.println(x) } - List(2) match { - case List(_: Int) | List() => Console.println() - } -} +}
\ No newline at end of file |