Aladdin - Scala Bugtracking
[#131] project: compiler priority: medium category: bug
submitter assigned to status date submitted
Matthias Burak won't fix 2003-09-11 15:23:14.0
subject Nested sequence patterns
code
class Expr;
case class One(xs: List[Expr]) extends Expr;
case class Two() extends Expr;
object Foo {
  def test(xs: List[Expr]) = xs match {
    case List(One(List(_*))*,a,Two()?) => 
  }
}
what happened
Pattern matcher crashes in call to TreeCloner:
Exception in thread "main" java.lang.AssertionError: Foo.test.x$0
        at scalac.ast.TreeCloner.getSymbolFor(TreeCloner.java:62)
        at scalac.ast.TreeCloner.transform(TreeCloner.java:78)
        at scalac.ast.Transformer.transform(Transformer.java:276)
        at scalac.ast.Transformer.transform(Transformer.java:159)
        at scalac.ast.TreeCloner.transform(TreeCloner.java:77)
        at scalac.ast.Transformer.transform(Transformer.java:276)
        at scalac.ast.Transformer.transform(Transformer.java:206)
        at scalac.ast.TreeCloner.transform(TreeCloner.java:77)
        at scalac.ast.Transformer.transform(Transformer.java:276)
        at scalac.ast.Transformer.transform(Transformer.java:206)
        at scalac.ast.TreeCloner.transform(TreeCloner.java:77)
        at scalac.transformer.matching.RightTracerInScala._cur_match(RightTracerInScala.java:340)
        at scalac.transformer.matching.RightTracerInScala.code_delta(RightTracerInScala.java:381)
        at scalac.transformer.matching.RightTracerInScala.code_state(RightTracerInScala.java:265)
        at scalac.transformer.matching.RightTracerInScala.code_body(RightTracerInScala.java:185)
        at scalac.transformer.matching.RightTracerInScala.getStms(RightTracerInScala.java:432)
        at scalac.transformer.matching.SequenceMatcher.addBinderToBody(SequenceMatcher.java:146)
        at scalac.transformer.matching.SequenceMatcher.addBindersToBodies(SequenceMatcher.java:201)
        at scalac.transformer.matching.SequenceMatcher.construct(SequenceMatcher.java:266)
        at scalac.transformer.matching.AlgebraicMatcher.callSequenceMatcher(AlgebraicMatcher.java:489)
        at scalac.transformer.matching.AlgebraicMatcher.toTree(AlgebraicMatcher.java:417)
        at scalac.transformer.matching.AlgebraicMatcher.toTree(AlgebraicMatcher.java:382)
        at scalac.transformer.matching.AlgebraicMatcher.toTree(AlgebraicMatcher.java:364)
        at scalac.transformer.matching.AlgebraicMatcher.construct(AlgebraicMatcher.java:59)
        at scalac.transformer.matching.AlgebraicMatcher.construct(AlgebraicMatcher.java:46)
        at scalac.transformer.TransMatch.transform(TransMatch.java:103)
        at scalac.transformer.TransMatch.transform(TransMatch.java:125)
        at scalac.transformer.OwnerTransformer.transform(OwnerTransformer.java:41)
        at scalac.transformer.OwnerTransformer.transform(OwnerTransformer.java:116)
        at scalac.transformer.TransMatch.transform(TransMatch.java:136)
        at scalac.transformer.OwnerTransformer.transform(OwnerTransformer.java:41)
        at scalac.transformer.OwnerTransformer.transformTemplateStat(OwnerTransformer.java:87)
        at scalac.transformer.OwnerTransformer.transformTemplateStats(OwnerTransformer.java:76)
        at scalac.transformer.OwnerTransformer.transform(OwnerTransformer.java:68)
        at scalac.transformer.OwnerTransformer.transform(OwnerTransformer.java:100)
        at scalac.transformer.TransMatch.transform(TransMatch.java:136)
        at scalac.ast.Transformer.transform(Transformer.java:281)
        at scalac.transformer.OwnerTransformer.apply(OwnerTransformer.java:35)
        at scalac.transformer.TransMatch.apply(TransMatch.java:92)
        at scalac.transformer.TransMatchPhase.apply(TransMatchPhase.java:33)
        at scalac.Global.compile(Global.java:293)
        at scalac.Global.compile(Global.java:266)
        at scalac.Main.main(Main.java:32)
what expected Compiles.
[back to overview]
Changes of this bug report
Burak  edited on  2003-09-24 11:33:49.0
I reassign this bug to Michel, who wrote the TreeCloner and who might know better where the problem lies.
Burak  edited on  2003-09-24 15:28:46.0
better description of the problem. The TreeCloner was created with
TreeCloner st = new TreeCloner(cf.unit.global, freshenMap, Type.IdMap );
where freshenMap is the empty HashMap. it seems TreeCloner.getSymbolFor does not do what it promises in the comment.
Matthias  edited on  2003-10-07 12:54:23.0
Michel said that he's not responsible, so I assigned it to the new maintainer Philippe.
Philippe  edited on  2003-10-15 14:32:51.0

The problem is not in TreeCloner but in RightTracerInScala where the cloner is not correctly used => reassinged to Burak.

Burak, you should reread the (now updated) description of TreeCloner to see how to use it.

Lex  edited on  2006-03-28 13:33:32.0
The title says it: nested sequence patterns. The current compiler generates a nice message saying that this is not supported.