Aladdin - Scala Bugtracking
[#1013] project: compiler priority: low category: bug
submitter assigned to status date submitted
Iulian Martin fixed 2007-03-23 10:42:39.0
subject [contrib #385] VerifyError in secondary constructor
code
object Bug extends Application {
  class Graph[V](n: List[V], e: List[Pair[V,V]]) {
    def this(e: List[Pair[V,V]]) = this(
      (e.map(p=>p._1) ::: e.map(p=>p._2)), e);
  }
  new Graph(Nil, Nil);
}
what happened
$ scalac -version
Scala compiler version 2.4.0-RC2 -- (c) 2002-2007 LAMP/EPFL
$ scalac Bug.scala
$ scala Bug
java.lang.VerifyError: (class: Bug$Graph, method:  signature: (Lscala/List;)V) Expecting to find object/ar\
ray on stack
        at Bug$.(Bug.scala:6)
        at Bug$.(Bug.scala)
        at Bug.main(Bug.scala)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:76)
        at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:106)
        at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
$ java -version
java version "1.5.0_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-b03)
Java HotSpot(TM) Client VM (build 1.5.0_07-b03, mixed mode, sharing)
$ javap -c Bug
Compiled from "Bug.scala"
public final class Bug extends java.lang.Object{
public static final int $tag();
  Code:
   0:   getstatic       #11; //Field Bug$.MODULE$:LBug$;
   3:   invokevirtual   #13; //Method Bug$.$tag:()I
   6:   ireturn

public static final void main(java.lang.String[]);
  Code:
   0:   getstatic       #11; //Field Bug$.MODULE$:LBug$;
   3:   aload_0
   4:   invokevirtual   #17; //Method Bug$.main:([Ljava/lang/String;)V
   7:   return

public static final void executionStart_$eq(long);
  Code:
   0:   getstatic       #11; //Field Bug$.MODULE$:LBug$;
   3:   lload_0
   4:   invokevirtual   #21; //Method Bug$.executionStart_$eq:(J)V
   7:   return

public static final long executionStart();
  Code:
   0:   getstatic       #11; //Field Bug$.MODULE$:LBug$;
   3:   invokevirtual   #25; //Method Bug$.executionStart:()J
   6:   lreturn

}
what expected No crash or an (implementation restriction) error.
[back to overview]
Changes of this bug report
Iulian  edited on  2007-03-23 10:46:38.0
The problem is that the argument to the other constructor needs the two closures, and each closure needs an 'outer'. The outer they see is the uninitialized instance we are currently constructing. It would be probably easy to issue a type-error, but it's troubling to note that the 'outer' instance is not needed here!
Martin  edited on  2007-03-30 18:16:52.0