Aladdin - Scala Bugtracking
[#91] project: compiler priority: medium category: bug
submitter assigned to status date submitted
Vincent Martin fixed 2003-08-27 18:21:02.0
subject "null" vs "_"
code
class Bug {
  def main(args: Array[String]) = {
    var msg: String = _; // no bug if "null" instead of "_"
    val f:  PartialFunction[Any, unit] = { case 42 => msg = "coucou" };
  }
}
what happened
Exception in thread "main" java.lang.AssertionError: void -> java.lang.Object
        at scalac.backend.jvm.GenJVM.genWidenConversion(GenJVM.java:929)
what expected No compiler crash.
[back to overview]
Changes of this bug report
Michel  edited on  2003-08-28 09:47:58.0
I know how to fix that problem in LambdaLift (because it's really a LambdaLift problem in my opinion) but it would be better fixed by transforming "_" into real values as soon as possible. This would make a fix of LambdaLift unnecessary and simplfy both back-ends which would not need to deal with them anymore.
Martin  edited on  2003-08-28 17:14:26.0
I changed the frontend so that now the right hand side of a var x: T = _ is always replaced by a default value. In the case where T is a type variable bounded by Any, that default value is a special constant definitions.ZERO of name and of type scala.All, which is mapped to null in phase Erasure.
Martin  edited on  2003-08-28 17:15:21.0
HTML got me there. The name of definitions.ZERO is

Martin  edited on  2003-08-28 17:16:15.0
Still no luck. The name of definitions.ZERO is "less-than zero greater-than". How does one express that in HTML?
Burak  edited on  2006-02-24 19:09:32.0
[Martin said] how to write < in HTML to enter in bugtracking system. here's how: To use the < sign, you would have to escape it like this: &lt;