https://issues.dlang.org/show_bug.cgi?id=21443

          Issue ID: 21443
           Summary: scope (failure) with a return breaks safety
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: [email protected]
          Reporter: [email protected]

-----
ulong get () @safe nothrow
{
    scope (failure) return 10;
    throw new Error("");
}

void main () @safe
{
    assert(get() == 10);  // passes
}
-----

It should not be allowed to do a `return` inside of a `scope (failure)`,
because currently scope failure also handles Errors. In this case any Error
thrown is not re-thrown, and the function simply returns a value.

That's a big hole in safety IMO.

--

Reply via email to