Skip to content

Commit 7db3a72

Browse files
authored
Improve comments in VersionSetSpecifier (#5740)
1 parent 96ed023 commit 7db3a72

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Sources/PackageGraph/VersionSetSpecifier.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,12 @@ extension VersionSetSpecifier {
276276
}
277277

278278
if lhs.lowerBound == rhs {
279-
// Return empty if the range represents the exact version or the range is empty.
280-
if lhs.lowerBound == lhs.upperBound || lhs.lowerBound.nextPatch() == lhs.upperBound {
279+
// Return empty if the range is empty. This means upper and lower bounds are equal since the range is half-open and there are no negative results here.
280+
if lhs.lowerBound == lhs.upperBound {
281+
return .empty
282+
}
283+
// If there is exactly one patch between lower and upper bound, the range represent the lower bound as an exact version. So the range is empty in this case as well.
284+
if lhs.lowerBound.nextPatch() == lhs.upperBound {
281285
return .empty
282286
}
283287
return .range(rhs.nextPatch()..<lhs.upperBound)

0 commit comments

Comments
 (0)