<div dir="ltr"><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 1, 2016 at 11:26 PM, ag0aep6g 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 09/01/2016 11:01 PM, Rory McGuire via Digitalmars-d-announce 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>
There is no CTFE error in your example. It doesn't compile in the first place, even without attempting any CTFE.<br>
<br>
[...]<span class="gmail-"><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<br>
errors. (Not invalid, just unsupported at CT).<br>
</blockquote>
<br></span>
Maybe. It isn't obvious to me that it would be a good idea, but it's not obviously terrible either.<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">
The ctfe engine would have to "go past" the try anyway, right? This is<br>
the part I don't understand. Is it because ctfe actually hasn't started<br>
yet and some other analysis is freaking out?<br>
</blockquote>
<br></span>
It's just a compiler error. The snippet on its own fails compilation and there is no CTFE in there. Something like `static assert(_checkCTFE());` would involve CTFE. But that's not needed to trigger the error.<br>
</blockquote></div><br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">Yeah, I'm using an enum to force the evaluation during CT, and its dying before CTFE from what I can tell. Here is another example:<div><br></div><div><div>void main() {</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">     </span>enum ret = ctfefunc();</div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>mixin(ret);</div><div>}</div><div><br></div><div><br></div><div>string ctfefunc() {</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>static if (!assertCTFE!true) {</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">         </span>throw new Exception("Only during ctfe please...");</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">   </span>}</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">      </span>return `import std.stdio; writeln("ctfe generated this");`;</div><div>}</div><div><br></div><div>template assertCTFE(bool b) {</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">     </span>enum assertCTFE = __traits(compiles, _checkCTFE1());</div><div>}</div><div>void _checkCTFE1() {</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>static if (__ctfe) {</div><div><br></div><div><span class="gmail-Apple-tab-span" style="white-space:pre">  </span>}</div><div>}</div></div><div><br></div><div><br></div><div><br></div><div><br></div></div></div>