New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
match in finally&static init causes VerifyError ("register 16 contains wrong type") #5929
Comments
Imported From: https://issues.scala-lang.org/browse/SI-5929?orig=1 |
@paulp said: org.scalacheck:scalacheck_2.10.0-M3:1.10-SNAPSHOT Why would it be downloading that to build against M4. |
@retronym said: object test {
null match {
case _ =>
}
try {
()
} finally {
null match {
case _ =>
}
}
}
|
@paulp said: |
@retronym said: Highlights of the voyage: [[syntax trees at end of constructors]] // scalatest-bug.scala
package <empty> {
object test extends Object {
def <init>(): ... = {
test.super.<init>();
{
case <synthetic> val x1: Null = null;
case3(){
matchEnd2(scala.runtime.BoxedUnit.UNIT)
};
matchEnd2(x: scala.runtime.BoxedUnit){
()
}
};
try {
()
} finally {
case <synthetic> val x1: Null = null;
case3(){
matchEnd2(scala.runtime.BoxedUnit.UNIT)
};
matchEnd2(x: scala.runtime.BoxedUnit){
()
}
};
()
}
}
} Bytecode: private test$();
Code:
Stack=1, Locals=6, Args_size=1
0: aload_0
1: invokespecial #16; //Method java/lang/Object."<init>":()V
4: aload_0
5: putstatic #18; //Field MODULE$:Ltest$;
8: aconst_null
9: astore_1
10: getstatic #24; //Field scala/runtime/BoxedUnit.UNIT:Lscala/runtime/BoxedUnit;
13: astore_2
14: aconst_null
15: astore 5
17: getstatic #24; //Field scala/runtime/BoxedUnit.UNIT:Lscala/runtime/BoxedUnit;
20: astore_3
21: goto 33
24: astore 4
26: aconst_null
27: astore 5
29: getstatic #24; //Field scala/runtime/BoxedUnit.UNIT:Lscala/runtime/BoxedUnit;
32: astore_3
33: aload 4
35: athrow |
@bvenners said: |
@paulp said: |
@retronym said: class testS {
null match {
case _ => ""
}
try {
""
} finally {
val x = null match {
case _ => ""
}
()
}
}
class testS extends Object {
def <init>(): testS = {
testS.super.<init>();
{
case <synthetic> val x1: Null = null;
case3(){
matchEnd2("")
};
matchEnd2(x: String){
x
}
};
try {
""
} finally {
val x: String = {
case <synthetic> val x1: Null = null;
case3(){
matchEnd2("")
};
matchEnd2(x: String){
x
}
};
()
};
()
}
};
Code:
Stack=2, Locals=7, Args_size=1
0: aload_0
1: invokespecial #10; //Method java/lang/Object."<init>":()V
4: aconst_null
5: astore_1
6: ldc #12; //String
8: astore_2
9: aload_2
10: pop
11: ldc #12; //String
13: aconst_null
14: astore 6
16: ldc #12; //String
18: astore_3
19: goto 30
22: astore 4
24: aconst_null
25: astore 6
27: ldc #12; //String
29: astore_3
30: aload_3
31: astore 5
33: aload 4
35: athrow
Exception table:
from to target type
11 13 22 any
|
@adriaanm said: I improved the pattern matcher a bit to avoid emitting all these BoxedUnits, new pattern matcher: 0: aload_0
1: invokespecial #10; //Method java/lang/Object."<init>":()V
4: goto 8 // this should be a return! (it's completely wrong to jump to 8)
7: astore_1
8: aload_1
9: athrow correct bytecode: 0: aload_0
1: invokespecial #10; //Method java/lang/Object."<init>":()V
4: return
5: astore_1
6: aload_1
7: athrow test code (bytecode above is for testIncompatStackHeight) class testIncompatStackHeight {
null match { case _ => }
try { "" } finally { null match { case _ => } }
}
class testExpectedObjectRef {
null match { case _ => }
try { } finally { null match { case _ => } }
} |
@adriaanm said (edited on Jun 28, 2012 1:53:25 PM UTC): |
@paulp said: |
@adriaanm said: def x = {
null match { case _ => }
try { 1 } finally { while(true) { } }
} |
@paulp said: [log icode] Added (method while$11,method while$11) to labels. Why is the label parameter owned by NoSymbol I guess? "def x" renamed to "def quux" for clarity:
|
@paulp said: |
@dragos said: A forward jump triggers a 'scanForLabels' call, trying to find where the target of that jump is, and create a label. Later on, when the LabelDef is generated, that label is anchored and assigned an offset (or basic block number). scanForLabel will blindly add all |
@dragos said (edited on Jun 28, 2012 3:33:15 PM UTC): |
@paulp said: |
@paulp said: |
@dragos said: The invariant I was counting on was that, for all LabelDefs, ldef.symbol.info.params == ldef.params.map(_.symbol). So the symbols in the LabelDef tree (a list of Idents with symbols), are the same as the ones in the method type of the label symbol. It's not always the case :( I'll stop now. :) |
@dragos said: |
@paulp said: /** A foreach traverser which prunes anytime a new scope would be
* opened - that is, it doesn't recurse into Blocks, Templates,
* or catch/finally blocks. (Am I missing anything?)
* You might use this if you wanted to traverse the statements of
* a DefDef body without running into trees which are not in scope
* for the whole body.
*/
class ForeachTreeInScopeTraverser(f: Tree => Unit) extends Traverser {
override def traverse(t: Tree) {
f(t)
t match {
case Try(body, _, _) => traverse(body)
case _: Template | _: Block => // prune
case _ => super.traverse(t)
}
}
} |
@paulp said: |
@adriaanm said: |
I do not know how to boil this down to a small example, unfortunately. This happens when I try and compile ScalaTest under Scala 2.10.0-M4. I'm not sure this is a Scala 2.10 issues. May be some other fluke, but here's the stack trace and instructions on how to reproduce it:
runtest:
[scalatest] *** RUN ABORTED *** (21 seconds, 76 milliseconds)
[scalatest] java.lang.VerifyError: (class: org/scalatest/BeforeAndAfterEachFunctions$class, method: runTest signature: (Lorg/scalatest/BeforeAndAfterEachFunctions;Ljava/lang/String;Lorg/scalatest/Reporter;Lorg/scalatest/Stopper;Lscala/collection/immutable/Map;Lorg/scalatest/Tracker;)V) Register 16 contains wrong type
[scalatest] at org.scalatest.BeforeAndAfterFunctionsExtendingSuite.(BeforeAndAfterFunctionsSuite.scala:415)
[scalatest] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[scalatest] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
[scalatest] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
[scalatest] at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
[scalatest] at java.lang.Class.newInstance0(Class.java:355)
[scalatest] at java.lang.Class.newInstance(Class.java:308)
[scalatest] at org.scalatest.tools.DiscoverySuite$$anonfun$1.apply(DiscoverySuite.scala:40)
[scalatest] at org.scalatest.tools.DiscoverySuite$$anonfun$1.apply(DiscoverySuite.scala:34)
[scalatest] at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:239)
[scalatest] ...
To (attempt to) reproduce it, check out this branch:
https://scalatest.googlecode.com/svn/branches/r18for210M4
And type:
ant compile; ant gencode; ant test
The text was updated successfully, but these errors were encountered: