www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12620] New: Compiler picks lesser template specialization

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

          Issue ID: 12620
           Summary: Compiler picks lesser template specialization match
                    for float array alias value parameters
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: andrej.mitrovich gmail.com

-----
template Foo(alias sym)         { pragma(msg, "Foo1"); }
template Foo(alias int[] sym)   { pragma(msg, "Foo2"); }
template Foo(alias float[] sym) { pragma(msg, "Foo3"); }

void main()
{
    alias foo1 = Foo!(1);      // instantiates #1, ok
    alias foo2 = Foo!([1]);    // instantiates #2, ok
    alias foo3 = Foo!([1.0]);  // instantiates #1 instead of #3!
}
-----

--
Apr 22 2014