D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6702 - .length for Associative Array is not @safe
Summary: .length for Associative Array is not @safe
Status: RESOLVED DUPLICATE of issue 6357
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other All
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-20 11:24 UTC by Harry Vennik
Modified: 2011-09-20 12:54 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Harry Vennik 2011-09-20 11:24:09 UTC
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 Kenji Hara 2011-09-20 12:54:04 UTC

*** This issue has been marked as a duplicate of issue 6357 ***