skiptools / skiptools/skip-lib
ClosedRange.upperBound reports incorrect value
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 13
- Forks
- 4
- Avg merge
- 1h 49m
- Merged PRs (30d)
- 2
Description
Range.lowerBound and Range.upperBound is correct for open ranges:
let rangeExclusiveInt = 1..<3
XCTAssertEqual(rangeExclusiveInt.lowerBound, 1)
XCTAssertEqual(rangeExclusiveInt.upperBound, 3)
But for ClosedRange, the upperBound is incorrect: Swift expects 1...3 to be 3, but SkipLib reports 4:
let rangeInclusiveInt = 1...3
XCTAssertEqual(rangeInclusiveInt.lowerBound, 1)
XCTAssertEqual(rangeInclusiveInt.upperBound, 3) // java.lang.AssertionError: 4 != 3
The reason is that we always translate upperBound into endInclusive + 1, since we assume open ranges. Kotlin doesn't distinguish between open ranges and closed ranges (they are both IntRange), so I'm not sure if there is any way of handling this correctly short of having our own independent Range structures.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Trace how SkipLib translates Range.upperBound for the open-range and ClosedRange examples in the issue. Compare the handling of 1..<3 and 1...3, then verify that both lowerBound and upperBound match Swift's expected values without changing the open-range behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin, swift
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100