DConf 2013 Day 3 Talk 2: Code Analysis for D with AnalyzeD by Stefan Rohe
Adam D. Ruppe
destructionator at gmail.com
Wed Jun 12 13:29:15 PDT 2013
On Wednesday, 12 June 2013 at 20:23:43 UTC, Andrej Mitrovic wrote:
> Are you sure? A compiler can tell whether a function /can/ throw
> (hence why nothrow works), so I assume it has information on
> where an exception is thrown.
Consider this:
extern(D) void foo();
void bar() { foo(); }
That's legal D code, and foo could throw anything, and bar would
have no idea what it is.
Looking at dmd's source, looks like Walter actually wrote code to
parse a throws Exception, etc. to be part of the function
signature but stripped it out (surely because that's annoying).
Without a list like that, the compiler just can't be sure what
happens. It could maybe try to figure it out based on the source
it has available, and at least get an incomplete list, but
currently it doesn't attempt to do that.
That might not be too hard to do actually, when outputting the
ddoc, dive into the function body for throw statements and build
up a list. If the call tree goes down to anything it doesn't
recognize and is not marked nothrow, then it could say "I'm not
sure if this is everything but this is what I found".
More information about the Digitalmars-d-announce
mailing list