www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13721] New: typeof() for function return type produces

https://issues.dlang.org/show_bug.cgi?id=13721

          Issue ID: 13721
           Summary: typeof() for function return type produces peculiar
                    error in std.datetime
           Product: D
           Version: D2
          Hardware: All
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: Phobos
          Assignee: nobody puremagic.com
          Reporter: bugzilla digitalmars.com

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.

--
Nov 12 2014