Exception handling

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jul 14 14:20:29 PDT 2017


On Friday, July 14, 2017 9:06:52 PM MDT Moritz Maxeiner via Digitalmars-d-
learn wrote:
> On Friday, 14 July 2017 at 20:22:21 UTC, Ali Çehreli wrote:
> > Although it's obvious to us that there are only those two
> > exceptions, the compiler cannot in general know that.
>
> Not in general, no, but if the function's body (and the body of
> all functions it calls) are available, the compiler can aggregate
> the exception set and indeed perform a more precise nothrow
> analysis.

Except that that's not how it actually works, and it would probably violate
the language spec if it did. Basically, the compiler _never_ looks at the
bodies of other functions when determining which attributes apply. It always
uses the signatures. Even if attribute inferrence it involved, the
function's attributes (and therefore signature) are determined before any
function that's calling it is examined to determine whether it's violating
nothrow or @nogc or whatnot (or whether it can be nothrow or @nogc or
whatnot if its attributes are being inferred). For it to work otherwise
would actually cause a lot of problems with .di files.

- Jonathan M Davis




More information about the Digitalmars-d-learn mailing list