On 12/11/18 4:09 PM, Johannes Riecken wrote:
Code:
import std.conv;
import std.stdio;
mixin template genInts()
{
enum arr = [0,1];
static foreach (t; arr) {
mixin("int i" ~ to!string(t) ~ " = 5;");
}
}
void main() {
mixin genInts!();
writeln(i0);
writeln(i1);
}
Expected output:
5
5
Actual output is two garbage integer values.
Looks like a bug to me in static foreach.
Using -vcg-ast, it appears that the int definitions do not show up in main.
If I add an int using a regular declaration or a straight mixin("int i0
= 5;"); then the variable shows up.
-Steve