<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 1, 2016 at 11:05 PM, David Nadlinger via Digitalmars-d-announce <span dir="ltr"><<a href="mailto:digitalmars-d-announce@puremagic.com" target="_blank">digitalmars-d-announce@puremagic.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><span class="gmail-">On Thursday, 1 September 2016 at 21:01:46 UTC, Rory McGuire wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
I'm actually asking why we can't catch the ctfe error.<br>
</blockquote>
<br></span>
You can, by using __traits(compiles, …).<span class="gmail-"><br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
Surely the ctfe engine could be changed to catch unsupported code errors. (Not invalid, just unsupported at CT).<br>
</blockquote>
<br></span>
It already does, see above. How is this related to try/catch?<br>
<br>
 — David<br>
</blockquote></div><br></div><div class="gmail_extra">I was hoping that the error was coming from the CTFE engine as it ran the code, but it comes up before ctfe execution I guess.</div><div class="gmail_extra"><br></div><div class="gmail_extra">__traits(compiles, _some_function_that_calls_), thinks that the invalid code compiles even when it doesn't compile, e.g.:</div><div class="gmail_extra"><div class="gmail_extra"><br></div><div class="gmail_extra">template assertCTFE(bool b) {</div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre">       </span>enum assertCTFE = __traits(compiles, _checkCTFE1());</div><div class="gmail_extra">}</div><div class="gmail_extra">void _checkCTFE1() {</div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre">      </span>static if (__ctfe) { // this still stops compilation (probably because this is checked before __traits(compiled ...) is evaluated</div><div class="gmail_extra"><br></div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>}</div><div class="gmail_extra">}</div><div><br></div></div></div>