Skip to content

Commit 318c963

Browse files
committed
Get stdlib building again
PR 79186 (#79186) moved one of the mandatory passes from the C++ implementation to the Swift implementation resulting in a compiler that is unable to build the standard library. The pass used to ensure that inaccessible control-flow positions after an infinite loop was marked with `unreachable` in SIL. Since the pass is no longer running, any function that returns a value that also has an infinite loop internally must place a fatalError after the infinite loop or it will fail to compile as the compiler will determine that the function does not return from all control flow paths even though some of the paths are unreachable.
1 parent a792717 commit 318c963

10 files changed

+14
-0
lines changed

stdlib/public/core/CollectionAlgorithms.swift

+1
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ extension MutableCollection where Self: BidirectionalCollection {
441441
swapAt(lo, hi)
442442
formIndex(after: &lo)
443443
}
444+
fatalError()
444445
}
445446
}
446447

stdlib/public/core/Flatten.swift

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ extension FlattenSequence.Iterator: IteratorProtocol {
8585
_inner = s!.makeIterator()
8686
}
8787
while true
88+
fatalError()
8889
}
8990
}
9091

stdlib/public/core/HashTable.swift

+2
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ extension _HashTable {
387387
return unsafe Bucket(word: word, bit: bit)
388388
}
389389
}
390+
fatalError()
390391
}
391392

392393
@inlinable
@@ -414,6 +415,7 @@ extension _HashTable {
414415
return unsafe Bucket(word: word, bit: bit)
415416
}
416417
}
418+
fatalError()
417419
}
418420
}
419421

stdlib/public/core/Join.swift

+1
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ extension JoinedSequence.Iterator: IteratorProtocol {
125125
return nil
126126
}
127127
}
128+
fatalError()
128129
}
129130
}
130131

stdlib/public/core/KeyPath.swift

+3
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ public class AnyKeyPath: _AppendKeyPath {
193193

194194
if optNextType == nil { return .some(offset) }
195195
}
196+
fatalError()
196197
}
197198
#else
198199
// compiler optimizes _storedInlineOffset into a direct offset computation,
@@ -271,6 +272,7 @@ extension AnyKeyPath: Hashable {
271272
return true
272273
}
273274
}
275+
fatalError()
274276
}
275277
}
276278
}
@@ -432,6 +434,7 @@ public class KeyPath<Root, Value>: PartialKeyPath<Root> {
432434
}
433435
}
434436
}
437+
fatalError()
435438
}
436439
}
437440
}

stdlib/public/core/SequenceAlgorithms.swift

+2
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ extension Sequence {
332332
case (nil, nil): return true
333333
}
334334
}
335+
fatalError()
335336
}
336337
}
337338

@@ -425,6 +426,7 @@ extension Sequence {
425426
return false
426427
}
427428
}
429+
fatalError()
428430
}
429431
}
430432

stdlib/public/core/StringComparison.swift

+1
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ private func _findBoundary(
265265

266266
unsafe idx &-= _utf8ScalarLength(utf8, endingAt: idx)
267267
}
268+
fatalError()
268269
}
269270

270271
@frozen

stdlib/public/core/StringUTF16View.swift

+1
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,7 @@ extension String.UTF16View {
945945

946946
readIdx &+= len
947947
}
948+
fatalError()
948949
}
949950
}
950951

stdlib/public/core/UTF16.swift

+1
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ extension Unicode.UTF16 {
256256
return (utf16Count, utf16BitUnion < 0x80)
257257
}
258258
}
259+
fatalError()
259260
}
260261
}
261262

stdlib/public/core/Unicode.swift

+1
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ public func transcode<
585585
}
586586
OutputEncoding.encodedReplacementCharacter.forEach(processCodeUnit)
587587
}
588+
fatalError()
588589
}
589590

590591
/// Instances of conforming types are used in internal `String`

0 commit comments

Comments
 (0)