D-Programming-Language/dmd — pull request #826 by 9rnsr (2012-03-23 13:04:11+00:00)
Title: fix Issue 6659 - Destructor in range foreach called after initialization

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

If for statement has two or more declarations in its Intiliaze part, we should handle their destructors correctly.
This pull transform such for statement like follows.

```d
for (auto x=X(a), y = Y(b); ...; ...) {}
```

to:

```d
try {
try {
for (auto x=((x=X.init).this(a)), auto y=((y=Y.init)).this(b)); ...; ...) {}
} finally {
y.~this();
}
} finally {
x.~this();
}
```

The way is basically same as in `CompoundStatement::semantic`.