[Issue 5181] New: Excess cast on in-place operation op= involving conversion
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Nov 6 13:40:42 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5181
Summary: Excess cast on in-place operation op= involving
conversion
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Keywords: rejects-valid
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: rsinfu at gmail.com
--- Comment #0 from Shin Fujishiro <rsinfu at gmail.com> 2010-11-06 13:39:41 PDT ---
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
}
----------
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list