Status status = __traits(compilesReportError, {string b=10; }) => status.msg=Error: cannot....

Nicholas Wilson iamthewilsonator at hotmail.com
Wed Feb 7 21:13:19 UTC 2018


On Wednesday, 7 February 2018 at 20:29:44 UTC, Timothee Cour 
wrote:
> is there any way to get error from speculative execution 
> (`__traits(
> compiles, ...)`)? would be useful in tests; If not currently 
> how hard
> would that be to implement? eg:
>
> ```
>
> struct Status{bool ok; string msg;}
>
> Status status = __traits(compilesReportError, {string b=10;})
> assert(!status.ok);
> assert(status.msg==`main.d(15) Error: cannot implicitly convert
> expression 10 of type int to string`);
> ```

Probably not very hard. Would make for some nice diagnostics,but 
very flakey tests. Compiler errors are frequently changed.


More information about the Digitalmars-d mailing list