[Issue 19479] Garbage .init in string mixins in static foreach in mixin templates
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Feb 4 08:59:19 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=19479
Iain Buclaw <ibuclaw at gdcproject.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
CC| |ibuclaw at gdcproject.org
--- Comment #2 from Iain Buclaw <ibuclaw at gdcproject.org> ---
---
mixin template genInts3() {
static foreach (t; 0..1) {
mixin("int i = 5;");
}
}
unittest{
mixin genInts3!();
assert(i == 5);
}
---
This is a correct reduced test case of the original issue.
The (sanitized) generated code looks like:
---
unittest
{
int t = 0;
assert(i == 5);
}
---
The variable `i` is never declared!
--
More information about the Digitalmars-d-bugs
mailing list