www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15243] New: rejects-valid on variadic

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

          Issue ID: 15243
           Summary: rejects-valid on variadic
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: ace17 free.fr

This code won't compile:

class E(Types...)
{
  void apply(U)(U delegate(Types[0]) f0)
  {
  }
}

void test()
{
  E!int e;

  int f(int) { return 0; }

  e.apply(&f);
}

ace ANTEC:~/projects/bugs/dmd$ dmd -c rejectsvalid1.d 
rejectsvalid1.d(15): Error: template rejectsvalid1.E!int.E.apply cannot deduce
function from argument types !()(int delegate(int _param_0)), candidates are:
rejectsvalid1.d(4):        rejectsvalid1.E!int.E.apply(U)(U delegate(Types[0])
f0)


However, one can make it compile by introducing an alias:

class E(Types...)
{
  alias Types[0] T0;
  void apply(U)(U delegate(T0) f0)
  {
  }
}

I'm using DMD64 D Compiler v2.068.2

--
Oct 24 2015