www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11812] New: Associative array .keys needs 'this' at compile time


           Summary: Associative array .keys needs 'this' at compile time
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: tcdknutson gmail.com

--- Comment #0 from Dylan Knutson <tcdknutson gmail.com> 2013-12-24 11:49:03
PST ---
DMD compiler 2.064, Windows 7 64 bit

enum myaa = ["foo": "bar"];

template MyTemplate(alias Arr)
    enum MyTemplate = Arr.length;

void main()
    // Fails
    auto a = MyTemplate!(myaa.keys);

void main()
    // Works
    enum keys = myaa.keys;
    auto a = MyTemplate!keys;

Passing an AA's .keys to a template directly fails, but making `keys` a
separate enum allows them to be passed.


aabug.d(5): Error: need 'this' for 'keys' of type 'pure nothrow  property
 system string[]()'
aabug.d(10): Error: template instance aabug.MyTemplate!(keys) error

Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 24 2013