[Issue 10056] Strange Error with templates and string.format

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat May 11 06:29:17 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10056


Kenji Hara <k.hara.pg at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid


--- Comment #1 from Kenji Hara <k.hara.pg at gmail.com> 2013-05-11 06:29:15 PDT ---
This regression is caused by the commit:
https://github.com/D-Programming-Language/dmd/commit/596c1128f4de2b246d339497e1bcec70d93ffd78

Reduced test case:
-------
void main()
{
    alias Zoo = Foo!(false, false, 1);
}

struct Foo(bool S, bool L, size_t N)
{
    string bar()
    {
        Appender!(string) w;
        char[] buf; put(w, buf);
        return "";
    }

    public bool opEquals(T)(T other)
    {
        alias Foo!(typeof(this), T, "CMP") P;
        return false;
    }
}

template Foo(T, U, string OP)
{
    static if (T.ISEMPTY && U.ISEMPTY)
        enum bool S = false;
    else
        enum bool S = false;

    alias Foo = Foo!(false, false, 0);
}

/**********************************************/

void put(R, E)(ref R r, E e)
{
    static if (is(typeof(r.put(e))))
    {
        r.put(e);
    }
    else
    {
        static assert(false, "Cannot put a "~E.stringof~" into a "~R.stringof);
    }
}

struct Appender(A : T[], T)
{
    private template canPutItem(U)
    {
        enum bool canPutItem = is(U : T);
    }
    private template canPutRange(R)
    {
        enum bool canPutRange = is(typeof(Appender.init.put(R.init[0])));
    }

    void put(U)(U item) if (canPutItem!U)
    {
        char[T.sizeof == 1 ? 4 : 2] encoded;
        put(encoded[]);
    }
    void put(R)(R items) if (canPutRange!R)
    {
    }
}

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