digitalmars.D.bugs - [Issue 20928] New: Overloaded opIndex confuses MapResult
- d-bugmail puremagic.com (35/35) Jun 13 2020 https://issues.dlang.org/show_bug.cgi?id=20928
https://issues.dlang.org/show_bug.cgi?id=20928 Issue ID: 20928 Summary: Overloaded opIndex confuses MapResult Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: rmanth gmail.com struct Always3 { enum empty = false; auto save() { return this; } long front() { return 3; } void popFront() {} long opIndex(size_t i) { return 3; } long opIndex(size_t i) immutable { return 3; }; } void main() { import std.algorithm.iteration : map; Always3.init.map!"a"[size_t.max]; } outputs: Error: function std.algorithm.iteration.MapResult!(unaryFun, Always3).MapResult.opIndex(uint index) is not callable using argument types (ulong) MapResult checks if it can call opIndex with ulong.max and fails for some reason. Changing the check from is(typeof(_input[ulong.max])) to is(typeof(() => _input[ulong.max])) fixes the problem. --
Jun 13 2020