Bug 13843 – Issue when passing a delegate as an class alias template parameter

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-12-09T13:22:00Z
Last change time
2015-02-18T03:42:10Z
Keywords
link-failure, pull
Assigned to
nobody
Creator
dev

Comments

Comment #0 by dev — 2014-12-09T13:22:08Z
There is an issue when passing a delegate as an class alias template parameter to be used with std.functional.binaryFun. Look at this code: import std.stdio; import std.functional; class Foo(T, alias greater = "a > b") { private alias compare = binaryFun!(greater); public this() { writefln("%s", compare(2, 1)); } } void main(string[] args) { // These work: auto foo1 = new Foo!(int, "a > b"); auto foo2 = new Foo!(int, (a, b) => a > b); auto foo4 = new Foo!(int, delegate(a, b){return a > b;}); // The following works when the delegate method is called without 'this.' // otherwise they generate linker Errors: auto foo3 = new Foo!(int, (int a, int b) => a > b); auto foo5 = new Foo!(int, delegate(int a, int b){return a > b;}); } If i remove the 'this.' from the compare method call, all works fine. After that call, i can call compare *with* 'this.' and all works. But there has to be an initial call made without the 'this.' for it to work from then on. If i leave the 'this.' in place and pass a delegate as the compare function using types in the parameter list, a linker error occurs when calling the delegate.
Comment #1 by dev — 2014-12-09T13:24:15Z
Changing the compare call to this: writefln("%s", this.compare(2, 1)); Exhibits the linker error.
Comment #2 by k.hara.pg — 2015-01-08T19:03:15Z
Comment #3 by github-bugzilla — 2015-01-11T05:01:19Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/f3556d65281bf7383a36759e7153f5accd645b32 fix Issue 13843 - Issue when passing a delegate as an class alias template parameter https://github.com/D-Programming-Language/dmd/commit/93986fd3ff4e43fa3dc06495095c4e8eccb15eea Merge pull request #4267 from 9rnsr/fix13843 Issue 13843 - Issue when passing a delegate as an class alias template parameter
Comment #4 by github-bugzilla — 2015-02-18T03:42:10Z
Commits pushed to 2.067 at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/f3556d65281bf7383a36759e7153f5accd645b32 fix Issue 13843 - Issue when passing a delegate as an class alias template parameter https://github.com/D-Programming-Language/dmd/commit/93986fd3ff4e43fa3dc06495095c4e8eccb15eea Merge pull request #4267 from 9rnsr/fix13843