Aladdin - Scala Bugtracking
[#550] project: compiler priority: high category: bug
submitter assigned to status date submitted
Stephane Martin fixed 2006-03-16 19:37:44.0
subject Runtime error in scala.tools.nsc.symtab.Types
code
abstract class Monoid[a] {
  def unit: a
}

object test {
  def sum[a](xs: List)(implicit m: Monoid[a]): a =
    if (xs.isEmpty) m.unit else xs.head
  sum(List(1,2,3))
}
what happened
test.scala:7 error: something is wrong (wrong class file?): class List with type parameters [a] gets applie\
d to arguments ()
    if (xs.isEmpty) m.unit else xs.head
                                  ^
Exception in thread "main" java.lang.Error: head of empty list
        at scala.Predef$.error(Predef.scala:155)
        at scala.Nil$.head(List.scala:1062)
        at scala.Nil$.head(List.scala:1060)
        at scala.tools.nsc.symtab.Types$SubstMap.subst$0(Types.scala:1276)
        at scala.tools.nsc.symtab.Types$SubstMap.apply(Types.scala:1280)
        at scala.tools.nsc.symtab.Types$SubstMap.apply(Types.scala:1265)
        at scala.List$.loop$0(List.scala:232)
        at scala.List$.mapConserve(List.scala:249)
        at scala.tools.nsc.symtab.Types$TypeMap.mapOver(Types.scala:1144)
        at scala.tools.nsc.symtab.Types$SubstMap.apply(Types.scala:1287)
        at scala.tools.nsc.symtab.Types$Type.subst(Types.scala:208)
[...]
what expected
[back to overview]
Changes of this bug report
Stephane  edited on  2006-03-16 19:38:01.0
Martin  edited on  2006-03-20 13:03:59.0