Bug 17264 – [REG2.073] uniq fails with const elements

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-03-17T19:28:46Z
Last change time
2018-01-05T13:28:40Z
Assigned to
No Owner
Creator
elpenguino+D

Comments

Comment #0 by elpenguino+D — 2017-03-17T19:28:46Z
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 by elpenguino+D — 2017-03-18T20:13:05Z
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 by dlang-bugzilla — 2017-05-06T09:41:38Z
Comment #3 by github-bugzilla — 2017-05-10T23:55:31Z
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 by github-bugzilla — 2017-05-29T23:02:15Z
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 by dlang-bugzilla — 2017-07-03T21:20:47Z
Comment #6 by github-bugzilla — 2018-01-05T13:28:40Z
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