D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 17264 - [REG2.073] uniq fails with const elements
Summary: [REG2.073] uniq fails with const elements
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P1 regression
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-17 19:28 UTC by elpenguino+D
Modified: 2018-01-05 13:28 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 elpenguino+D 2017-03-17 19:28:46 UTC
The fix for issue 16588 causes code like

const(int)[] var = [0, 1, 1, 2];
assert(var.uniq.equal([0,1,2]));

to result in errors like

std\algorithm\iteration.d(4967): Error: cannot modify const expression this._back
std\algorithm\iteration.d(4971): Error: cannot modify const expression last
std\algorithm\iteration.d(4975): Error: cannot modify const expression this._back
Comment 1 elpenguino+D 2017-03-18 20:13:05 UTC
Elements with a disabled default constructor fail similarly.

struct NoDefault {
  int i;
  @disable this();
  this(int x) { i = x; }
}

NoDefault[] var = [NoDefault(0), NoDefault(1), NoDefault(1), NoDefault(2)];
assert(var.uniq.equal([NoDefault(0), NoDefault(1), NoDefault(2)]));

results in

std\algorithm\iteration.d(4912): Error: field _back must be initialized in constructor
Comment 2 Vladimir Panteleev 2017-05-06 09:41:38 UTC
Introduced in https://github.com/dlang/phobos/pull/4961
Comment 3 github-bugzilla 2017-05-10 23:55:31 UTC
Commit pushed to stable at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/113502af744fb82d68e8f51fd73831b628dcc1eb
std.algorithm.iteration: Add test for issue 17264

Fixes Issue 17264 - [REG2.073] uniq fails with const elements
Comment 4 github-bugzilla 2017-05-29 23:02:15 UTC
Commit pushed to master at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/113502af744fb82d68e8f51fd73831b628dcc1eb
std.algorithm.iteration: Add test for issue 17264
Comment 5 Vladimir Panteleev 2017-07-03 21:20:47 UTC
https://github.com/dlang/phobos/pull/5384 was merged, closing.
Comment 6 github-bugzilla 2018-01-05 13:28:40 UTC
Commit pushed to dmd-cxx at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/113502af744fb82d68e8f51fd73831b628dcc1eb
std.algorithm.iteration: Add test for issue 17264