Thread overview
[Issue 7099] New: static constructor in template mixin in library not executed
Dec 12, 2011
Robert Clipsham
Dec 19, 2011
Don
Dec 19, 2011
Robert Clipsham
December 12, 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@puremagic.com
        ReportedBy: robert@octarineparrot.com


--- Comment #0 from Robert Clipsham <robert@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: -------
December 19, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7099


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
                 CC|                            |clugdbug@yahoo.com.au
           Platform|Other                       |All
           Severity|regression                  |normal


--- Comment #1 from Don <clugdbug@yahoo.com.au> 2011-12-19 03:36:37 PST ---
Happens on Windows as well. This isn't a regression, it behaves the same way in D 1.040. It has never worked.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 19, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7099



--- Comment #2 from Robert Clipsham <robert@octarineparrot.com> 2011-12-19 16:26:59 GMT ---
(In reply to comment #1)
> Happens on Windows as well. This isn't a regression, it behaves the same way in D 1.040. It has never worked.

I have no idea how my code used to work then. Weird.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------