Bug 9906 – filter of static opCall

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2013-04-08T16:59:00Z
Last change time
2015-02-18T03:39:23Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2013-04-08T16:59:42Z
import std.stdio: writeln; import std.algorithm: map, filter; struct Seen { static bool[int] set; static bool opCall(int n) { auto result = !!(n in set); set[n] = true; return result; } } void main() { auto data = [1, 5, 1, 3, 2, 1]; data.filter!(i => i.Seen).writeln; // OK. data.map!Seen.writeln; // OK. data.filter!Seen.writeln; // Error } DMD 2.063alpha gives: temp.d(18): Error: template instance filter!(Seen) does not match template declaration filter(alias pred) if (is(typeof(unaryFun!(pred))))
Comment #1 by hsteoh — 2014-09-25T20:09:53Z
Comment #2 by github-bugzilla — 2014-10-04T14:39:41Z
Commit pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/3b623f9939747fb687ccbcb5879eaf319e942f60 Merge pull request #2556 from quickfur/issue9906 Fix 9906: extend unaryFun and binaryFun to recognize function objects
Comment #3 by hsteoh — 2014-10-04T15:06:22Z
Confirmed fixed in git HEAD
Comment #4 by github-bugzilla — 2015-02-18T03:39:23Z