November 15, 2016
https://issues.dlang.org/show_bug.cgi?id=12492

Ali Cehreli <acehreli@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |acehreli@yahoo.com

--- Comment #1 from Ali Cehreli <acehreli@yahoo.com> ---
I hit this problem in a const member function where the member type of .values turned out to be const:

struct S {
    int[char[]] aa;

    void constFunc() const {
        static assert(is(typeof(aa.keys[0]) == const(char)[]));  // Passes,
good
        static assert(is(typeof(aa.values[0]) == int));          // FAILS
    }
}

void main() {
}

(In my particular case, I had attempted to sort the copy of values, which had
failed due to const(int) members.)

Note that the workaround of declaring a non-const array is totally safe:

        int[] values;
        foreach (v; aa.byValue) {
            values ~= v;
        }

Of course functional style with .byValue would still produce the wrong type:

        auto values = aa.byValue.array;
        static assert(is(typeof(values[0]) == int));  // FAILS

Ali

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=12492

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P3

--