Aladdin - Scala Bugtracking
[#132] project: compiler priority: low category: bug
submitter assigned to status date submitted
Matthias Burak fixed 2003-09-11 15:30:11.0
subject Violation of first-match policy
code
class Expr;
case class One(xs: List[Expr]) extends Expr;
case class Two() extends Expr;
object Foo with Executable {
  def test(xs: List[Expr]) = xs match {
    case List(Two()?,a,Two()?) => System.out.println("a = " + a);
    case List(Two()*,b,Two()*) => System.out.println("b = " + b);
    case List(_*) => System.out.println("no match");
  }
  test(List(Two(),Two(),Two(),Two()));
  test(List(Two(),Two(),Two()));
  test(List(Two(),Two()));
  test(List(Two()));
  test(List());
}
what happened
When object Foo is executed, it prints out the following lines:
b = Two
b = Two
b = Two
a = Two
no match
what expected The expected output is:
b = Two
a = Two
a = Two
a = Two
no match
[back to overview]
Changes of this bug report
Burak  edited on  2003-09-23 18:25:53.0
changed priority
Burak  edited on  2003-09-26 17:38:47.0
fixed. patterns were not treated correctly. However, I am not 100% of the correctness of the fix.