__traits(compileError, {})

bitwise via Digitalmars-d digitalmars-d at puremagic.com
Mon Sep 11 16:07:33 PDT 2017


On Monday, 11 September 2017 at 11:07:46 UTC, Timon Gehr wrote:
>
> The dangerous thing about this suggestion is that it makes the 
> compilation errors DMD implements de facto part of the 
> semantics of the D language. I.e. improving compiler 
> diagnostics becomes a breaking language change.

I guess this is true if people start trying to parse the error 
messages to extract details, but shouldn't there be some level of 
standardization for tools anyways?


Thinking about this a little further though, I think the behavior 
I had in mind could be implemented without changes.

My example from above could become this:

`
static if(!__traits(compiles, { doIt(); }))
{
     // now, we know it's about to fail
     pragma(msg, "doIt() failed because....");
}

// do it anyways and let the compiler output it's regular error 
message
doIt();
`



More information about the Digitalmars-d mailing list