Skip to content

Potentially unnecessary athrow is emitted when return is inside a nested block #5064

Closed
@biboudis

Description

@biboudis

The following snippet generates an athrow instruction if return is used inside a nested block.

class Test {
  def fun: Int = {
    var a = 10;
    { // throw is generated only when return is nested
      return a
    }
  }
}

This seems like e a backend issue and may not be related with how return expressions are translated (because NonLocalReturns phase has no effect).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions