Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-15384] StrideTo and StrideThrough contains methods don't handle decreasing ranges #57705

swift-ci opened this issue Oct 25, 2021 · 1 comment


Copy link

swift-ci commented Oct 25, 2021

Previous ID SR-15384
Radar None
Original Reporter (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug
Assignee @xwu
Priority Medium

md5: 56008e11dfd8fa313b4b53d09aa6845d

Issue Description:

The `stride(from:to:by)` and `stride(from:through:by)` methods generate a `StrideTo` and `StrideThrough` struct respectively. When the end bound is less than the start bound, calling `contains(_🙂` incorrectly reports false. Consider this:

let r = stride(from: 5, through: 1, by: -1)
print(r.contains(3)) // false

Thanks to @Lukasa, the issue was identified as an override of [`_customContainsEquatableElement`](

Copy link

xwu commented Oct 25, 2021


@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants