[Issue 5427] New: constructors .di files lack modifiers
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Jan 8 01:18:21 PST 2011
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 at puremagic.com
ReportedBy: jmdavisProg at gmx.com
--- Comment #0 from Jonathan M Davis <jmdavisProg at gmx.com> 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:
/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: -------
More information about the Digitalmars-d-bugs
mailing list