[Issue 12150] Regression (2.063): char[] implicitly converts to string in .dup expression

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Feb 13 07:37:57 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=12150



--- Comment #6 from Kenji Hara <k.hara.pg at gmail.com> 2014-02-13 07:37:52 PST ---
(In reply to comment #3)
> But the regression is likely unintended. Did anyone actually request for the
> feature in Issue 9656? Magical built-in behavior is something we should avoid
> IMHO, exactly because of issues like this..

That is not magic. It is consistent with the implicit conversion for the
returned value from pure function.

E[] dup(E)(const(E)[] src) pure
{
    E[] r;
    r.reserve(src.length);
    foreach (ref e; src)
        r ~= e;
    return r;
}
int foo(string arg)
{
    return foo(dup(arg));
    // returned char[] is implicitly convertible to string
}
void main()
{
    foo("foo");
}

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


More information about the Digitalmars-d-bugs mailing list