When storing a CodePointSet in an AA, the reference count member is included when hashing, so two identical CodePointSets only differing in the reference count are not considered as the same AA key. std.regex does actually put CodePointSets into AAs, so this seems very fragile. As a solution, CodePointSet should properly implement the toHash function.
Test case:
--------------------------------------
import std.uni, std.stdio;
void main()
{
int[CodepointSet] aa;
auto set = unicode.Nd;
aa[set] = 42;
writeln(aa[set]);
}
--------------------------------------
This is expected to print 42, but currently throws a RangeError instead.
Comment #1 by bugzilla — 2019-12-19T13:59:19Z
Seems to me, this is a CodePointSet issue and not a regex...
Comment #2 by robert.schadek — 2024-12-01T16:33:28Z