Bug 17066 – [REG2.073a] std.regex captures got immutable

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2017-01-07T18:24:00Z
Last change time
2017-07-26T08:35:32Z
Keywords
pull
Assigned to
nobody
Creator
greeenify

Comments

Comment #0 by greeenify — 2017-01-07T18:24:27Z
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 by dmitry.olsh — 2017-01-17T21:15:02Z
Comment #2 by github-bugzilla — 2017-01-17T23:15:24Z
Comment #3 by github-bugzilla — 2017-01-21T23:45:52Z
Comment #4 by github-bugzilla — 2017-01-24T11:55:05Z
Comment #5 by code — 2017-01-26T12:33:20Z
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 by dmitry.olsh — 2017-07-26T08:35:32Z
Regex was reverted