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
java.lang.VerifyError: Inconsistent stack height (simple for loop/ foreach) #5380
Comments
Imported From: https://issues.scala-lang.org/browse/SI-5380?orig=1 |
@magarciaEPFL said: |
@magarciaEPFL said: Input program: def main(args: Array[String]) {
for (x <- List(1))
return try { 1 } catch { case _ => 0 }
0
} After cleanup: @SerialVersionUID(0) final <synthetic> class $anonfun$main$1 extends scala.runtime.AbstractFunction1 with Serializable {
final def apply(x: Int): Nothing =
throw new scala.runtime.NonLocalReturnControl(
$anonfun$main$1.this.nonLocalReturnKey1$1, {
var exceptionResult1: Object = _;
try {
exceptionResult1 = {
1;
scala.runtime.BoxedUnit.UNIT
}
} catch {
case _ => {
exceptionResult1 = {
0;
scala.runtime.BoxedUnit.UNIT
}
}
};
exceptionResult1
});
final <bridge> def apply(v1: Object): Object = $anonfun$main$1.this.apply(scala.Int.unbox(v1));
<synthetic> <paramaccessor> private[this] val nonLocalReturnKey1$1: Object = _;
def <init>(nonLocalReturnKey1$1: Object): anonymous class $anonfun$main$1 = {
$anonfun$main$1.this.nonLocalReturnKey1$1 = nonLocalReturnKey1$1;
$anonfun$main$1.super.<init>();
()
}
}; What Scala.Net emits: .method public hidebysig virtual final instance class [mscorlib]System.Exception
apply(int32 x) cil managed
{
// Code size 52 (0x34)
.maxstack 2
.locals init (object V_0)
IL_0000: ldarg.0
IL_0001: ldfld object ABC$/$anonfun$main$1::nonLocalReturnKey1$1
IL_0006: ldnull
IL_0007: stloc.0
.try
{
IL_0008: ldc.i4.1
IL_0009: pop
IL_000a: ldsfld class [scalalib]scala.runtime.BoxedUnit [scalalib]scala.runtime.BoxedUnit::UNIT
IL_000f: stloc.0
IL_0010: leave IL_002d
IL_0015: leave IL_002d
} // end .try
catch [mscorlib]System.Exception
{
IL_001a: pop
IL_001b: ldc.i4.0
IL_001c: pop
IL_001d: ldsfld class [scalalib]scala.runtime.BoxedUnit [scalalib]scala.runtime.BoxedUnit::UNIT
IL_0022: stloc.0
IL_0023: leave IL_002d
IL_0028: leave IL_002d
} // end handler
IL_002d: ldloc.0
IL_002e: newobj instance void [scalalib]scala.runtime.NonLocalReturnControl::.ctor(object,
object)
IL_0033: throw
} // end of method $anonfun$main$1::apply And the error message: ABC$+$anonfun$main$1::apply][offset 0x00000008] Attempt to enter a try block with nonempty stack. |
Hai Bison (haibison) said: |
@paulp said: |
This is a simple function:
Please do not mind about the purpose of the function. I tried but could not know how to code to show the purpose. I shortened it from my code.
The code can be compiled. It raises exception at runtime. I got this exception:
I guess this issue is similar to this one: #203
The text was updated successfully, but these errors were encountered: