D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 12693 - multiple arithmetic assignment on same line fails for short and byte
Summary: multiple arithmetic assignment on same line fails for short and byte
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 major
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-02 21:01 UTC by Vlad Levenfeld
Modified: 2020-03-21 03:56 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 Vlad Levenfeld 2014-05-02 21:01:42 UTC
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 basile-z 2019-11-24 10:54:48 UTC
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);
}