Please tell me this is a bug?

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Sun Feb 22 12:55:40 PST 2015


On Sun, 22 Feb 2015 09:59:35 +0000, ponce wrote:

> On Sunday, 22 February 2015 at 02:27:30 UTC, Peter Alexander wrote:
>> On Sunday, 22 February 2015 at 01:24:09 UTC, Almighty Bob wrote:
>>> a += b; // Compiles with no ERROR!
>>>
>>> Please tell me that's a bug?
>>
>> Not a bug. From spec:
>>
>> http://dlang.org/expression.html#AssignExpression
>>> Assignment operator expressions, such as:
>>> 
>>> a op= b
>>> 
>>> are semantically equivalent to:
>>> 
>>> a = cast(typeof(a))(a op b)
>>
>> Seems questionable to me. Anyone know the rationale? If a = b; is
>> disallowed, I don't see why a += b; should be more acceptable.
> 
> Questionable or not, this is the C behaviour we might not depart from.

but compiler can at least warn about implicit converting float to int. 
one can always silence warning with `cast(int)f`. ER, anybody?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20150222/eda2b47d/attachment.sig>


More information about the Digitalmars-d mailing list