www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 274] New: Different template alias arguments are treated as the same.

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

           Summary: Different template alias arguments are treated as the
                    same.
           Product: D
           Version: 0.163
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: critical
          Priority: P1
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: daiphoenix lycos.com


Under certain conditions, different template alias arguments are treated as the
same, and thus fail to create different template instances. Consider this code:

----
import std.stdio;

class Foo {} 
class Bar {}

template aliastest(alias A) {
        pragma(msg,"Alias Test instanciated");  
        void aliastest() {
                writefln("Alias Test: ", (new A!().al).classinfo.name);
        }
}

template boxtpl(alias A) {
        template box() {
                alias A al;
        }
}

void test() {
        aliastest!(boxtpl!(Foo).box) ();
        aliastest!(boxtpl!(Bar).box) ();
        aliastest!(boxtpl!(Exception).box) ();
}
----

In the test function, aliastest is only instantiated once (we only see the
pragma msg once), and both instances are considered to be the same, such that
the runtime output is: 
  Alias Test: Foo
  Alias Test: Foo
  Alias Test: Foo

That is, "aliastest!(boxtpl!(Bar).box)" and any other subsequent atempted
instantiations of the form "aliastest!(boxtpl!(XXXX).box)" are considered to be
the same as the first one, the one with alias argument "boxtpl!(Foo).box".


-- 
Aug 01 2006
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=274


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED





Fixed DMD 0.164


-- 
Aug 11 2006