digitalmars.D.bugs - [Issue 8618] New: std.typecons.Typedef can't instead typedef keyword
- d-bugmail puremagic.com (75/75) Sep 04 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8618
- d-bugmail puremagic.com (12/12) Jan 26 2013 http://d.puremagic.com/issues/show_bug.cgi?id=8618
http://d.puremagic.com/issues/show_bug.cgi?id=8618 Summary: std.typecons.Typedef can't instead typedef keyword Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: cpunion gmail.com --- Comment #0 from Li Jie <cpunion gmail.com> 2012-09-04 08:05:25 PDT --- In old dmd, we can use typedef to create strong type. Now I found it deprecated: http://dlang.org/deprecate.html#typedef . But it can't completely instead typedef keyword. The following code run failed, this happened in my project. --- code import std.typecons; import std.stdio; void testString(S)() { S a = "a"; S a1 = cast(string)"a".dup; S b = "b"; assert(a1 == "a"); assert(a == a1); bool[S] m; m[a] = true; bool* v; v = (a in m); assert(v); assert(*v); v = (b in m); assert(!v); v = (a1 in m); assert(v); // <----- failed line assert(*v); } void main() { alias Typedef!string MyString; testString!(string)(); writeln("string test passed"); testString!(MyString)(); writeln("MyString test passed"); } --- --- output $ dmd testproxy.d $ ./testproxy string test passed core.exception.AssertError testproxy(30): Assertion failure ---------------- 5 testproxy 0x000000010e9a5ea6 _d_assertm + 38 6 testproxy 0x000000010e99297b void testproxy.__assert(int) + 23 7 testproxy 0x000000010e992e45 void testproxy.testString!(std.typecons.Typedef!(immutable(char)[], null).Typedef).testString() + 441 8 testproxy 0x000000010e992930 _Dmain + 36 9 testproxy 0x000000010e9a6846 extern (C) int rt.dmain2.main(int, char**).void runMain() + 34 10 testproxy 0x000000010e9a61fd extern (C) int rt.dmain2.main(int, char**).void tryExec(scope void delegate()) + 45 11 testproxy 0x000000010e9a6890 extern (C) int rt.dmain2.main(int, char**).void runAll() + 56 12 testproxy 0x000000010e9a61fd extern (C) int rt.dmain2.main(int, char**).void tryExec(scope void delegate()) + 45 13 testproxy 0x000000010e9a6187 main + 235 14 libdyld.dylib 0x00007fff8b17d7e1 start + 0 15 ??? 0x0000000000000001 0x0 + 1 ---------------- --- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 04 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8618 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich gmail.com --- Comment #1 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-01-26 15:40:03 PST --- I'm curious which version you made this compile with, I'm getting a compile-time template instance failure instead (see Issue 9407), and this is with 2.062 git-head, 2.061, 2.060 and 2.059. Older versions don't have Typedef. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 26 2013