@@ -410,7 +410,13 @@ extension Range: Decodable where Bound: Decodable {
410
410
var container = try decoder. unkeyedContainer ( )
411
411
let lowerBound = try container. decode ( Bound . self)
412
412
let upperBound = try container. decode ( Bound . self)
413
- self = lowerBound..< upperBound
413
+ guard lowerBound <= upperBound else {
414
+ throw DecodingError . dataCorrupted (
415
+ DecodingError . Context (
416
+ codingPath: decoder. codingPath,
417
+ debugDescription: " Cannot initialize \( Range . self) with a lowerBound ( \( lowerBound) ) greater than upperBound ( \( upperBound) ) " ) )
418
+ }
419
+ self . init ( uncheckedBounds: ( lower: lowerBound, upper: upperBound) )
414
420
}
415
421
}
416
422
@@ -467,7 +473,7 @@ extension PartialRangeUpTo: RangeExpression {
467
473
extension PartialRangeUpTo : Decodable where Bound: Decodable {
468
474
public init ( from decoder: Decoder ) throws {
469
475
var container = try decoder. unkeyedContainer ( )
470
- self = try ( ..< container. decode ( Bound . self) )
476
+ try self . init ( container. decode ( Bound . self) )
471
477
}
472
478
}
473
479
@@ -522,7 +528,7 @@ extension PartialRangeThrough: RangeExpression {
522
528
extension PartialRangeThrough : Decodable where Bound: Decodable {
523
529
public init ( from decoder: Decoder ) throws {
524
530
var container = try decoder. unkeyedContainer ( )
525
- self = try ( ... container. decode ( Bound . self) )
531
+ try self . init ( container. decode ( Bound . self) )
526
532
}
527
533
}
528
534
@@ -672,7 +678,7 @@ extension PartialRangeFrom: Sequence
672
678
extension PartialRangeFrom : Decodable where Bound: Decodable {
673
679
public init ( from decoder: Decoder ) throws {
674
680
var container = try decoder. unkeyedContainer ( )
675
- self = try container. decode ( Bound . self) ...
681
+ try self . init ( container. decode ( Bound . self) )
676
682
}
677
683
}
678
684
0 commit comments