Why does this mixin fail to compile?

ryuukk_ ryuukk.dev at gmail.com
Mon Jul 1 09:25:39 UTC 2024


This simple mixin fails to compile, anyone know why?

```D
mixin implement;

mixin template implement() {
     mixin("struct _gen(T) {");
     mixin("}");
}

void main(){}
```

```
onlineapp.d-mixin-5(5): Error: `}` expected following members in 
`struct` declaration
onlineapp.d-mixin-5(5):        struct `_gen` starts here
onlineapp.d(6): Error: mixin `__anonymous` incomplete mixin 
declaration `}`
onlineapp.d(2): Error: mixin `onlineapp.implement!()` error 
instantiating
```





More information about the Digitalmars-d-learn mailing list