Request for Comment assert(__ctfe)

Steven Schveighoffer schveiguy at gmail.com
Tue Apr 7 21:13:54 UTC 2020


On 4/7/20 12:53 PM, Johannes Pfau wrote:
> The example above actually already compiles with -betterC, as the check
> is done in codegen phase! But some betterC checks seem to be done in
> semantic. This doesn't work yet:
> 
> ------------------------
> string generateMixin(T)(string b)
> {
>      assert(__ctfe);
>      return typeid(T).stringof ~ " " ~ b ~ ";";
> }
> 
> void main() @nogc
> {
>      mixin(generateMixin!string("b"));
> }
> ------------------------
> dmd -betterC test.d -c
> test.d(4): Error: TypeInfo cannot be used with -betterC

Ironically, ctfe can't deal with TypeInfo today.

In the past, the issue was for functions that use TypeInfo is that the 
non-CTFE branch uses TypeInfo, and that can't be used in betterC, but 
the CTFE branch doesn't use TypeInfo, but the compiler wants to build 
the whole function.

So while this is still a problem, I don't think this fix will change that.

-Steve


More information about the Digitalmars-d mailing list