Bug 13721 – typeof() for function return type produces peculiar error in std.datetime

Status
RESOLVED
Resolution
WORKSFORME
Severity
blocker
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
Windows
Creation time
2014-11-12T20:54:39Z
Last change time
2022-12-16T14:26:45Z
Assigned to
No Owner
Creator
Walter Bright

Comments

Comment #0 by bugzilla — 2014-11-12T20:54:39Z
Replacing line 17372 in std.datetime from: @property auto length() const pure nothrow to: @property typeof(end - begin) length() const pure nothrow and adding a trivial destructor: public pure nothrow @safe @nogc ~this() { } and compiling with: dmd src\datetime.d -unittest -main produces the peculiar error: std\datetime.d(17341): Error: function std.datetime.Interval!(TimeOfDay).Interval.end need 'this' to access member end std\datetime.d(17374): called from here: end() std\datetime.d(18699): Error: template instance std.datetime.Interval!(TimeOfDay) error instantiating std\datetime.d(17341): Error: function std.datetime.Interval!(DateTime).Interval.end need 'this' to access member end std\datetime.d(17374): called from here: end() std\datetime.d(18700): Error: template instance std.datetime.Interval!(DateTime) error instantiating std\datetime.d(18685): Error: pure nested function '__invariant63' cannot access mutable data '_begin' std\datetime.d(18685): Error: need 'this' for '_begin' of type 'TimeOfDay' std\datetime.d(18685): Error: pure nested function '__invariant63' cannot access mutable data '_end' std\datetime.d(18685): Error: need 'this' for '_end' of type 'TimeOfDay' See: https://github.com/D-Programming-Language/phobos/pull/2689 for more information. For some reason it only happens on Windows.
Comment #1 by hsteoh — 2014-11-12T21:04:21Z
Huh? Why is this a bug in Phobos rather than dmd?
Comment #2 by bugzilla — 2014-11-12T22:17:51Z
(In reply to hsteoh from comment #1) > Huh? Why is this a bug in Phobos rather than dmd? Don't know which it is until it is reduced.
Comment #3 by code — 2014-11-17T20:05:19Z
If we merge https://github.com/D-Programming-Language/dmd/pull/4136 then this will be a blocker for the next release as it might get triggered way more often.
Comment #4 by stanislav.blinov — 2021-12-08T17:19:08Z
The file in question now is std/datetime/interval.d (struct Interval(TP)). Cannot reproduce on Linux. Please verify on Windows and close if not reproducible.