Please tell me this is a bug?

Peter Alexander via Digitalmars-d digitalmars-d at puremagic.com
Sat Feb 21 18:27:29 PST 2015


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.


More information about the Digitalmars-d mailing list