www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10066] New: Template opEquals sometimes obstructs struct compilation

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

           Summary: Template opEquals sometimes obstructs struct
                    compilation
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: blocker
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: k.hara.pg gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg gmail.com> 2013-05-12 01:12:14 PDT ---
During debug for 10056, I found another bug case.

Following code will occur strange errors:
----
test.d(71): Error: static assert  "Cannot put a char[] into a
Appender!(string)"
test.d(39):        instantiated from here: put!(Appender!(string), char[])
test.d(30):        instantiated from here: Foo!(1)

code:
----
void main()
{
    alias Zoo = Foo!(1);
    Zoo z;
}

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

    public bool opEquals(T)(T other) const
    // <--- Add const, different from bug 10056
    {
        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!(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)
    {
    }
}

The error occurs in the internal code generation for TypeInfo.equals. It
instantiates Foo's opEquals member template function in background, but the
instantiation errors are now unexpectedly un-gagged.

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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #1 from Kenji Hara <k.hara.pg gmail.com> 2013-05-12 01:25:04 PDT ---
https://github.com/D-Programming-Language/dmd/pull/2025

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



--- Comment #2 from github-bugzilla puremagic.com 2013-05-14 12:06:51 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/5a1307007cd033386ec3d31c70118deaaeb7ff51
fix Issue 10066 - Template opEquals sometimes obstructs struct compilation

Move __xopEquals generation after struct semantic3 done

https://github.com/D-Programming-Language/dmd/commit/ad0679d1a7676f694b016b10ed8ae927c08282ae
Merge pull request #2025 from 9rnsr/fix10066

Issue 10066 - Template opEquals sometimes obstructs struct compilation

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


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


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