D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 17066 - [REG2.073a] std.regex captures got immutable
Summary: [REG2.073a] std.regex captures got immutable
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 regression
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2017-01-07 18:24 UTC by Seb
Modified: 2017-07-26 08:35 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Seb 2017-01-07 18:24:27 UTC
The following reduced code used to work with 2.072.2:


    import std.stdio : writeln;
    import std.regex : ctRegex, matchAll, regex, splitter;
    import std.algorithm : joiner, map;

    string message = "fix issue 16319 and fix std.traits.isInnerClass";
    static auto matchToRefs(M)(M m)
    {
        enum splitRE = regex(`[^\d]+`); // ctRegex throws a weird error in unittest compilation
        return m.captures[5].splitter(splitRE);
    }

    // see https://github.com/github/github-services/blob/2e886f407696261bd5adfc99b16d36d5e7b50241/lib/services/bugzilla.rb#L155
    enum issueRE = ctRegex!(`((close|fix|address)e?(s|d)? )?(ticket|bug|tracker item|issue)s?:? *([\d ,\+&#and]+)`, "i");
    message.matchAll(issueRE).map!matchToRefs.joiner.writeln;

it fails with:

dlang/phobos/std/algorithm/iteration.d(2446): Error: cannot modify struct copy._items MapResult!(matchToRefs, RegexMatch!(string, BacktrackingMatcher)) with immutable members
dlang/phobos/std/algorithm/iteration.d(2443): Error: function std.algorithm.iteration.joiner!(MapResult!(matchToRefs, RegexMatch!(string, BacktrackingMatcher))).joiner.Result.save no return exp; or assert(0); at end of function
bugzilla.d(16): Error: template instance std.algorithm.iteration.joiner!(MapResult!(matchToRefs, RegexMatch!(string, BacktrackingMatcher))) error instantiating


According to digger this is due to:

https://github.com/dlang/phobos/pull/4286
Comment 1 Dmitry Olshansky 2017-01-17 21:15:02 UTC
https://github.com/dlang/phobos/pull/5042
Comment 3 github-bugzilla 2017-01-21 23:45:52 UTC
Commits pushed to master at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/4d19d0ad3aab77a9a4a9b2dedaccbacfdeb4e45e
Fix issue 17066

https://github.com/dlang/phobos/commit/8986f149c7c9ff9e5333e6a9427b5799e8576c50
Merge pull request #5042 from DmitryOlshansky/fix-issue-17066
Comment 4 github-bugzilla 2017-01-24 11:55:05 UTC
Commits pushed to newCTFE at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/4d19d0ad3aab77a9a4a9b2dedaccbacfdeb4e45e
Fix issue 17066

https://github.com/dlang/phobos/commit/8986f149c7c9ff9e5333e6a9427b5799e8576c50
Merge pull request #5042 from DmitryOlshansky/fix-issue-17066
Comment 5 Martin Nowak 2017-01-26 12:33:20 UTC
cat > bug.d << CODE
import std.algorithm : joiner, map;

auto matchIssueRefs(string message)
{
    import std.regex;
    return message.matchAll(`a|b`).joiner;
}

void getIssueRefs(string[] messages)
{
    messages.map!(m => m.matchIssueRefs).joiner;
}
CODE
dmd -c -o- bug
----
/usr/include/dmd/phobos/std/algorithm/iteration.d-mixin-2442(2456): Error: cannot modify struct this._current Result with immutable members
bug.d(11): Error: template instance std.algorithm.iteration.joiner!(MapResult!(__lambda2, string[])) error instantiating
----

Thanks for the fix, but it only seems to solves half of the problem, still getting this error with a nested `joiner`.
Comment 6 Dmitry Olshansky 2017-07-26 08:35:32 UTC
Regex was reverted