Thread overview
[Issue 5003] New: regex(replace with delegate) sample doesn't work
Oct 06, 2010
SHOO
Jun 06, 2011
Dmitry Olshansky
Jul 01, 2011
yebblies
Mar 10, 2013
Dmitry Olshansky
May 06, 2013
Dmitry Olshansky
October 06, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5003

           Summary: regex(replace with delegate) sample doesn't work
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: zan77137@nifty.com
        Depends on: 1904


--- Comment #0 from SHOO <zan77137@nifty.com> 2010-10-06 10:54:09 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 09, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5003


Andrei Alexandrescu <andrei@metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei@metalanguage.com
         AssignedTo|nobody@puremagic.com        |andrei@metalanguage.com


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 06, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5003


Dmitry Olshansky <dmitry.olsh@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
                 CC|                            |dmitry.olsh@gmail.com
         Resolution|                            |WORKSFORME


--- Comment #1 from Dmitry Olshansky <dmitry.olsh@gmail.com> 2011-06-06 13:18:54 PDT ---
Works on dmd 2.053.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 01, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5003


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
             Status|RESOLVED                    |REOPENED
                 CC|                            |yebblies@gmail.com
           Platform|Other                       |All
         Resolution|WORKSFORME                  |
         OS/Version|Windows                     |All


--- Comment #2 from yebblies <yebblies@gmail.com> 2011-07-02 04:09:49 EST ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 08, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=5003


Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|andrei@erdani.com           |dmitry.olsh@gmail.com


--- Comment #3 from Andrei Alexandrescu <andrei@erdani.com> 2013-01-07 23:01:30 PST ---
Assigning to Dmitry.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 10, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=5003


Dmitry Olshansky <dmitry.olsh@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|dmitry.olsh@gmail.com       |nobody@puremagic.com


--- Comment #4 from Dmitry Olshansky <dmitry.olsh@gmail.com> 2013-03-10 10:28:21 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 06, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=5003



--- Comment #5 from Andrei Alexandrescu <andrei@erdani.com> 2013-05-05 18:41:55 PDT ---
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!

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 06, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=5003



--- Comment #6 from Dmitry Olshansky <dmitry.olsh@gmail.com> 2013-05-06 01:13:40 PDT ---
(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)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------