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
I use Scala 3.1.0 (17.0.1, Java OpenJDK 64-Bit Server VM).
Minimized code
In this setting, I found a Verify Error when using mutable fields in parametric enumeration as follows:
enumA(c: Int):caseB(vark:Int) extendsA(k)
Output
Exception in thread "main" java.lang.VerifyError:Badtypeon operand stack
ExceptionDetails:Location:A$B.<init>(I)V@7: invokevirtual
Reason:Type uninitializedThis (current frame, stack[1]) is not assignable to 'A$B'CurrentFrame:bci: @7flags: { flagThisUninit }
locals: { uninitializedThis, integer }
stack: { uninitializedThis, uninitializedThis }
Bytecode:0000000: 2a1b b500 1f2a 2ab6 0022 b700 24b1
at java.base/java.lang.Class.getDeclaredMethods0(NativeMethod)
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3402)
at java.base/java.lang.Class.getMethodsRecursive(Class.java:3543)
at java.base/java.lang.Class.getMethod0(Class.java:3529)
at java.base/java.lang.Class.getMethod(Class.java:2225)
at dotty.tools.scripting.ScriptingDriver.collectMainMethods$3(ScriptingDriver.scala:79)
at dotty.tools.scripting.ScriptingDriver.$anonfun$3(ScriptingDriver.scala:88)
at scala.collection.immutable.List.flatMap(List.scala:293)
at dotty.tools.scripting.ScriptingDriver.detectMainClassAndMethod(ScriptingDriver.scala:89)
at dotty.tools.scripting.ScriptingDriver.compileAndRun(ScriptingDriver.scala:34)
at dotty.tools.scripting.Main$.main(Main.scala:43)
at dotty.tools.MainGenericRunner$.run$1(MainGenericRunner.scala:168)
at dotty.tools.MainGenericRunner$.main(MainGenericRunner.scala:175)
at dotty.tools.MainGenericRunner.main(MainGenericRunner.scala)
Expectation
However, the following code does not throw any error:
enumA(c: Int):caseB(k: Int) extendsA(k)
I think that it happens because the compiled JVM bytecode tries to use the mutable field k before its initialization in A(k).
The text was updated successfully, but these errors were encountered:
smarter
changed the title
VerifyError when enum class case has var parameter
VerifyError when class has var parameter and extends another class
Feb 7, 2022
Uh oh!
There was an error while loading. Please reload this page.
Originally posted at https://contributors.scala-lang.org/t/verify-error-when-using-mutable-fields-in-parametric-enumeration/5531
Compiler version
I use Scala 3.1.0 (17.0.1, Java OpenJDK 64-Bit Server VM).
Minimized code
In this setting, I found a Verify Error when using mutable fields in parametric enumeration as follows:
Output
Expectation
However, the following code does not throw any error:
I think that it happens because the compiled JVM bytecode tries to use the mutable field
k
before its initialization inA(k)
.The text was updated successfully, but these errors were encountered: