www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17242] New: Specialized templates defined inside functions

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

          Issue ID: 17242
           Summary: Specialized templates defined inside functions fail
                    lookup, moving them outside makes them work
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: andrei erdani.com

This code causes a compilation error:

void main ()
{
    template Floating1(T)
    if (is(T == cfloat) || is(T == cdouble) || is(T == creal))
    {
    }

    template Floating1(T)
    if (is(T == float) || is(T == double) || is(T == real))
    {
    }
}

Error: declaration Floating1(T) if (is(T == float) || is(T == double) || is(T
== real)) is already defined

Obviously moving the two templates to top level works. This is a violation of
the "turtles all the way down" principle.

--
Mar 03