mixin does not work as expected

vit vit at vit.vit
Wed Jan 5 09:14:08 UTC 2022


On Wednesday, 5 January 2022 at 08:40:15 UTC, rempas wrote:
> I'm trying to use mixins and enums to "expand" code in place 
> but the results are not what I expected and I'm getting an 
> weird error. I have created the smallest possible example to 
> reproduce the error and it is the following:
>
> [...]

And you cannot have else statement in different mixin:

```d

extern (C) void main() {
     ///OK:
     mixin("static if(true){}else{}");

     ///ERROR:
     mixin("static if(true){}");
     mixin("else{}");
}
```


More information about the Digitalmars-d-learn mailing list