D-Programming-Language/dmd — pull request #2539 by 9rnsr (2013-09-08 10:25:53+00:00)
Title: Issue 6178 - Struct inside the AA are not init correctly

http://d.puremagic.com/issues/show_bug.cgi?id=6178

If the AA value setting invokes opAsign method, it would need additional runtime const to distinguish construction and assignment.

Following is the implemented behavior.

1. If the setting is identity assignment (the AA value type is equal to toe rhs type):

```d
struct S1 { void opAssign(S1 rhs) {} }
S1[int] aa1;
aa1[1] = S1(); // <--
```

1. If the key doesn't exist in aa yet, so it should work as initializing.
2. If the key already exists in aa, so it should work as assignment (== opAssign call).

2. If the setting is not identity assignment (the AA value type is not equal to toe rhs type):

```d
struct S2 {
this(int val) {}
void opAssign(int val) {} }
S2[int] aa1;
aa[1] = 1; // <--
```

1. If the key doesn"t exist in aa yet, it should work as initializing, with implicit constructor call.
```d
S2 tmp = 1; // Rewrite as: S2 tmp = S2(1);
aa[1] = tmp; // blit copy
```
2. If the key already exists in aa, so it should work as assignment (== opAssign call).

The case #2 is necessary to allow using `@disable this()` structs as AA values.