This code doesn't work!
import std.regex, std.string;
void main()
{
string baz(RegexMatch!(string) m)
{
return std.string.toupper(m.hit);
}
auto s = replace!(baz)("Strap a rocket engine on a chicken.",
regex("[ar]", "g"));
}
RESULT:
std/regex.d(2840): Error: struct std.regex.RegexMatch!(string).RegexMatch member test is not accessible
See also:
http://ideone.com/7pGAm
Workaround:
Define the dummy free function for RegexMatch!(string).test.
private bool _dummyTest(Engine)(Engine r, size_t idx)
{
return r.test(idx);
}
Note:
This issue is maybe related with bug 1904.
- Template function's alias parameter takes delegate.
- Template function uses same module's structs or classes and calls their private function.
Comment #1 by dmitry.olsh — 2011-06-06T13:18:54Z
Works on dmd 2.053.
Comment #2 by yebblies — 2011-07-01T11:09:49Z
Reopened as the reason it works is that the bug has been worked around in phobos, not fixed. It still needs to be reduced with an older version of phobos, or possibly closed as a duplicate.
Comment #3 by andrei — 2013-01-07T23:01:30Z
Assigning to Dmitry.
Comment #4 by dmitry.olsh — 2013-03-10T10:28:21Z
I seriously dunno what to do about this bug report:
- the code of current std.regex changed so that sample no longer compiles
- even then Phobos worked around the issue back then when 2.053 was all the rage
- even if the exact code where it failed is dug up there are chances it won't compile on latest dmd
So somebody would have to chase down the original situation to see if it's still a bug in dmd.
Comment #5 by andrei — 2013-05-05T18:41:55Z
Dmitry, any chance you could close this by (a) submitting a pull request changing the code sample so that it works, and (b) submitting a bug report for dmd? Thanks!
Comment #6 by dmitry.olsh — 2013-05-06T01:13:40Z
(In reply to comment #5)
> Dmitry, any chance you could close this by (a) submitting a pull request
> changing the code sample so that it works, and (b) submitting a bug report for
> dmd? Thanks!
'a' is impossible since the question is about this particular sample presented in Bugzilla (and there is no pull request for that ;) ) that's no longer applicable.
See new example that uses Captures!string:
http://dlang.org/phobos/std_regex.html#.replace
I'll try my hand at 'b' but it's tricky as it involves at least a getting problem statement. And to do that...
1) Get the old phobos with std.regex
2) Run compiler(s) starting from 2.042+ and/or patching old source so that it works with later compiler
3) Recreating error with the current HEAD (if it's not fixed yet)
Comment #7 by hsteoh — 2014-09-12T18:35:44Z
Should we just close this bug? As Dmitry has said, the implementation of std.regex has changed a lot, and it's hard to tell if this issue even exists anymore. If the OP finds the same problem again, he can reopen this bug.
Comment #8 by yebblies — 2014-09-12T19:11:04Z
I'd say the window where it's reasonable to reduce the bug with the old dmd has passed. There are a couple of fixed bugs that match the error message from this one.