Aladdin - Scala Bugtracking
[#197] project: compiler priority: medium category: bug
submitter assigned to status date submitted
Matthias Burak fixed 2003-10-15 12:02:55.0
subject Empty sequence pattern doesn't match sometimes
code
case class Two(xs: List[Any]);
object Foo with Executable {
  def test(xs: Any) = xs match {
    case Two(List(_*, b@(3 | ()))) =>
    	Console.println("b = " + b);
    case _ =>
    	Console.println("default");
  }
  test(Two(List(1, 2, 3)));
  test(Two(List(1, 2)));
  test(Two(List(1)));
  test(Two(List()));
}
what happened
The pattern in method test is supposed to match all lists. But the current implementation ignores t\
he empty sequence () and matches only if lists are terminated with 3.
Output:
b = 3
default
default
default
what expected Match for all test cases.
[back to overview]
Changes of this bug report
Matthias  edited on  2003-10-15 12:03:27.0
Burak  edited on  2003-10-29 16:46:27.0
fixed. This was a bug in the Parser, more precisely in the normalization used by the parser. It "optimized" the pattern b is bound to simply to 3 ! oops...