[Issue 5988] Error when template is instantiated in a class

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Feb 9 06:06:22 PST 2013


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


Andrej Mitrovic <andrej.mitrovich at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|rejects-valid               |accepts-invalid
                 CC|                            |andrej.mitrovich at gmail.com
         OS/Version|Mac OS X                    |All


--- Comment #3 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-02-09 06:06:21 PST ---
(In reply to comment #2)
> This is because that class template is actually
> 
>     template C(T) {
>       class C {
>         <declarations>
>       }
>     }
> 
> so the C inside is referring to the class C, not the template C. This code
> works:
> 
>     class C(T) {
>       Templ!(.C) foo;
>     }
> 
> I don't know why uncomment the global instantiation makes the problem goes
> away.

Yeah, this is an accepts-invalid for this test-case:

template Templ(alias T)
{
    alias T!int Templ;
}

class C(T)
{
    Templ!(C) foo;  // should be NG, must use Templ!(.C)
}

Templ!C foo;

void main()
{
    C!int a;
}

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