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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Feb 23 17:03:27 PST 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 at puremagic.com
        ReportedBy: hsteoh at quickfur.ath.cx


--- Comment #0 from hsteoh at 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: -------


More information about the Digitalmars-d-bugs mailing list