Bug 9046 – typeof(T.init) should have the type T

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-11-18T19:55:00Z
Last change time
2012-12-19T05:49:29Z
Keywords
wrong-code
Assigned to
nobody
Creator
k.hara.pg

Comments

Comment #0 by k.hara.pg — 2012-11-18T19:55:20Z
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)); } }
Comment #1 by github-bugzilla — 2012-11-18T21:01:58Z
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 Merge pull request #959 from 9rnsr/fix9046 Issue 9046 - typeof(T.init) should have the type T
Comment #2 by k.hara.pg — 2012-11-18T21:48:01Z
Comment #3 by github-bugzilla — 2012-11-19T13:33:44Z
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 Merge pull request #1300 from 9rnsr/fix9046 Issue 9046 - typeof(T.init) should have the type T
Comment #4 by bearophile_hugs — 2012-11-19T13:56:15Z
Very good Hara :-) You have fixed so many important corner cases of D.
Comment #5 by bugzilla — 2012-11-19T14:05:53Z
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
Comment #6 by github-bugzilla — 2012-11-19T19:04:35Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/027b5a0e282d51d238bb696e5f985d462892d8da Revert "revert D2 pull #1300" to re-fix bug 9046 This reverts commit 1619096bfede776f9565395f8cba386c14176b16. https://github.com/D-Programming-Language/dmd/commit/25e2aea808e081fe713753738501c4bd028b0730 Merge pull request #1303 from 9rnsr/fix9046 Revert "revert D2 pull #1300" to re-fix bug 9046
Comment #7 by monarchdodra — 2012-12-19T05:49:29Z
Seems fixed to me.