www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19877] New: 'private' makes toHash un- safe in -preview=dip1000

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

          Issue ID: 19877
           Summary: 'private' makes toHash un- safe in -preview=dip1000
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: hsteoh quickfur.ath.cx

Code:
------
import std.container.rbtree;

alias Grid = RedBlackTree!(GridPoint);

struct GridPoint
{
    private string _srcStr;
    int opCmp(in GridPoint p) const { return 0; }
}
------

Compiler output (with -preview=dip1000):
------
/usr/src/d/phobos/std/container/rbtree.d(1111): Error:  safe function
std.container.rbtree.RedBlackTree!(GridPoint, "a < b",
false).RedBlackTree.toHash cannot call  system function
core.internal.hash.hashOf!(GridPoint).hashOf
/usr/src/d/druntime/import/core/internal/hash.d(510):       
core.internal.hash.hashOf!(GridPoint).hashOf is declared here
numid.d(3): Error: template instance
`std.container.rbtree.RedBlackTree!(GridPoint, "a < b", false)` error
instantiating
------

Compiling without -preview=dip1000 works.

The problem appears to be the 'private': removing 'private' from _srcStr makes
the problem go away.

Why 'private' makes toHash un- safe is anybody's guess.

--
May 15 2019