Bug 5427 – constructors in .di files lack modifiers if they are after the function name in the .d file

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2011-01-08T01:16:00Z
Last change time
2015-06-09T05:15:02Z
Assigned to
nobody
Creator
issues.dlang

Comments

Comment #0 by issues.dlang — 2011-01-08T01:16:02Z
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.
Comment #1 by issues.dlang — 2011-01-08T01:19:00Z
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.
Comment #2 by andrej.mitrovich — 2013-01-11T19:57:20Z
In both samples the qualifiers are now outputted properly.