digitalmars.D.bugs - [Issue 3538] New: Default value of alias template parameter is instantiated only once.
- d-bugmail puremagic.com (29/29) Nov 21 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3538
- d-bugmail puremagic.com (32/32) Apr 23 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3538
- d-bugmail puremagic.com (12/12) May 16 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3538
http://d.puremagic.com/issues/show_bug.cgi?id=3538
Summary: Default value of alias template parameter is
instantiated only once.
Product: D
Version: 2.036
Platform: x86
OS/Version: Linux
Status: NEW
Severity: critical
Priority: P2
Component: DMD
AssignedTo: nobody puremagic.com
ReportedBy: e.insafutdinov gmail.com
12:28:04 PST ---
template Boo(T) {}
struct Foo(T, alias V = Boo!T) { pragma(msg, V.stringof); }
alias Foo!double B;
alias Foo!int A;
outputs
Boo!(double)
Boo!(double)
while it should
Boo!(double)
Boo!(int)
Although it's a blocker for a design that I intend to use, I don't mark it as
such with hope that it'll get fixed, as it looks trivial to me.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 21 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3538
Robert Clipsham <robert octarineparrot.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
CC| |robert octarineparrot.com
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: -------
Apr 23 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3538
Walter Bright <bugzilla digitalmars.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |bugzilla digitalmars.com
Resolution| |FIXED
11:15:20 PDT ---
changelog 492
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 16 2010









d-bugmail puremagic.com 