[Issue 4913] Repeated template instantiations with the same symbol argument fails

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Sep 21 18:44:17 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4913


Shin Fujishiro <rsinfu at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


--- Comment #1 from Shin Fujishiro <rsinfu at gmail.com> 2010-09-21 18:43:39 PDT ---
This patch fixes the problem (dmd r680):
====================
--- src/template.c
+++ src/template.c
@@ -4641,6 +4641,12 @@ Identifier *TemplateInstance::genIdent()
                 ea = NULL;
                 goto Lsa;
             }
+            if (ea->op == TOKdsymbol)
+            {
+                sa = ((DsymbolExp *)ea)->s;
+                ea = NULL;
+                goto Lsa;
+            }
             buf.writeByte('V');
             if (ea->op == TOKtuple)
             {   ea->error("tuple is not a valid template value argument");
====================

NOTE: I think the problem is that DsymbolExp::semantic() just returns 'this' if
it already run, whereas the function does elaborate AST rewriting. As for this
report's case, it rewrites itself to a VarExp *only* at the first semantic run.

So, the following patch also fixes the reported problem.
====================
--- src/expression.c
+++ src/expression.c
@@ -2244,8 +2244,10 @@ Lagain:

     //printf("DsymbolExp:: %p '%s' is a symbol\n", this, toChars());
     //printf("s = '%s', s->kind = '%s'\n", s->toChars(), s->kind());
+#if 0
     if (type)
         return this;
+#endif
     if (!s->isFuncDeclaration())        // functions are checked after
overloading
         checkDeprecated(sc, s);
     s = s->toAlias();

-- 
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