www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9579] New: std.regex.replace format argument should not require same constness as target string

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9579

           Summary: std.regex.replace format argument should not require
                    same constness as target string
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: minor
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: hsteoh quickfur.ath.cx


--- Comment #0 from hsteoh quickfur.ath.cx 2013-02-23 17:03:25 PST ---
Code:

// This works:
auto re = regex(`a`, "g");
string input = "abc";
auto r = replace(input, re, "($1)");

// This gives a compile error:
auto re = regex(`a`, "g");
char[] input;
auto r = replace(input, re, "($1)");

The reason is that when input is char[], replace expects the format string to
also be char[], but "($1)" is, by default, of type string. But this is
unreasonable, because the constness of the format string shouldn't be tied to
the constness of the target string!

(Yes, DMD's IFTI has some limitations, it should be able in infer char[]
instead of immutable(char)[], but regardless, there's no reason why the format
argument must be char[].)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 23 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9579


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
                 CC|                            |dmitry.olsh gmail.com


--- Comment #1 from Dmitry Olshansky <dmitry.olsh gmail.com> 2013-03-10
10:10:33 PDT ---
https://github.com/D-Programming-Language/phobos/pull/1195

-- 
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=9579



--- Comment #2 from github-bugzilla puremagic.com 2013-08-16 16:35:14 PDT ---
Commit pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/558dba8dd4a62491545af574f4577ff2a5356fc4
Finalize new API,  more examples

Also fix issue 9579.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 16 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9579


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
         AssignedTo|nobody puremagic.com        |dmitry.olsh gmail.com


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 16 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9579



--- Comment #3 from hsteoh quickfur.ath.cx 2013-08-16 22:09:26 PDT ---
Confirmed it works now in git HEAD. Thanks Dmitry!

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