On Friday, 12 September 2025 at 08:36:42 UTC, realhet wrote:
Hi,
```d
import std;
void main() {
int val = 4;
enum prog = q{
(){ val += 1; return val; }()
};
//mixin(prog); //
auto dummy = mixin(prog); //Must capture the return value,
otherwise it hallucinates EOF.
writeln(val);
}
```
When uncommenting mixin(prog);
It gives
```
Error: found `End of File` when expecting `;` following
expression
expression: `()
{
val += 1;
return val;
}
()`
```
Hi realhet,
I can explain what happens here.
When you write `auto x = mixin(bla);`
The mixin it parsed as an expression.
b/c there can only be an expression after the =.
However when you don't do that the mixin is parsed as a
statement, after which a ; is expected and mandatory.
putting a ; into the string generated by prog should fix that.