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

RazvanN <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |[email protected]
         Resolution|---                         |WONTFIX

--- Comment #3 from RazvanN <[email protected]> ---
Generally, the compiler tries to find the common type between the arguments,
however, the common type is chosen to be one of the types of the arguments.
Having the compiler infer the common type in the general case will add more
complexity to the compiler. However, for your use case you can just use
template variadic parameters:

```
void test(A...)(A a)
{
        import std.stdio;
        writeln(A.stringof);                                                    
}

class A     { } 
class B : A { } 
class C : A { } 

void main()
{
    test(1,2,3);    // int
    test(4,5,6.9);  // double
    test(new B(), new C());
}
```

This works.

So this is not a bug in the compiler, it could be seen at most as an
enhancement request, however, this does not buy us anything since we already
have syntax that takes care of the case.

--

Reply via email to