www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2279] New: alias within function template

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2279

           Summary: alias within function template
           Product: D
           Version: 1.034
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: Daniel919 web.de


template Test(T) { alias int V; void test(T t) {} }
Test!(int).test(0); //OK

template test(T) { alias int V; void test(T t) {} }
test!(int)(0); //Error
test(0) //Error

template test(T) { void test(T t) {} }
test!(int)(0); //OK
test(0); //OK


-- 
Aug 12 2008
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2279


2korden gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID




------- Comment #1 from 2korden gmail.com  2008-08-12 09:41 -------
This is not a bug, it is by desing.

If you create exactly one symbol (an alias, variable or a function) and it
matches the template name, you can access it without fully qualified name, like
this:

template foo()
{
    const int foo = 42;
}

const int f = foo();

but if you introduce a second symbol then you should fully specify it:

template foo()
{
    void foo() {}
    int bar(int i) { return i; }
}

foo!().foo();
int bar = foo!().bar(42);

http://www.digitalmars.com/d/1.0/template.html


-- 
Aug 12 2008