Skip to content

Commit 5039ad5

Browse files
committed
Document foldAll behavior that calls error handler twice.
1 parent d4c99e3 commit 5039ad5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Sources/SwiftOperatorPrecedence/OperatorPrecedence+Folding.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,11 @@ extension OperatorPrecedence {
444444
/// tree with structured syntax trees, by walking the tree and invoking
445445
/// `foldSingle` on each sequence expression it encounters. Use this to
446446
/// provide structure to an entire tree.
447+
///
448+
/// Due to the inability to express the implementation of this rethrowing
449+
/// function, a throwing error handler will end up being called twice with
450+
/// the first error that causes it to be thrown. The first call will stop
451+
/// the operation, then the second must also throw.
447452
public func foldAll<Node: SyntaxProtocol>(
448453
_ node: Node,
449454
errorHandler: OperatorPrecedenceErrorHandler = { throw $0 }
@@ -459,6 +464,7 @@ extension OperatorPrecedence {
459464
// error.
460465
if let origFatalError = folder.firstFatalError {
461466
try errorHandler(origFatalError)
467+
fatalError("error handler did not throw again after \(origFatalError)")
462468
}
463469

464470
return result

0 commit comments

Comments
 (0)