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


Don <clugd...@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
                 CC|                            |clugd...@yahoo.com.au


--- Comment #1 from Don <clugd...@yahoo.com.au> 2010-03-02 11:19:28 PST ---
The missing line number is the only bug here; the rest is an enhancement
request. You have a recursive definition in sum.opAdd(). As soon as you do
anything which forces opAdd to be instantiated, the recursion is detected.

Here's a reduced test case for what you're doing:

struct sum(A) {
    auto blah(int a) { return .sum!(sum)(); }
}

sum!(int) z;

-------
A quick, incomplete patch to improve the error message slightly: Template.c
line 156.
(Doesn't help very much, since it only gives the line number of the template
which is being instantiated, whereas you might want the line which was
instantiating it).
In fact, this particular test case will compile OK if the error message is
removed. (still need to return 1 to fake a match). But that won't work in
general.

    if (t1)
    {
    /* if t1 is an instance of ti, then give error
     * about recursive expansions.
     */
    Dsymbol *s = t1->toDsymbol(sc);
    if (s && s->parent)
    {   TemplateInstance *ti1 = s->parent->isTemplateInstance();
        if (ti1 && ti1->tempdecl == tempdecl)
        {
        for (Scope *sc1 = sc; sc1; sc1 = sc1->enclosing)
        {
            if (sc1->scopesym == ti1)
            {
-            error("recursive template expansion for template argument %s",
t1->toChars());
+            error(s->loc, "recursive template expansion for template argument
%s", t1->toChars());
            return 1;    // fake a match
            }
        }
        }
    }

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to