www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5003] New: regex(replace with delegate) sample doesn't work

reply d-bugmail puremagic.com writes:
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



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: -------
Oct 06 2010
next sibling parent d-bugmail puremagic.com writes:
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: -------
Jan 09 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Jun 06 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Jul 01 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



PST ---
Assigning to Dmitry.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 07 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Mar 10 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5003




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 05 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5003




01:13:40 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!
'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: 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: -------
May 06 2013