digitalmars.D.bugs - [Issue 4617] New: Alias this'ed symbols cannot be passed to templates
- d-bugmail puremagic.com (60/60) Aug 10 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4617
- d-bugmail puremagic.com (24/24) Aug 10 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4617
- d-bugmail puremagic.com (11/11) Jun 30 2012 http://d.puremagic.com/issues/show_bug.cgi?id=4617
- d-bugmail puremagic.com (9/9) Mar 04 2013 http://d.puremagic.com/issues/show_bug.cgi?id=4617
http://d.puremagic.com/issues/show_bug.cgi?id=4617 Summary: Alias this'ed symbols cannot be passed to templates Product: D Version: unspecified Platform: All OS/Version: All Status: NEW Keywords: rejects-valid Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: rsinfu gmail.com --- DMD tries to evaluate alias this'ed symbols. It causes a compile error on instantiating templates with alias this'ed symbols. -------------------- test1.d alias Test!(S.square) test; struct S { struct F { int square(int n) { return n*n; } real square(real n) { return n*n; } } F forward; alias forward this; } template Test(alias k) {} -------------------- % dmd -o- -c test1.d test1.d(1): Error: function test1.S.F.square (int n) is not callable using argument types () test1.d(1): Error: expected 1 function arguments, not 0 % _ -------------------- TemplateInstance::semanticTiargs() (or TypeQualified::resolveHelper()) resolves forwarded symbols as dotvar expressions and tries to evaluate them at compile time. Apparently, it causes the problem. The error does not occur if the symbol is forwarded directly: -------------------- test2.d alias Test!(S.square) test; struct S { struct F { int square(int n) { return n*n; } real square(real n) { return n*n; } } F forward; alias forward.square square; // okay } template Test(alias k) {} -------------------- % dmd -o- -c test2.d % _ -------------------- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 10 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4617 --- The bug also causes a false negative of __traits(isSame), becuase isSame reuses the same algorithm as template instantiation: -------------------- test3.d static assert( __traits(isSame, S.square, S.forward.square) ); struct S { struct F { int square(int n) { return n*n; } real square(real n) { return n*n; } } F forward; alias forward this; } -------------------- % dmd -o- -c test3.d test3.d(1): Error: static assert (__traits(isSame,forward.square,square)) is false -------------------- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 10 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4617 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull Version|unspecified |D2 https://github.com/D-Programming-Language/dmd/pull/1032 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 30 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4617 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 04 2013