Bug 20943 – std.algorithm.setops.cartesianProduct fails for ranges with @system popFront

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-06-17T17:01:07Z
Last change time
2020-06-24T01:40:50Z
Keywords
pull
Assigned to
No Owner
Creator
John Colvin

Comments

Comment #0 by john.loughran.colvin — 2020-06-17T17:01:07Z
unittest { import std.algorithm : cartesianProduct; import std.algorithm : equal; import std.typecons : tuple; static struct SystemRange { int[] data; int front() @system @property { return data[0]; } bool empty() @system @property { return data.length == 0; } void popFront() @system { data = data[1 .. $]; } SystemRange save() @system { return this; } } assert(SystemRange([1, 2]).cartesianProduct(SystemRange([3, 4])) .equal([tuple(1, 3), tuple(1, 4), tuple(2, 3), tuple(2, 4)])); } /dlang/dmd/linux/bin64/../../src/phobos/std/algorithm/setops.d(398): Error: scope variable r assigned to non-scope parameter this calling onlineapp.__unittest_L1_C1.SystemRange.popFront /dlang/dmd/linux/bin64/../../src/phobos/std/algorithm/setops.d(399): Error: scope variable r assigned to non-scope parameter this calling onlineapp.__unittest_L1_C1.SystemRange.empty /dlang/dmd/linux/bin64/../../src/phobos/std/algorithm/setops.d(404): Error: scope variable this assigned to non-scope parameter this calling onlineapp.__unittest_L1_C1.SystemRange.save /dlang/dmd/linux/bin64/../../src/phobos/std/algorithm/setops.d(398): Error: scope variable r assigned to non-scope parameter this calling onlineapp.__unittest_L1_C1.SystemRange.popFront /dlang/dmd/linux/bin64/../../src/phobos/std/algorithm/setops.d(399): Error: scope variable r assigned to non-scope parameter this calling onlineapp.__unittest_L1_C1.SystemRange.empty onlineapp.d(32): Error: template instance std.algorithm.setops.cartesianProduct!(SystemRange, SystemRange) error instantiating
Comment #1 by dlang-bot — 2020-06-17T17:02:31Z
@John-Colvin updated dlang/phobos pull request #7519 "Let safety of cartesianProduct.Result.popFront be inferred" fixing this issue: - Fix Issue 20943 - std.algorithm.setops.cartesianProduct fails for ranges with @system popFront https://github.com/dlang/phobos/pull/7519
Comment #2 by dlang-bot — 2020-06-18T09:08:19Z
dlang/phobos pull request #7519 "Let safety of cartesianProduct.Result.popFront be inferred" was merged into stable: - e33db3409c78f6a4e758315387a8e308f014c267 by John Colvin: Fix Issue 20943 - std.algorithm.setops.cartesianProduct fails for ranges with @system popFront https://github.com/dlang/phobos/pull/7519
Comment #3 by dlang-bot — 2020-06-24T01:40:50Z
dlang/phobos pull request #7541 "merge stable" was merged into master: - b8e90f4a227edbfce52ace5e597e039cf56c03c0 by John Colvin: Fix Issue 20943 - std.algorithm.setops.cartesianProduct fails for ranges with @system popFront (#7519) Let safety of cartesianProduct.Result.popFront be inferred. https://github.com/dlang/phobos/pull/7541