digitalmars.D.bugs - [Issue 21443] New: scope (failure) with a return breaks safety
- d-bugmail puremagic.com (29/29) Dec 02 2020 https://issues.dlang.org/show_bug.cgi?id=21443
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: nobody puremagic.com Reporter: andrej.mitrovich gmail.com ----- 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. --
Dec 02 2020