Bug 5181 – (D1 only) Excess cast on in-place operation op= involving conversion

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
All
OS
All
Creation time
2010-11-06T13:39:00Z
Last change time
2012-02-20T00:50:45Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
rsinfu

Comments

Comment #0 by rsinfu — 2010-11-06T13:39:41Z
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 } ----------
Comment #1 by yebblies — 2012-02-04T19:30:43Z
Comment #2 by yebblies — 2012-02-19T23:54:21Z
Comment #3 by github-bugzilla — 2012-02-20T00:43:37Z
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