Associative arrays - non-intuitive 'in' semantics

Ben Davis entheh at
Sat Feb 18 03:29:18 PST 2012

On 18/02/2012 03:04, Andrej Mitrovic wrote:
> AA's seem to be full of bugs. You shouldn't be able to use a mutable
> keytype. For now your best option is probably to just use string as
> the key type.

The good news is I didn't intend for the key to be mutable. I've updated 
my code to make it explicitly immutable now. Besides, the bug bearophile 
showed us suggests that the compiler is already trying to const-ify the 
key implicitly (though probably not doing it correctly).

The bad news is that the 'in' bug is separate - I've confirmed that now. 
It's when the key type is a fixed-length array/string, and an 'in' 
expression is used with a dynamic array/string. The example works if and 
only if I cast my string literals to fixed-length when I use an 'in' 
expression. No such cast is necessary when inserting an entry.

More information about the Digitalmars-d mailing list