D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7099 - (D1 only) static constructor in template mixin in library not executed
Summary: (D1 only) static constructor in template mixin in library not executed
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2011-12-12 15:08 UTC by Robert Clipsham
Modified: 2019-11-07 08:08 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Robert Clipsham 2011-12-12 15:08:00 UTC
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).
Comment 1 Don 2011-12-19 03:36:37 UTC
Happens on Windows as well. This isn't a regression, it behaves the same way in D 1.040. It has never worked.
Comment 2 Robert Clipsham 2011-12-19 08:26:59 UTC
(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.
Comment 3 yebblies 2014-08-31 13:55:20 UTC
I can't reproduce this on recent D2 (2.067 HEAD win32)
Comment 4 RazvanN 2019-11-07 08:08:45 UTC
D1 is no longer supported, closing as WORKSFORME.