www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17401] New: type inference broken when F and Parameters!F are

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 puremagic.com
          Reporter: tomerfiliba 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
}

--
May 15 2017