[Issue 15243] New: rejects-valid on variadic

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Oct 24 02:49:20 PDT 2015


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

--


More information about the Digitalmars-d-bugs mailing list