Skip to content

Compiler crashes with code involving return inside try #10183

Open
@scabug

Description

@scabug

Scala 2.12 (both .0 and .1) compiler crashes when trying to compile my project. Specifically, it throws the following exception:

scala.tools.asm.tree.analysis.AnalyzerException: While processing switchwalker/Inspector.inspect
....
Caused by: scala.tools.asm.tree.analysis.AnalyzerException: Error at instruction 350: Incompatible stack heights
....
Caused by: scala.tools.asm.tree.analysis.AnalyzerException: Incompatible stack heights
....
[error] Error while emitting switchwalker/Inspector
[error] While processing switchwalker/Inspector.inspect

The construct that hurts the compiler seems to look something like this:

def inspect(): Result
{
  var switch: Switch = null
  ....
  try {
  /*** 1 ***/   switch = Switch(...) match {
        case Right(sw) => sw
        case Left(result) => return result
     }//match
     ...
  } catch {
     ....
  /*** 2 ***/ } finally {
      if (switch != null)
         switch.cleanup()
  }//finally

  result
}//inspect

Commenting out the assignment in the point marked /*** 1 / (without touching the following "match" clause) or removing the "finally" clause in the point / 2 ***/ stops the compiler from crashing. But no other changes in the same file (those I've tried) help.

The project compiles without any problems with Scala 2.11. I could not reproduce the crash with the smaller example project, containing the similar constructs. So I supply the full stack trace and the source file that causes the compiler to crash in the attachment. The points in the source file where the changes can help the compiler to survive are also marked /*** 1 / and / 2 ***/.

I also can supply the entire project if required (since it is not secret nor very big), so the crash could be reproduced.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions