Closed
Description
When trying to compile this syntactically correct, but nonsensical program the compiler crashes:
object Bug {
val x = 42
x match {case {42}.toString => 42}
}
Beginning of the trace:
exception while transforming Bug.x match
{
case 42.toString() => 42
} of class class dotty.tools.dotc.ast.Trees$Match # 79
exception while transforming () extends Object() {
val x: Int = 42
Bug.x match
{
case 42.toString() => 42
}
} of class class dotty.tools.dotc.ast.Trees$Template # 81
exception while transforming @scala.annotation.internal.SourceFile("examples/bug.scala") final module class
Bug$
() extends Object() {
val x: Int = 42
Bug.x match
{
case 42.toString() => 42
}
} of class class dotty.tools.dotc.ast.Trees$TypeDef # 82
exception while transforming package <empty> {
final lazy module val Bug: Bug$ = new Bug$()
@scala.annotation.internal.SourceFile("examples/bug.scala") final module class
Bug$() extends Object() {
val x: Int = 42
Bug.x match
{
case 42.toString() => 42
}
}
} of class class dotty.tools.dotc.ast.Trees$PackageDef # 83
exception occurred while compiling examples/bug.scala
Exception in thread "main" java.util.NoSuchElementException: head of empty list
at scala.collection.immutable.Nil$.head(List.scala:420)
at scala.collection.immutable.Nil$.head(List.scala:417)
at dotty.tools.dotc.transform.PatternMatcher$Translator$ScalacPatternExpanders$ScalacPatternExpander$class.applyMethodTypes(PatternMatcher.scala:1863)
at dotty.tools.dotc.transform.PatternMatcher$Translator$ScalacPatternExpanders$alignPatterns$.applyMethodTypes(PatternMatcher.scala:1904)
at dotty.tools.dotc.transform.PatternMatcher$Translator$ScalacPatternExpanders$alignPatterns$.apply(PatternMatcher.scala:1955)
at dotty.tools.dotc.transform.PatternMatcher$Translator$ScalacPatternExpanders$alignPatterns$.apply(PatternMatcher.scala:1978)
at dotty.tools.dotc.transform.PatternMatcher$Translator$MatchTranslator$ExtractorCall$.apply(PatternMatcher.scala:1412)
at dotty.tools.dotc.transform.PatternMatcher$Translator$MatchTranslator$BoundTree.extractor$lzycompute(PatternMatcher.scala:1127)
at dotty.tools.dotc.transform.PatternMatcher$Translator$MatchTranslator$BoundTree.extractor(PatternMatcher.scala:1127)
at dotty.tools.dotc.transform.PatternMatcher$Translator$MatchTranslator$BoundTree.paramType$1(PatternMatcher.scala:1185)
at dotty.tools.dotc.transform.PatternMatcher$Translator$MatchTranslator$BoundTree.extractorStep(PatternMatcher.scala:1201)
at dotty.tools.dotc.transform.PatternMatcher$Translator$MatchTranslator$BoundTree.nextStep(PatternMatcher.scala:1222)
at dotty.tools.dotc.transform.PatternMatcher$Translator$MatchTranslator$BoundTree.translate(PatternMatcher.scala:1231)
at dotty.tools.dotc.transform.PatternMatcher$Translator$MatchTranslator$class.translatePattern(PatternMatcher.scala:1338)
at dotty.tools.dotc.transform.PatternMatcher$Translator$OptimizingMatchTranslator.translatePattern(PatternMatcher.scala:72)
at dotty.tools.dotc.transform.PatternMatcher$Translator$MatchTranslator$class.translateCase(PatternMatcher.scala:1335)
at dotty.tools.dotc.transform.PatternMatcher$Translator$OptimizingMatchTranslator.translateCase(PatternMatcher.scala:72)
at dotty.tools.dotc.transform.PatternMatcher$Translator$MatchTranslator$$anonfun$29.apply(PatternMatcher.scala:1299)
at dotty.tools.dotc.transform.PatternMatcher$Translator$MatchTranslator$$anonfun$29.apply(PatternMatcher.scala:1299)
at scala.collection.immutable.List.map(List.scala:273)