D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6775 - [CTFE] foreach over an AA fails to compile
Summary: [CTFE] foreach over an AA fails to compile
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2011-10-05 22:40 UTC by Don
Modified: 2015-06-09 05:11 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Don 2011-10-05 22:40:40 UTC
..because aaApply and aaApply2 aren't implemented.

Simple test case:

static assert({
    int[int] aa = [58: 17, 45:6];
    int valsum = 0;
    int keysum = 0;
    foreach(m; aa) { //aaApply
        valsum += m;
    }
    assert(valsum == 17+6);
    valsum = 0;
    foreach(n, m; aa) { //aaApply2
        valsum += m;
        keysum += n;
    }
    assert(valsum == 17+6);
    assert(keysum == 58+45);
    // Check empty AA
    valsum = 0;
    int[int] bb;
    foreach(m; bb) {
        ++valsum;
    }
    assert(valsum == 0);
    return true;
}());