[Issue 17401] New: type inference broken when F and Parameters!F are used

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon May 15 23:16:53 PDT 2017


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

          Issue ID: 17401
           Summary: type inference broken when F and Parameters!F are used
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: tomerfiliba at gmail.com

dmd v2.074.0 on ubuntu 14.04

-------------------

import std.traits: Parameters;

void f(int x) {}
void wrap1(R, T...)(R function(T) fn, T args) {}
void wrap2(alias F)(Parameters!F args) {}
void wrap3(F)(F fn, Parameters!F args) {}
void wrap4(F)(F* fn, Parameters!F args) {}


void main() {
    int x;

    wrap1(&f, x);  // ok
    wrap2!f(x);    // ok
    wrap3(&f, x);  // Error: template wrap3 cannot deduce function from
argument types !()(void function(int x), int), candidates are:
                   //        wrap3(F)(F fn, Parameters!F args)

    wrap4!(typeof(f))(&f, x);  // ok -- explicit typeof
    wrap4(&f, x);  // same error
}

--


More information about the Digitalmars-d-bugs mailing list