Bug 20928 – Overloaded opIndex confuses MapResult

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-06-13T22:28:54Z
Last change time
2020-06-15T16:11:52Z
Keywords
pull
Assigned to
No Owner
Creator
Richard Manthorpe

Comments

Comment #0 by rmanth — 2020-06-13T22:28:54Z
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.
Comment #1 by dlang-bot — 2020-06-15T07:03:33Z
@Biotronic created dlang/phobos pull request #7532 "Issue 20928 - Overloaded opIndex confuses MapResult" fixing this issue: - Fix issue 20928 https://github.com/dlang/phobos/pull/7532
Comment #2 by dlang-bot — 2020-06-15T16:11:52Z
dlang/phobos pull request #7532 "Issue 20928 - Overloaded opIndex confuses MapResult" was merged into master: - 692f909883af8dda23c5cef2b99cb6860675ab91 by Simen Kjærås: Fix issue 20928 https://github.com/dlang/phobos/pull/7532