Cannot hash a std.datetime.Date

Per Nordlöw per.nordlow at gmail.com
Sun Jun 17 18:15:19 UTC 2018


The following

unittest
{
     import std.datetime.date : Date;
     Date date;
     import core.internal.hash : hashOf;
     auto hash = date.hashOf;
}

errors (with DMD v2.081.0-beta.1) as

/usr/include/dmd/druntime/import/core/internal/convert.d(619,101): Error: template `core.internal.convert.toUbyte` cannot deduce function from argument types `!()(Month)`, candidates are:
/usr/include/dmd/druntime/import/core/internal/convert.d(14,16):  
       `core.internal.convert.toUbyte(T)(ref T val) if 
(is(Unqual!T == float) || is(Unqual!T == double) || is(Unqual!T 
== real) || is(Unqual!T == ifloat) || is(Unqual!T == idouble) || 
is(Unqual!T == ireal))`
/usr/include/dmd/druntime/import/core/internal/convert.d(479,16): 
        `core.internal.convert.toUbyte(T)(T[] arr) if (T.sizeof == 
1)`
/usr/include/dmd/druntime/import/core/internal/convert.d(485,16): 
        `core.internal.convert.toUbyte(T)(T[] arr) if 
(is(typeof(toUbyte(arr[0])) == const(ubyte)[]) && (T.sizeof > 1))`
/usr/include/dmd/druntime/import/core/internal/convert.d(503,16): 
        `core.internal.convert.toUbyte(T)(ref T val) if 
(__traits(isIntegral, T) && !is(T == enum))`
/usr/include/dmd/druntime/import/core/internal/convert.d(537,16): 
        `core.internal.convert.toUbyte(T)(ref T val) if 
(is(Unqual!T == cfloat) || is(Unqual!T == cdouble) || is(Unqual!T 
== creal))`
/usr/include/dmd/druntime/import/core/internal/convert.d(619,101):        ... (2 more, -v to show) ...
/usr/include/dmd/druntime/import/core/internal/hash.d(145,37): 
Error: template instance `core.internal.convert.toUbyte!(Date)` 
error instantiating
foo.d(6,21):        instantiated from here: `hashOf!(Date)`

but not with 2.080.1. A regression?


More information about the Digitalmars-d mailing list