[Issue 14439] aa's keys, values, byKey, byValue not usable in @safe context
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Apr 13 18:06:07 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=14439
Brad Roberts <braddr at puremagic.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|aa's are essentially |aa's keys, values, byKey,
|unusable in @safe contexts |byValue not usable in @safe
| |context
--- Comment #1 from Brad Roberts <braddr at puremagic.com> ---
module safeaa;
void main() @safe
{
string[string] saa = [ "a" : "1", "b" : "2" ];
string s = saa["a"];
saa["c"] = "3";
if ("c" in saa) {}
size_t l = saa.length;
foreach(k; saa.keys) {}
foreach(k; saa.byKey) {}
foreach(v; saa.values) {}
foreach(v; saa.byValue) {}
}
safeaa.d(15): Error: safe function 'D main' cannot call system function
'object.keys!(string[string], string, string).keys'
safeaa.d(17): Error: safe function 'D main' cannot call system function
'object.byKey!(string[string], string, string).byKey'
safeaa.d(17): Error: safe function 'D main' cannot call system function
'object.byKey!(string[string], string, string).byKey.Result.empty'
safeaa.d(17): Error: safe function 'D main' cannot call system function
'object.byKey!(string[string], string, string).byKey.Result.popFront'
safeaa.d(17): Error: safe function 'D main' cannot call system function
'object.byKey!(string[string], string, string).byKey.Result.front'
safeaa.d(19): Error: safe function 'D main' cannot call system function
'object.values!(string[string], string, string).values'
safeaa.d(21): Error: safe function 'D main' cannot call system function
'object.byValue!(string[string], string, string).byValue'
safeaa.d(21): Error: safe function 'D main' cannot call system function
'object.byValue!(string[string], string, string).byValue.Result.empty'
safeaa.d(21): Error: safe function 'D main' cannot call system function
'object.byValue!(string[string], string, string).byValue.Result.popFront'
safeaa.d(21): Error: safe function 'D main' cannot call system function
'object.byValue!(string[string], string, string).byValue.Result.front'
I'm not sure why saa.length builds since _aaLen isn't marked @safe. Probably
the compiler making assumptions that the code doesn't declare.
--
More information about the Digitalmars-d-bugs
mailing list