[Issue 7099] New: static constructor in template mixin in library not executed

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Dec 12 15:08:03 PST 2011


http://d.puremagic.com/issues/show_bug.cgi?id=7099

           Summary: static constructor in template mixin in library not
                    executed
           Product: D
           Version: D1 & D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: robert at octarineparrot.com


--- Comment #0 from Robert Clipsham <robert at octarineparrot.com> 2011-12-12 23:08:00 GMT ---
lib.d:
----
import std.stdio;

template T() {
    static this() {
        writefln("A");
    }
}
mixin T;

mixin(q{
    static this() {
        writefln("B");
    }
});

static this() {
    writefln("C");
}
----

test.d:
----
import lib;

void main() {
    import std.stdio;
    writefln("You should see ABC above.");
}
----

Compile the above files with the following:
$ dmd -lib lib.d
$ dmd test.d lib.a

The first static constructor (A) is not executed when lib.d is a library. Note
that when compiled with `dmd test.d lib.d` this works as expected. Tested on
Linux32 and OSX32 with dmd 2.056. This worked in previous releases, it is
currently broken (not sure when it broke).

-- 
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