Aladdin - Scala Bugtracking
[#889] project: compiler priority: low category: bug
submitter assigned to status date submitted
Nikolay Martin not repro 2007-01-16 11:02:04.0
subject [contrib #296] Compiler crashes with call by name argument returned from inside match
code
object Bug {
  def foo (l: => String) : String = 12 match { case _ => l}
}

what happened
The compiler crashes. It does not with def foo(l: String). It does not if the match is removed. 
The compiler version is 2.3.1
The output is :
$ scalac *.scala
scala.tools.nsc.symtab.Types$TypeError: type mismatch;
 found   : () => java.lang.String
 required: java.lang.String
        at scala.tools.nsc.typechecker.Contexts$Context.error(Contexts.scala:252)
        at scala.tools.nsc.typechecker.Infer$Inferencer.error(Infer.scala:245)
        at scala.tools.nsc.typechecker.Infer$Inferencer.typeError(Infer.scala:254)
        at scala.tools.nsc.typechecker.Infer$Inferencer.typeErrorTree(Infer.scala:263)
        at scala.tools.nsc.typechecker.Typers$Typer.adapt(Typers.scala:653)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:2217)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:2258)
        at scala.tools.nsc.transform.ExplicitOuter$ExplicitOuterTransformer.transform(ExplicitOuter.scala:628)
        at scala.tools.nsc.ast.Trees$Transformer$$anonfun$20.apply(Trees.scala:1084)
        at scala.tools.nsc.ast.Trees$Transformer$$anonfun$20.apply(Trees.scala:1083)
        at scala.tools.nsc.ast.Trees$Transformer.atOwner(Trees.scala:1191)
        at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:33)
        at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:27)
        at scala.tools.nsc.ast.Trees$Transformer.transform(Trees.scala:1082)
        at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:46)\

        at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.transform(ExplicitOuter.scala:303)
        at scala.tools.nsc.transform.ExplicitOuter$ExplicitOuterTransformer.transform(ExplicitOuter.scala:569)
        at scala.tools.nsc.ast.Trees$Transformer$$anonfun$30.apply(Trees.scala:1185)
        at scala.tools.nsc.ast.Trees$Transformer$$anonfun$30.apply(Trees.scala:1183)
        at scala.List$.loop$0(List.scala:244)
        at scala.List$.mapConserve(List.scala:261)
        at scala.tools.nsc.ast.Trees$Transformer.transformStats(Trees.scala:1183)
        at scala.tools.nsc.ast.Trees$Transformer.transform(Trees.scala:1103)
        at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.scala$tools$nsc$transform$TypingTransf\
ormers$TypingTransformer$$super$transform(TypingTransformers.scala:44)
        at scala.tools.nsc.transform.TypingTransformers$TypingTransformer$$anonfun$0.apply(TypingTransformers.sc\
ala:44)
        at scala.tools.nsc.transform.TypingTransformers$TypingTransformer$$anonfun$0.apply(TypingTransformers.sc\
ala:44)
        at scala.tools.nsc.ast.Trees$Transformer.atOwner(Trees.scala:1191)
        at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:33)
        at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:27)
        at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:44)\

        at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.transform(ExplicitOuter.scala:303)
        at scala.tools.nsc.transform.ExplicitOuter$ExplicitOuterTransformer.transform(ExplicitOuter.scala:537)
        at scala.tools.nsc.ast.Trees$Transformer.transformTemplate(Trees.scala:1171)
        at scala.tools.nsc.ast.Trees$Transformer$$anonfun$17.apply(Trees.scala:1071)
        at scala.tools.nsc.ast.Trees$Transformer$$anonfun$17.apply(Trees.scala:1070)
        at scala.tools.nsc.ast.Trees$Transformer.atOwner(Trees.scala:1191)
        at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:33)
        at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:27)
        at scala.tools.nsc.ast.Trees$Transformer.transform(Trees.scala:1069)
        at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:46)\

        at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.transform(ExplicitOuter.scala:303)
        at scala.tools.nsc.transform.ExplicitOuter$ExplicitOuterTransformer.transform(ExplicitOuter.scala:651)
        at scala.tools.nsc.ast.Trees$Transformer$$anonfun$30.apply(Trees.scala:1185)
        at scala.tools.nsc.ast.Trees$Transformer$$anonfun$30.apply(Trees.scala:1183)
        at scala.List$.loop$0(List.scala:244)
        at scala.List$.mapConserve(List.scala:261)
        at scala.tools.nsc.ast.Trees$Transformer.transformStats(Trees.scala:1183)
        at scala.tools.nsc.ast.Trees$Transformer$$anonfun$16.apply(Trees.scala:1066)
        at scala.tools.nsc.ast.Trees$Transformer$$anonfun$16.apply(Trees.scala:1066)
        at scala.tools.nsc.ast.Trees$Transformer.atOwner(Trees.scala:1191)
        at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:33)
        at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:27)
        at scala.tools.nsc.ast.Trees$Transformer.transform(Trees.scala:1065)
        at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:46)\

        at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.transform(ExplicitOuter.scala:303)
        at scala.tools.nsc.transform.ExplicitOuter$ExplicitOuterTransformer.transform(ExplicitOuter.scala:651)
        at scala.tools.nsc.ast.Trees$Transformer.transformUnit(Trees.scala:1186)
        at scala.tools.nsc.transform.ExplicitOuter$ExplicitOuterTransformer.scala$tools$nsc$transform$ExplicitOu\
ter$ExplicitOuterTransformer$$super$transformUnit(ExplicitOuter.scala:662)
        at scala.tools.nsc.transform.ExplicitOuter$ExplicitOuterTransformer$$anonfun$17.apply(ExplicitOuter.scal\
a:662)
        at scala.tools.nsc.transform.ExplicitOuter$ExplicitOuterTransformer$$anonfun$17.apply(ExplicitOuter.scal\
a:662)
        at scala.tools.nsc.symtab.SymbolTable.atPhase(SymbolTable.scala:77)
        at scala.tools.nsc.transform.ExplicitOuter$ExplicitOuterTransformer.transformUnit(ExplicitOuter.scala:66\
2)
        at scala.tools.nsc.transform.Transform$Phase.apply(Transform.scala:30)
        at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:220)
        at scala.tools.nsc.Global$GlobalPhase$$anonfun$1.apply(Global.scala:209)
        at scala.tools.nsc.Global$GlobalPhase$$anonfun$1.apply(Global.scala:209)
        at scala.Iterator$class.foreach(Iterator.scala:341)
        at scala.collection.mutable.ListBuffer$$anon$0.foreach(ListBuffer.scala:244)
        at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:209)
        at scala.tools.nsc.Global$Run.compileSources(Global.scala:474)
        at scala.tools.nsc.Global$Run.compile(Global.scala:545)
        at scala.tools.nsc.Main$.process(Main.scala:58)
        at scala.tools.nsc.Main$.main(Main.scala:80)
        at scala.tools.nsc.Main.main(Main.scala)
[died while typechecking the translated pattern match:]
l.apply()                                                        

what expected I think this is valid code. Even if it is not, the compiler should not crash.
[back to overview]
Changes of this bug report
Nikolay  edited on  2007-01-16 11:02:45.0
contribution #296
Martin  edited on  2007-01-23 20:02:08.0
I could not reproduce with the latest version of the compiler. I assume its' fixed by some of the recent changes to pattern matching.