issue with static foreach

Tejas notrealemail at gmail.com
Thu Jul 22 17:38:09 UTC 2021


On Thursday, 22 July 2021 at 05:57:02 UTC, jfondren wrote:
> On Thursday, 22 July 2021 at 03:43:44 UTC, someone wrote:
>> ... it compiles no-more: Error: found `End of File` when 
>> expecting `}` following compound statement
>>
>> ... what I am doing wrong ?
>
> You'll get the same error from this code:
>
> ```d
> unittest {
>     mixin("{");
>     mixin("}");
> }
> ```
>
> https://dlang.org/spec/statement.html#mixin-statement
>
>>The text contents of the string must be compilable as a valid 
>>StatementList, and is compiled as such.
>
> Each individual string has to compile on its own. You'll have 
> to concatenate strings and then mixin them.

Why does this work?

```d
import std;
void main()
{
     mixin("int") a;
     writeln(a);
}
```




More information about the Digitalmars-d-learn mailing list