Getting the error from __traits(compiles, ...)
Walter Bright
newshound1 at digitalmars.com
Thu Nov 12 13:00:42 PST 2009
Walter Bright wrote:
> Bill Baxter wrote:
>> Any other thoughts about how to get the failure info? This is
>> probably the main complaint against __traits(compiles), that there's
>> no way to find out what went wrong if the code doesn't compile. Often
>> it can just be a typo. I know I've spent plenty of time looking at
>> static if(__traits(compiles, ...)) checks that weren't working only to
>> discover I switched an x for a y somewhere. Or passed the wrong
>> number of arguments.
>
> I agree it's a problem. Perhaps we can do:
>
> __traits(compiles_or_msg, ...)
>
> which would print the error messages, at least making it easier to track
> down.
Eh, scratch that dumb idea. Just remove the __traits(compiles, ...) and
replace it with ..., and you'll get the message!
More information about the Digitalmars-d
mailing list