[Issue 17242] New: Specialized templates defined inside functions fail lookup, moving them outside makes them work

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Mar 3 07:41:06 PST 2017


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 at puremagic.com
          Reporter: andrei at 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.

--


More information about the Digitalmars-d-bugs mailing list