www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5427] New: constructors .di files lack modifiers

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5427

           Summary: constructors .di files lack modifiers
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: jmdavisProg gmx.com



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:

/home/jmdavis/Downloaded_Files/dmd/dmd2/linux/bin/../../src/druntime/import/core/time.di(193):
Error: pure function 'dur' cannot call impure function 'this'
/home/jmdavis/Downloaded_Files/dmd/dmd2/linux/bin/../../src/druntime/import/core/time.di(193):
Error: (Duration __ctmp1 = 0;
 , __ctmp1).this is not nothrow
/home/jmdavis/Downloaded_Files/dmd/dmd2/linux/bin/../../src/druntime/import/core/time.di(191):
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:

     safe
    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: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 08 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5427


Jonathan M Davis <jmdavisProg gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|major                       |normal



PST ---
Interestingly enough, it looks like the problem goes away if you place nothrow
and pure _before_ this() rather than after. So, there _does_ appear to be a
trivial workaround, but still, it needs to be fixed. As there is a trivial
workaround, however, I'll downgrade its severity to normal.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 08 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5427


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrej.mitrovich gmail.com
         Resolution|                            |WORKSFORME



19:57:20 PST ---
In both samples the qualifiers are now outputted properly.

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