When not capturing the return value of a string mixin expression, I get "found `End of File` when expecting `;`"

realhet real_het at hotmail.com
Fri Sep 12 08:36:42 UTC 2025


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;
}
()`
```

It happens only when NOT capturing the result of the mixed in 
evaluated lambda function.
I've noticed this since LDC 1.41

Is this a feature or a bug? :D
Is there a way to make this processing_and_optional_returning 
thing better?

Use case: The purpose of this is that I can put knobs and sliders 
into my IDE, nested in the source code text that work on a value 
reference: It synchronizes the value between the running program 
and the IDE. Underneath the slider there is a mixin() expression. 
The weird problem only happens when I DON'T capture the result of 
that mixin() expression. Sometimes I put a value display around 
the slider, that reads its value, but sometimes that's not 
needed. Now in that latter case I get a scary End Of File error.

Note: It doesn't matter it I use lambda or a normal function. The 
error is triggered when I don't capture a return value on the 
membrane of a string mixin() expr.

Thank You in advance!


More information about the Digitalmars-d-learn mailing list