Why do ints defined in template mixins have garbage values?
Steven Schveighoffer
schveiguy at gmail.com
Wed Dec 12 18:19:43 UTC 2018
On 12/12/18 10:22 AM, Kagamin wrote:
> On Tuesday, 11 December 2018 at 21:19:59 UTC, Steven Schveighoffer wrote:
>> If I add an int using a regular declaration or a straight mixin("int
>> i0 = 5;"); then the variable shows up.
>
> mixin template genInts()
> {
> enum arr = [0];
> static foreach (t; arr)
> {
> mixin("int i0 = 5;");
> }
> }
>
> Still prints garbage.
I meant this:
mixin template genInts()
{
mixin("int i0 = 5;");
}
It's still a static foreach + mixin + mixin template bug, all those are
needed to make it fail.
What's interesting is that dmd thinks there is an i0 (there is no error
on a missing symbol), but the ast printed doesn't show a declaration for it.
-Steve
More information about the Digitalmars-d-learn
mailing list