[#441] | project: compiler | priority: high | category: bug | |
---|---|---|---|---|
submitter | assigned to | status | date submitted | |
Burak | Philippe | fixed | 2005-06-08 11:21:30.0 | |
subject | runtime crash in equality (boxing/unboxing?) | |||
code |
object Test with Application { def bug() = { val foo: Array[String] = Array("1","2","3"); if( foo.length == null ) // == 0 makes more sense, but still Console.println("plante"); // this code leads to runtime crash else Console.println("plante pas"); } bug() } |
|||
what happened | Exception in thread "main" java.lang.ExceptionInInitializerError at Test.main(test.scala:45) Caused by: java.lang.NullPointerException at scala.runtime.RunTime.unbox_ivalue(RunTime.java:201) at Test$.bug(test.scala:5) at Test$. |
|||
what expected | silent compilation, and "plante pas" printed on the screen
It seems the last distribution would box the result of |
|||
[back to overview] |
Burak edited on 2005-06-08 11:31:01.0 |
changed title.
This bug is more subtle than it seems. Do we really want
to allow things like
If we choose to not change this, should we optimize such comparisons by replacing them with |
Burak edited on 2005-06-08 12:37:07.0 |
Martin edited on 2005-06-08 16:17:01.0 |
It's not a bug. Every int as an Any, and comparison is defined on Any. Of course the runtime crash is a bug, but this seems already fixed in the last distribution. |
Burak edited on 2005-06-08 17:06:55.0 |
Well, apparently it was reintroduced, or newly introduced, because Sebastien found this bug when using the latest CVS snapshot. |
Burak edited on 2005-06-08 17:20:30.0 |
Well, apparently it was reintroduced, or newly introduced, because Sebastien found this bug when using the latest CVS snapshot. |
Burak edited on 2005-06-08 17:22:36.0 |
I replaced compiler error (foo.length is an int, which cannot be compared to null). into "plante pas" printed on screen in field "what expected". |
Martin edited on 2005-06-08 17:52:09.0 |
Well but in that case it should not be assigned to me. |
Martin edited on 2006-03-30 14:48:34.0 |