D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5181 - (D1 only) Excess cast on in-place operation op= involving conversion
Summary: (D1 only) Excess cast on in-place operation op= involving conversion
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: pull, rejects-valid
Depends on:
Blocks:
 
Reported: 2010-11-06 13:39 UTC by Shin Fujishiro
Modified: 2012-02-20 00:50 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Shin Fujishiro 2010-11-06 13:39:41 UTC
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 3 github-bugzilla 2012-02-20 00:43:37 UTC
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