[Issue 9046] New: typeof(T.init) should have the type T
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Nov 18 19:55:22 PST 2012
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 at puremagic.com
ReportedBy: k.hara.pg at gmail.com
--- Comment #0 from Kenji Hara <k.hara.pg at gmail.com> 2012-11-18 19:55:20 PST ---
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: -------
More information about the Digitalmars-d-bugs
mailing list