www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18742] New: std.regex: Using CodePointSet in AAs breaks if

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

          Issue ID: 18742
           Summary: std.regex: Using CodePointSet in AAs breaks if
                    reference count changes
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: bootcamp
          Severity: minor
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: johannespfau gmail.com

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.

--
Apr 07 2018