Bug 11774 – Lambda argument to templated function changes its signature forever

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-12-19T06:53:00Z
Last change time
2014-05-26T17:32:01Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
verylonglogin.reg

Comments

Comment #0 by verylonglogin.reg — 2013-12-19T06:53:48Z
This code should compile: --- void f(T, R)(R delegate(T[]) del) { T[] src; del(src); } void main() { int[] delegate(int[]) del; f!int(del); // ok f!Object(a => a); f!int(del); // fails, line 12 } --- main.d(12): Error: template main.f does not match any function template declaration. Candidates are: main.d(1): main.f(T, R)(R delegate(Object[]) del) main.d(12): Error: template main.f(T, R)(R delegate(Object[]) del) cannot deduce template function from argument types !(int)(int[] delegate(int[])) --- The issue is major as compiler errors are misleading and people don't expect such "broken forever" behaviour.
Comment #1 by verylonglogin.reg — 2013-12-19T06:55:27Z
Workaround: Specify lambda argument types, i.e. `(Object[] a) => a` instead of `a => a`.
Comment #2 by k.hara.pg — 2014-05-26T11:38:21Z
Comment #3 by github-bugzilla — 2014-05-26T17:32:00Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/9c52a1e1538981586b24913f33e03af1d2df7ce3 fix Issue 11774 - Lambda argument to templated function changes its signature forever https://github.com/D-Programming-Language/dmd/commit/77e92c17e6a66aac18cb552e65b78b0579d1a20d Merge pull request #3589 from 9rnsr/fix11774 Issue 11774 - Lambda argument to templated function changes its signature forever