void main () @safe
{
int[string] aa;
foreach (val; aa.byKeyValue)
++aa[val.key];
}
/d399/f220.d(4): Error: @safe function 'D main' cannot call @system function 'object.byKeyValue!(int[string], string, int).byKeyValue'
/d399/f220.d(4): Error: @safe function 'D main' cannot call @system function 'object.byKeyValue!(int[string], string, int).byKeyValue.Result.empty'
/d399/f220.d(4): Error: @safe function 'D main' cannot call @system function 'object.byKeyValue!(int[string], string, int).byKeyValue.Result.popFront'
/d399/f220.d(5): Error: @safe function 'D main' cannot call @system function 'object.byKeyValue!(int[string], string, int).byKeyValue.Result.front.Pair.key'
Comment #1 by hsteoh — 2017-03-09T00:20:55Z
Hmph. This is caused by the last line in object.byKeyValue()():
----
/usr/src/d/druntime/import/object.d(2071): Error: cast from int[string] to void* not allowed in safe code
test.d(4): Error: template instance object.byKeyValue!(int[string], string, int) error instantiating
----
Could this be a regression? I vaguely recall casting to void* used to be allowed, you just can't dereference it unless you're in @trusted land.
Comment #2 by hsteoh — 2017-03-09T00:25:58Z
Bah. Regardless of whether the void* cast is allowed or not, _aaRange() is @system so it's still a no-go.
Comment #3 by github-bugzilla — 2017-11-06T14:15:13Z