www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15764] New: Name of template cannot

https://issues.dlang.org/show_bug.cgi?id=15764

          Issue ID: 15764
           Summary: Name of template cannot
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: samjnaa gmail.com

Ref: http://forum.dlang.org/post/nb8kkg$1ea0$1 digitalmars.com

string ta(string s) { return s ~ "1"; }
template ta(string s) { enum ta = .ta(s); }
void main()
{
    import std.stdio;
    writeln(ta("a"), ' ', ta!"b");
}

outputs "a1 b1" as expected. So the compiler is in general able to identify
when a symbol refers to a function and when a template, but if I remove the .
before the ta(s) *within* the template ta, it gives an error:

<src>(2): Error: forward reference of variable ta
<src>(6): Error: template instance <src>.ta!"b" error instantiating

This seems to be a minor limitation (and maybe not of terribly high priority)
that symbol lookup within an (eponymous?) template doesn't look outside the
template for other possible compatible symbols and requires a preceding "." to
tell it to look at top-level.

--
Mar 04 2016