[Issue 14439] aa's keys, values, byKey, byValue not usable in @safe context
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat Mar 26 10:06:32 PDT 2016
https://issues.dlang.org/show_bug.cgi?id=14439
--- Comment #5 from Chris Wright <dhasenan at gmail.com> ---
After taking a closer look, AAs already allow you to violate @safety: opEquals
and postblit are not required to be @safe, and toHash is only required to be
@safe it opEquals is present. This allows you to call @system code from @safe
code without a @trusted intermediary.
The `keys`, `values`, `byKey`, and `byValue` methods don't use opEquals or
toHash but do use postblit. Making them @trusted would exacerbate the existing
problem.
In the implementation in rt/aaA.d, everything uses RTTI to access opEquals,
toHash, and postblit. This obscures the difference, so those methods can't ever
be @safe and it's invalid to make them @trusted. (Unless we start requiring
opEquals, toHash, and postblit to be @safe.)
The wrappers, being templates, can explicitly detect when the types involved
can be used safely and mark themselves @trusted in that case.
Beyond that huge problem, there are a number of minor things that aaA.d does
that aren't @safe but can be made @trusted. Much of the implementation can be
brought closer to @safe standards.
--
More information about the Digitalmars-d-bugs
mailing list