For example, int *= double fails if the type of its result is inferred (auto, typeof etc.): ---------- void main() { int var; auto res = (var *= 1.5); // (4) } ---------- % dmd -o- -c test.d test.d(4): Error: cast(double)var is not an lvalue test.d(4): Error: cannot implicitly convert expression (cast(double)var *= 1.5) of type double to int ---------- The same error occurs with addition +=, subtraction -= and division /=. Besides, modulus %= works fine: ---------- void main() { int var; auto res = (var %= 1.5); // okay } ----------
https://github.com/D-Programming-Language/dmd/pull/695
Fixed D2: https://github.com/D-Programming-Language/dmd/commit/34cb3dec9de6c1c01850447c29fc2bc81d386382
Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/4b3db308691690261d8a27a15bd6537d0567ecc1 fix Issue 5181 - Excess cast on in-place operation op= involving conversion