[Issue 12420] [AA] Can't set associative array with array as key value using key type

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Jun 21 01:24:39 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=12420

--- Comment #5 from Kenji Hara <k.hara.pg at gmail.com> ---
(Sorry, ignore my comment #4.)

(In reply to Denis Shelomovskij from comment #3)
> Looks like you misunderstood me. The word `immutable` shouldn't be here,
> it's just an incorrect error message. Currently we have no rules disallowing
> non-`immutable` associative array keys. I filed Issue 12491 for this.
> 
> This issue will be auto-fixed if Issue 2954 will be fixed by applying a
> correct check to ensure key expression can be implicitly converted to AA key
> type in case of setting AA value.

In D, AA requires immutability for the key. In evidence all AA key types are
implicitly qualified with const.

    int[char[]] aa;
    pragma(msg, typeof(aa));    // Prints: int[const(char)[]]

Honesty, key type should be qualified with immutable. Currently
int[const(char[])] can accept char[] key when storing value in the AA, but it's
a known issue.

Anyway in D AA types cannot have mutable key. Therefore this issue should be
marked as invalid.

--


More information about the Digitalmars-d-bugs mailing list