skiptools / skiptools/skip-lib

ClosedRange.upperBound reports incorrect value

Open
#30 0 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.