www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17066] New: std.regex captures got immutable

https://issues.dlang.org/show_bug.cgi?id=17066

          Issue ID: 17066
           Summary: std.regex captures got immutable
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: greeenify gmail.com

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

--
Jan 07