[Issue 274] New: Different template alias arguments are treated as the same.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Aug 1 16:50:15 PDT 2006
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 at digitalmars.com
ReportedBy: daiphoenix at 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".
--
More information about the Digitalmars-d-bugs
mailing list