Thread overview
[Issue 9579] New: std.regex.replace format argument should not require same constness as target string
Mar 10, 2013
Dmitry Olshansky
Aug 16, 2013
Dmitry Olshansky
February 24, 2013
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: -------
March 10, 2013
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: -------
August 16, 2013
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: -------
August 16, 2013
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: -------
August 17, 2013
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: -------