[Issue 2954] [tdpl] Appalling bug in associative arrays (D2 only)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Mar 19 04:38:16 PDT 2014


https://d.puremagic.com/issues/show_bug.cgi?id=2954


Denis Shelomovskij <verylonglogin.reg at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|patch                       |
             Status|RESOLVED                    |REOPENED
                 CC|                            |verylonglogin.reg at gmail.com
           Platform|x86                         |All
            Version|2.020                       |D2
         Resolution|FIXED                       |


--- Comment #8 from Denis Shelomovskij <verylonglogin.reg at gmail.com> 2014-03-19 15:38:05 MSK ---
Why is it marked as fixed?

If we are talking about original testcase, just replace `hash[a]` with `const
ca = a; hash[ca]` and the program will work as in description. I see no
fundamental difference here.

Currently implemented "fix": the compiler checks whether a key as an array and,
if it is, checks whether its elements are mutable, if mutable, it complains
"...can only be assigned values with immutable keys" (note even the error
message is incorrect, not-mutable check and `immutable` in error).

IMO, the issue is associative arrays accept non-`immutable` keys and those keys
can later be changed. E.g. keys of pointers, classes, associative arrays, and
structs/unions with mutable indirection.

The whole issue is terrible and current inconsistent compiler behaviour with
incorrect error message make situation even worse. The only visible solution is
to disallow any associative array element set except with immutable key.

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


More information about the Digitalmars-d-bugs mailing list