Skip to content

Commit 595b197

Browse files
committed
Remove Comparable requirement from Range bound
Fails due to /Users/dave/src/hylo/Sources/IR/Emitter.swift:2321: Fatal error: lvalue lowering for cast expressions #1049
1 parent b2b2e9d commit 595b197

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

StandardLibrary/Sources/Core/Range.hylo

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/// A half-open interval from a lower bound up to, but not including, an uppor bound.
2-
public type Range<Bound: SemiRegular & Comparable> {
2+
public type Range<Bound: SemiRegular> {
33

44
// TODO: private(set)
55
/// The minimum value included in `self`.
@@ -22,13 +22,13 @@ public type Range<Bound: SemiRegular & Comparable> {
2222
}
2323

2424
/// Returns `true` iff `element` is contained in `self`.
25-
public fun contains(_ element: Bound) -> Bool {
26-
(element >= lower_bound) && (element < upper_bound)
25+
public fun contains<B: Comparable where Bound == B>(_ element: B) -> Bool {
26+
((element as! Bound) >= lower_bound) && ((element as! Bound) < upper_bound)
2727
}
2828

2929
/// Returns `true` iff `other` is contained in `self`.
30-
public fun contains(_ other: Self) -> Bool {
31-
(other.lower_bound >= self.lower_bound) && (other.upper_bound <= self.upper_bound)
30+
public fun contains<B: Comparable where Bound == B>(_ other: Range<B>) -> Bool {
31+
((other.lower_bound as! Bound) >= self.lower_bound) && ((other.upper_bound as! Bound) <= self.upper_bound)
3232
}
3333

3434
}

0 commit comments

Comments
 (0)