Bug or feature? This one caught me by surprise:

void main() {
    {
        int[string] aa[string];
        aa["foo"]["bar"] = 1;
        assert(aa["foo"]["bar"] == 1); //ok

        auto aa2 = aa;
        aa2["boo"]["dar"] = 2;
        assert(aa["foo"]["bar"] == 1); //ok
    }

    {
        int[string] aa[string]; //not set to anything yet

        auto aa2 = aa;
        aa2["boo"]["dar"] = 2;
        assert(aa["foo"]["bar"] == 1); //oops
    }
}

It seems that assigning an AA to another makes both point at the same data only if the first array has data to begin with. Is that the expected behaviour?

Atila

Reply via email to