Bug 8675 – Nothrow can't throw Errors

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-09-17T02:38:00Z
Last change time
2012-12-28T17:10:50Z
Keywords
rejects-valid
Assigned to
nobody
Creator
monarchdodra

Comments

Comment #0 by monarchdodra — 2012-09-17T02:38:12Z
A nothrow function will refuse an explicit call to "throw Error": nothrow void foo() { assert(1, "Some error"); assert(0, "Some error"); } //This is fine nothrow void bar() { throw new Error("Some error"); } //This is NOT fine Error: object.Error is thrown but not caught Error: function main.bar 'bar' is nothrow yet may throw nothrow void baz() { try { throw new Error("Some error"); } catch(Exception) { } } //This works though (!) //Obviously, the "Error" is not caught...
Comment #1 by github-bugzilla — 2012-09-18T12:07:24Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/d77b7c2bf456e99495d8a6644a6304995d1a3b20 fix Issue 8675 - Nothrow can't throw Errors - fixed by checking whether the thrown exception is derived from Error before complaining about uncaught throws https://github.com/D-Programming-Language/dmd/commit/fb733a0f5fc9fa49ee58fcf7a19ca8e35d2e98bc Merge pull request #1125 from dawgfoto/fix8675 fix Issue 8675 - Nothrow can't throw Errors