[Issue 3538] Default value of alias template parameter is instantiated only once.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Apr 23 12:50:48 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3538
Robert Clipsham <robert at octarineparrot.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
CC| |robert at octarineparrot.com
--- Comment #1 from Robert Clipsham <robert at octarineparrot.com> 2010-04-23 20:50:46 BST ---
This is caused as default arguments to templates are only instantiated once,
which causes the Boo!T to always become whatever is instantiated first. The
patch below fixes this:
--- template.c 2010-03-18 18:58:06.000000000 +0000
+++ template.c 2010-04-23 20:49:54.000000000 +0100
@@ -2993,6 +2993,17 @@
Object *TemplateAliasParameter::defaultArg(Loc loc, Scope *sc)
{
+ Type *ta = isType(defaultAlias);
+ if (ta)
+ {
+ if (ta->ty == Tinstance)
+ {
+ // If the default arg is a template, instantiate for each type
+ Object *da = ta->syntaxCopy();
+ Object *o = aliasParameterSemantic(loc, sc, da);
+ return o;
+ }
+ }
Object *o = aliasParameterSemantic(loc, sc, defaultAlias);
return o;
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list