Bug 274 – Different template alias arguments are treated as the same.

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-08-01T18:50:00Z
Last change time
2014-02-15T13:20:52Z
Keywords
wrong-code
Assigned to
bugzilla
Creator
bruno.do.medeiros+deebugz

Comments

Comment #0 by bruno.do.medeiros+deebugz — 2006-08-01T18:50:12Z
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".
Comment #1 by bugzilla — 2006-08-11T19:17:58Z
Fixed DMD 0.164