[Issue 11025] [aa] std.typecons.Tuple needs to define toHash

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Apr 3 15:59:15 PDT 2014


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



--- Comment #2 from hsteoh at quickfur.ath.cx 2014-04-03 15:59:12 PDT ---
Yes it's a serious bug. Sadly, it's also not a surprising one: the current AA
implementation has a lot of issues (and I do mean a LOT), and this is just
another hole in the cheesegrater.

Basically, the only guaranteed correct behaviour of AA's in their current state
is to use string keys or immutable array keys. Anything key type more
complicated than that -- all bets are off, you could run into one of numerous
AA-related bugs unexpectedly. Having said that, though, AA's with string keys
do work great.

The workaround for this particular bug is to wrap your key (whether it's Tuple
or multiple strings or whatever else) in your own struct, and make sure you
define opCmp, opEquals, and toHash with the right signatures for the typeinfo
to be set up correctly. And make sure you don't have external mutable
references to the key struct after you add it to an AA. Then it should work
correctly. (Yes, it's troublesome and tedious, and yes it sucks to have to do
that, but given how deeply-rooted some of the AA bugs are, fixes are moving
rather slowly, and I wouldn't hold my breath for them to be fixed in the next
release. The good news is that D's templating power mostly alleviates this pain
once you have the workaround suitably templatized, then you just reuse it
everywhere and don't ever worry about manually doing it again.)

-- 
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