D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 13721 - typeof() for function return type produces peculiar error in std.datetime
Summary: typeof() for function return type produces peculiar error in std.datetime
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All Windows
: P3 blocker
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-12 20:54 UTC by Walter Bright
Modified: 2022-12-16 14:26 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Walter Bright 2014-11-12 20:54:39 UTC
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 hsteoh 2014-11-12 21:04:21 UTC
Huh? Why is this a bug in Phobos rather than dmd?
Comment 2 Walter Bright 2014-11-12 22:17:51 UTC
(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 Martin Nowak 2014-11-17 20:05:19 UTC
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 Stanislav Blinov 2021-12-08 17:19:08 UTC
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.