D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 21337 - join can iterates ranges multiple times
Summary: join can iterates ranges multiple times
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2020-10-22 13:06 UTC by Richard Manthorpe
Modified: 2020-11-13 03:43 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Richard Manthorpe 2020-10-22 13:06:49 UTC
class Once
{
    bool empty;
    void popFront() { empty = true; }
    int front() { return 0; }
}

void main()
{
    import std.array : join;
    import std.algorithm.iteration : map;

    assert([1, 2].map!"[a]".join(new Once) == [1, 0, 2]); // fails
}


Join iterates `Once` once to make an array and again for each separator, which obviously doesn't work.
Comment 1 Dlang Bot 2020-10-22 13:12:52 UTC
@rmanthorpe created dlang/phobos pull request #7674 "Fix Issue 21337: Join can iterate ranges multiple times" fixing this issue:

- Fix Issue 21337: Join can iterates ranges multiple times

https://github.com/dlang/phobos/pull/7674
Comment 2 Dlang Bot 2020-10-23 18:47:54 UTC
dlang/phobos pull request #7674 "Fix Issue 21337: Join can iterate ranges multiple times" was merged into stable:

- 529a28ce185375a793d16a84a4a05b2786af39b4 by Richard Manthorpe:
  Fix Issue 21337: Join can iterate ranges multiple times

https://github.com/dlang/phobos/pull/7674
Comment 3 Dlang Bot 2020-11-13 03:43:22 UTC
dlang/phobos pull request #7692 "merge stable" was merged into master:

- 10e862b458fe1b359ab050a08c8f4777a4c3cf7e by Richard Manthorpe:
  Fix Issue 21337: Join can iterate ranges multiple times

https://github.com/dlang/phobos/pull/7692