An incorrect associative array work?

Dark Hole dark.hole1 at yandex.ru
Sat Sep 19 19:38:29 UTC 2020


Let's take a look at this code:

int[char[]] test;
char[4] buf = "abcd";
test[buf] = 1;
buf = "evil";
writeln(test);

What we're expecting to see:
["abcd":1]
But real result is:
["evil":1]

But if we replace static array with dynamic, we'll get error "key 
must be immutable". Not exactly what we expected, but ok. If we 
declare test as int[char[4]], it works as expected.

So, is this behaviour bug?


More information about the Digitalmars-d mailing list