Bug 12693 – multiple arithmetic assignment on same line fails for short and byte
Status
RESOLVED
Resolution
WORKSFORME
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2014-05-02T21:01:42Z
Last change time
2020-03-21T03:56:43Z
Assigned to
No Owner
Creator
Vlad Levenfeld
Comments
Comment #0 by vlevenfeld — 2014-05-02T21:01:42Z
this test passes:
uint x = 0;
(x += 1) %= 2;
assert (x == 1);
ubyte y = 0;
(y += 1) %= 2;
assert (y == 0);
// though I expected y == 1
y += 1;
y %= 2;
assert (y == 1);
// this is correct
using dmd from debian package dmd-bin v2.065.0-0
Comment #1 by b2.temp — 2019-11-24T10:54:48Z
This is working since 2.067.1 according to run.dlang.io
void main()
{
uint x = 0;
(x += 1) %= 2;
assert (x == 1);
ubyte y = 0;
(y += 1) %= 2;
assert (y == 1);
y += 1;
y %= 2;
assert (y == 0);
}