[SR-15384] StrideTo and StrideThrough contains
methods don't handle decreasing ranges
#57705
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
standard library
Area: Standard library umbrella
Additional Detail from JIRA
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).
The text was updated successfully, but these errors were encountered: