You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I have two traits, Test1 and Test2, and Test2 is a subtype of Test1, and I define two extractors for these traits, a java.lang.VerifyError is thrown at runtime when I try to use the extractors in a pattern match statement. Consider the REPL output:
$$ scala
Welcome to Scala version 2.8.0.r0-b20100714201327 (JavaHotSpot(TM) ServerVM, Java1.6.0_20).
Type in expressions to have them evaluated.
Type:help for more information.
scala>traitTest1 {
|deff1:Int| }
defined traitTest1
scala>traitTest2extendsTest1 {
|deff2:Int| }
defined traitTest2
scala>objectTest1 {
|defunapply(t1: Test1):Option[(Int)] =Some(t1.f1)
| }
defined module Test1
scala>objectTest2 {
|defunapply(t2: Test2):Option[(Int,Int)] =Some(t2.f1, t2.f2)
| }
defined module Test2
scala>caseclassTest2Impl() extendsTest2{
|deff1=1|deff2=2| }
defined classTest2Impl
scala>vala:AnyRef=Test2Impl()
a:AnyRef=Test2Impl()
scala> a match {
|caseTest2(a,b) => println("a: "+ a)
|caseTest1(a) => println(a)
| }
java.lang.VerifyError: (class: , method: <init> signature: ()V) Accessing value from uninitialized register 4
at RequestResult$$.<init>(<console>:9)
at RequestResult$$.<clinit>(<console>)
at RequestResult$$scala_repl_result(<console>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at scala.tools.nsc.Interpreter$$Request$$$$anonfun$$loadAndRun$$1$$$$anonfun$$apply$$18.apply(Interpreter.scala:981)
at scala.tools.nsc.Interpreter$$Request$$$$anonfun$$loadAndRun$$1$$$$anonfun$$apply$$18.apply(Interpreter.scala:981)
at scala.util.control.Exception$$Catch.apply(Exception....
scala>
This problem isn't just limited to the REPL, but also for compiled code. See the attached file (which is just this REPL session in a file)
The text was updated successfully, but these errors were encountered:
Margus Freudenthal (margus) said:
I stumbled on a similar problem when trying to match parse tree produced by ANTLR treebuilder. The code runs under Scala 2.7 and fails under 2.8 (VerifyError). Interesting point: if I delete the line "g = " " from + ".." + to", then the program runs correctly under Scala 2.8.
@paulp said:
The test_match attachment minimized is:
deffoo(h: Any, t: List[Any]) = h match {
case5:: _ => ()
caseList(from) => from
}
This one is a buzzkill because it looks to arise from the pattern matcher cheating on case List(...) in a way it doesn't with anything else so as to offer the same performance (i.e. not use unapplySeq.) Thus there is special code for treating List like it's a series of :: and someone, me we can presume, has broken that code.
I'm not sure it's the same issue as the reporter's, except that the pattern matcher can legitimately be viewed as one giant issue.
When I have two traits, Test1 and Test2, and Test2 is a subtype of Test1, and I define two extractors for these traits, a java.lang.VerifyError is thrown at runtime when I try to use the extractors in a pattern match statement. Consider the REPL output:
This problem isn't just limited to the REPL, but also for compiled code. See the attached file (which is just this REPL session in a file)
The text was updated successfully, but these errors were encountered: