Aladdin - Scala Bugtracking
[#284] project: compiler priority: high category: bug
submitter assigned to status date submitted
Nikolay Burak fixed 2004-01-26 11:37:08.0
subject Pattern matcher generates incorrect tree
code
// bug contribution #10

trait Operator;
case class Increment extends Operator;
case class Decrement extends Operator;

trait Expression {
  def eval = match {
    case Operation (v: Value, o: Increment) => v
    case Operation (v: Value, d: Decrement) => v
  }
}

case class Value extends Expression;
case class Operation (e: Expression, o: Operator) extends Expression;
what happened
Exception in thread "main" java.lang.AssertionError:
unit        : bug_contrib/bug_10.scala
clasz       : Expression$class
member      : Expression$class.eval
owner       : Expression$class.eval.v
tree        : temp$5
tree.pos    : 8:22
tree.symbol : Expression.eval.temp$5
tree.type   : temp$5.type
        at scalac.checkers.TreeChecker.location(TreeChecker.java:392)
        at scalac.checkers.TreeChecker.expression(TreeChecker.java:309)
        at scalac.checkers.TreeChecker.statement(TreeChecker.java:202)
        at scalac.checkers.TreeChecker.expression(TreeChecker.java:241)
        at scalac.checkers.TreeChecker.expression(TreeChecker.java:255)
        at scalac.checkers.TreeChecker.expression(TreeChecker.java:256)
        at scalac.checkers.TreeChecker.expression(TreeChecker.java:243)
        at scalac.checkers.TreeChecker.expression(TreeChecker.java:255)
        ...
what expected Silent compilation. The problem seems to be a reference to an undefined identifier temp$5.
[back to overview]
Changes of this bug report
Nikolay  edited on  2004-01-26 11:37:45.0
Burak  edited on  2004-01-28 16:19:43.0
Fixed. The pattern matcher optimises the number of node tests. Unfortunately, every test comes with a symbol of a temporary variable that holds the casted. Node reuse has to handle these names (a simple substitution).