diff --git a/Sources/SwiftOperators/OperatorTable+Folding.swift b/Sources/SwiftOperators/OperatorTable+Folding.swift index c1c4f7f6025..3c2c63d3e97 100644 --- a/Sources/SwiftOperators/OperatorTable+Folding.swift +++ b/Sources/SwiftOperators/OperatorTable+Folding.swift @@ -141,7 +141,6 @@ extension OperatorTable { if let unsafeExpr = lhs.as(UnsafeExprSyntax.self) { return ExprSyntax( UnsafeExprSyntax( - leadingTrivia: unsafeExpr.leadingTrivia, unsafeExpr.unexpectedBeforeUnsafeKeyword, unsafeKeyword: unsafeExpr.unsafeKeyword, unsafeExpr.unexpectedBetweenUnsafeKeywordAndExpression, @@ -150,8 +149,7 @@ extension OperatorTable { op: op, rhs: rhs ), - unsafeExpr.unexpectedAfterExpression, - trailingTrivia: unsafeExpr.trailingTrivia + unsafeExpr.unexpectedAfterExpression ) ) } diff --git a/Tests/SwiftOperatorsTest/OperatorTableTests.swift b/Tests/SwiftOperatorsTest/OperatorTableTests.swift index e4c81c4605b..47e5bd2ad2f 100644 --- a/Tests/SwiftOperatorsTest/OperatorTableTests.swift +++ b/Tests/SwiftOperatorsTest/OperatorTableTests.swift @@ -435,4 +435,10 @@ class OperatorPrecedenceTests: XCTestCase { } } + + func testTriviaAroundUnsafeExpr() throws { + let original = ExprSyntax("/*leading*/ unsafe a /*trailing*/ + b") + let folded = try OperatorTable.standardOperators.foldAll(original) + XCTAssertEqual(original.description, folded.description) + } }