www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21245] New: Error: expression `canBitwiseHash!(...)` of type

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

          Issue ID: 21245
           Summary: Error: expression `canBitwiseHash!(...)` of type
                    `void` does not have a boolean value
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dlang-bugzilla thecybershadow.net

Also looks like a DMD problem with recursive templated types.

Partial reduction (no imports but depends on Druntime):

/////////////////// test.d ///////////////////
struct Node
{
    NodePtr[] choices;

    void visit(Handler)(Handler h)
    {
        foreach (i, f; this.tupleof)
            if (h.handle(p => &p.tupleof[i]))
                return;
    }

    mixin AutoVisitor;
}

struct NodePtr
{
    mixin AutoVisitor;

    void visit(Handler)(Handler h)
    {
        h.handle(p => p);
    }
}

template AutoVisitor()
{
    hash_t toHash()
    {
        alias T = typeof(this);
        struct Handler
        {
            T* self;
            bool handle(F)(F* delegate(T*) dg)
            {
                auto a = dg(self);
                hashOf(*a);
            }
        }
        visit!(Handler*);
    }
}
//////////////////////////////////////////////

Yields a wall of errors starting with:

.../core/internal/hash.d(503,8): Error: expression `canBitwiseHash!(NodePtr)`
of type `void` does not have a boolean value

Possibly related to issue 21244.

--
Sep 13 2020