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

Closed
swift-ci opened this issue Oct 25, 2021 · 1 comment
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-15384
Radar None
Original Reporter sean.rich (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`](https://forums.swift.org/t/is-there-a-bug-in-stride-fromby-or-is-it-me/53043).

@xwu
Copy link
Collaborator

xwu commented Oct 25, 2021

#39903

@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
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

2 participants