[Issue 20928] New: Overloaded opIndex confuses MapResult
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Jun 13 22:28:54 UTC 2020
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 at puremagic.com
Reporter: rmanth at 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.
--
More information about the Digitalmars-d-bugs
mailing list