[Issue 7220] Bad initialization when using mixin to generate a static field in a -lib'rary
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Nov 12 20:24:18 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7220
Walter Bright <bugzilla at digitalmars.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bugzilla at digitalmars.com
--- Comment #3 from Walter Bright <bugzilla at digitalmars.com> 2012-11-12 20:24:17 PST ---
This gets quite a bit simpler:
---------- faulty.d -------------
module faulty;
import core.stdc.stdio;
mixin template DefineCoreType(string type)
{
class Faulty
{
static int x;
static void instance()
{
printf("Faulty.instance()\n");
x = 3;
}
static this()
{
printf("Faulty.static this\n");
}
}
}
mixin DefineCoreType!("Faulty");
---------- bar.d -------------------------
import core.stdc.stdio,
faulty;
static this()
{
Faulty.instance();
assert(Faulty.x == 3);
printf("bar.static this\n");
}
private int main(string[] args)
{
printf("Main\n");
return 0;
}
------------------------------------------
dmd -lib faulty
dmd bar faulty.lib
bar
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list