Bug 13484 – Template type deduction from delegate parameter fails

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-09-16T16:26:00Z
Last change time
2015-02-18T03:37:05Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
weltensturm

Comments

Comment #0 by weltensturm — 2014-09-16T16:26:08Z
When overloading a template function taking a delegate with type T with one lacking arguments, type deduction fails: test.d(10): Error: template test.test cannot deduce function from argument types !()(void function(float _param_0) pure nothrow @nogc @safe), candidates are: test.d(2): test.test()(void delegate() hi) test.d(5): test.test(T)(void delegate(T) hi) Minimal example: void test()(void delegate() hi){ } void test(T)(void delegate(T) hi){ } void main(){ test({}); // works test((float){}); // throws error } Expected: No error, correct deduction DMD version: DMD64 D Compiler v2.066
Comment #1 by k.hara.pg — 2014-09-17T10:40:01Z
Comment #2 by github-bugzilla — 2014-09-19T11:32:10Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/bfa9a0007f6fd815ed2920a045c63c7f7b52a0a9 fix Issue 13484 - Template type deduction from delegate parameter fails The implicit conversion of expressions to delegates was added in 0.165 (a2b1fa4978948ca4d293c38666bd607c03ba791a, http://www.digitalmars.com/d/1.0/changelog2.html#new0165), but it was replaced with lazy parameter. https://github.com/D-Programming-Language/dmd/commit/c83986a35b2ef1616b214a9ecda17ff1db682c55 Merge pull request #4000 from 9rnsr/fix13484 Issue 13484 - Template type deduction from delegate parameter fails
Comment #3 by github-bugzilla — 2015-02-18T03:37:05Z