Bug 6702 – .length for Associative Array is not @safe
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2011-09-20T11:24:00Z
Last change time
2011-09-20T12:54:04Z
Assigned to
nobody
Creator
htvennik
Comments
Comment #0 by htvennik — 2011-09-20T11:24:09Z
The 'length' property of an associative array should be usable from @safe code, but isn't.
The following code doesn't compile:
--------------
module assoc;
import std.stdio;
string[int] a = [1: "foo", 2: "bar"];
@safe void main()
{
writefln("%d items.", a.length);
}
--------------
The compiler output is:
assoc.d(9): Error: safe function 'main' cannot call system function 'length'
Comment #1 by k.hara.pg — 2011-09-20T12:54:04Z
*** This issue has been marked as a duplicate of issue 6357 ***