[Issue 19877] New: 'private' makes toHash un- at safe in -preview=dip1000

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed May 15 18:12:42 UTC 2019


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

          Issue ID: 19877
           Summary: 'private' makes toHash un- at safe in -preview=dip1000
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: hsteoh at 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- at safe is anybody's guess.

--


More information about the Digitalmars-d-bugs mailing list