Summary: constructors .di files lack modifiers
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD

--- Comment #0 from Jonathan M Davis <> 2011-01-08 01:16:02 
PST ---
Take this program for example (you need druntime from svn for this to compile):

import core.time;

int func() pure
    auto d = dur!"msecs"(12);

    return 0;

void main()

It fails to compile, giving this lovely message:

Error: pure function 'dur' cannot call impure function 'this'
Error: (Duration __ctmp1 = 0;
 , __ctmp1).this is not nothrow
Error: function core.time.dur!("msecs").dur 'dur' is nothrow yet may throw
l.d(5): Error: template instance core.time.dur!("msecs") error instantiating

In core.time.d, Duration's constructor looks like this:

    this(long hnsecs) pure nothrow
        _hnsecs = hnsecs;

In core.time.di, it looks like this:

        @safe this(long hnsecs)
_hnsecs = hnsecs;

Notice that both pure and nothrow are missing (though apparently @safe
survived). This makes Duration unusable in pure functions, even though its
constructor is actually pure. This is a big problem for std.datetime, which
uses both nothrow and pure heavily.

I'll have to discuss with Sean the best way to fix this for core.time in the
short term, but I'm marking this bug as major rather than normal because it
affects druntime. Though truth be told, I don't know why druntime even uses .di
files. Regardless, this bug is a definite problem.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to