www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - deliberately failing compilation when errors are in embedded DSL

reply "Dmitri Makarov" <dmakarv gmail.com> writes:
I'm developing an embedded DSL using CTFE. The DSL code is 
translated into D code and mixin-ed into the D code of user's 
application.  In order to provide meaningful error messages the 
DSL compiler always intercepts all errors in the DSL code and 
reports them at compile-time using pragma(msg, ...). The DSL 
compiler never generates incorrect D code to avoid reporting 
errors in the generated D code obscurely related to the original 
DSL code.  The problem is that the D compiler always exits as if 
the compilation was successful (for D compiler it is successful, 
since the generated D code is correct).

Is there any way to force the D compiler to fail compilation 
other than generating incorrect D code when translating erroneous 
DSL code?
Feb 18 2015
parent Steven Schveighoffer <schveiguy yahoo.com> writes:
On 2/18/15 12:43 PM, Dmitri Makarov wrote:
 I'm developing an embedded DSL using CTFE. The DSL code is translated
 into D code and mixin-ed into the D code of user's application.  In
 order to provide meaningful error messages the DSL compiler always
 intercepts all errors in the DSL code and reports them at compile-time
 using pragma(msg, ...). The DSL compiler never generates incorrect D
 code to avoid reporting errors in the generated D code obscurely related
 to the original DSL code.  The problem is that the D compiler always
 exits as if the compilation was successful (for D compiler it is
 successful, since the generated D code is correct).

 Is there any way to force the D compiler to fail compilation other than
 generating incorrect D code when translating erroneous DSL code?
static assert(0, message) -Steve
Feb 18 2015