Phobos is now compiled with -preview=dip1000

Nicholas Wilson iamthewilsonator at hotmail.com
Thu May 16 05:14:39 UTC 2019


On Thursday, 16 May 2019 at 01:05:53 UTC, H. S. Teoh wrote:
> Gah, so apparently .hashOf is a gigantic overload set of *21* 
> different overloads, so this is not really "truly" reduced. =-O
>
> Anybody up for figuring out which overload(s) is/are getting 
> called?

https://github.com/dlang/druntime/blob/master/src/core/internal/hash.d#L393

static if (hasCallableToHash!(typeof(val))){ ... } // false
else
{
     static if (__traits(hasMember, T, "toHash") && 
is(typeof(T.toHash) == function)) { ... } // false
     else static if (T.tupleof.length == 0) { ... } // false
     else static if ((is(T == struct) && !canBitwiseHash!T) || 
T.tupleof.length == 1)//true
     {
         static foreach (i, F; typeof(val.tupleof))
         {
             static if (__traits(isStaticArray, F)) { ... } // 
false
             else static if (is(F == struct) || is(F == union)) { 
... } // false
             else
             {
                     // Nothing special happening.
                     static if (i == 0 && !isChained)
                         size_t h = hashOf(val.tupleof[i]);
                     else
                         h = hashOf(val.tupleof[i], h);
             }
     }
}

> Betcha the problem is that -preview=dip1000 causes one of the 
> overloads to fail to compile, thus shuffling to a different 
> overload that isn't @safe.  I hate SFINAE.

My money's on access to a private member through .tupleof.


More information about the Digitalmars-d-announce mailing list