[Issue 21245] New: Error: expression `canBitwiseHash!(...)` of type `void` does not have a boolean value

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Sep 14 02:33:12 UTC 2020


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 at puremagic.com
          Reporter: dlang-bugzilla at 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.

--


More information about the Digitalmars-d-bugs mailing list