www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9046] New: typeof(T.init) should have the type T

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

           Summary: typeof(T.init) should have the type T
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: k.hara.pg gmail.com



All T's built-in property init should have an exact same type as T.
But, in current, enum and non-nested struct have broken this principle.

Test case. All is(typeof(U.init) == U) should print 'true'.
----
import std.traits, std.typetuple;
void main()
{
    enum E { x, y }
    int i;
    static struct S {}
    static class  C {}
    struct NS { void f(){ i++; } }
    class  NC { void f(){ i++; } }
    foreach (T; TypeTuple!(E, S, C, NS, NC))
    foreach (U; TypeTuple!(T, const T, immutable T, shared T, shared const T,
inout T, shared inout T))
    {
        pragma(msg, U, ": ", typeof(U.init), " -> ", is(typeof(U.init) == U));
    }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 18 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9046




Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/71e54c199c7de8ed6b63735eebb0ed5fe6937972
fix Issue 9046 - typeof(T.init) should have the type T

hasOverloadedOpAssignWithDuration!T returns true even if T is not a mutable
type (e.g. for const Date). But, until now, the type of T.init had been
accidentally unqualified by bug 9046.

https://github.com/D-Programming-Language/phobos/commit/45f23d90f1c6aaf43eb26e3f94fc890b1022ec61


Issue 9046 - typeof(T.init) should have the type T

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 18 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9046




https://github.com/D-Programming-Language/dmd/pull/1300

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 18 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9046




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/3b4b14eb4294265c569685b7e792e860a76eca55
fix Issue 9046 - typeof(T.init) should have the type T

https://github.com/D-Programming-Language/dmd/commit/4c514b6c77d5c5455a40d7c17ccbd788b1131d25


Issue 9046 - typeof(T.init) should have the type T

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 19 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9046


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc



Very good Hara :-) You have fixed so many important corner cases of D.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 19 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9046


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com



14:05:53 PST ---
Had to revert:

Testing generated/osx/debug/32/unittest/std/datetime
td/datetime.d(31110): Error: static assert  (isTimePoint!(const(Date))) is
false
ake[2]: *** [generated/osx/debug/32/unittest/std/datetime] Error 1
ake[1]: *** [unittest] Error 2

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 19 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9046




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/027b5a0e282d51d238bb696e5f985d462892d8da


This reverts commit 1619096bfede776f9565395f8cba386c14176b16.

https://github.com/D-Programming-Language/dmd/commit/25e2aea808e081fe713753738501c4bd028b0730




-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 19 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9046


monarchdodra gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |monarchdodra gmail.com
         Resolution|                            |FIXED



Seems fixed to me.

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