Skip to content

Rethrows checking allows invalid try in nested function #63191

Open
@hamishknight

Description

@hamishknight

The following compiles, but fails at runtime with EXC_BAD_INSTRUCTION:

struct S: Error {}

func baz() throws { throw S() }

func foo(_ fn: () throws -> Void) rethrows {
  func bar() throws {
    try baz()
  }
  try bar()
}
foo({})

We shouldn't allow try baz() to count as a conditional throw for rethrowing checking.

rdar://104605214

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepts invalidBug: Accepts invalidbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareerror handlingrun-time crashBug → crash: Swift code crashed during executiontype checkerArea → compiler: Semantic analysis

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions