Comment #0 by dlang-bugzilla — 2020-09-14T02:33:12Z
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.
Comment #1 by dlang-bugzilla — 2020-09-23T14:58:05Z
Amended test case which doesn't have invalid code:
/////////////////// 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);
return true;
}
}
visit!(Handler*)(null);
return 0;
}
}
//////////////////////////////////////////////
Seems to be a regression.
Introduced in https://github.com/dlang/druntime/pull/2240
Comment #2 by robert.schadek — 2024-12-13T19:11:28Z