From 163756675ef150e9c3a54646b95349b942e24e25 Mon Sep 17 00:00:00 2001 From: ttozzi Date: Sat, 5 Apr 2025 20:04:40 +0900 Subject: [PATCH] Removes duplicate trivia from UnsafeExprSyntax --- Sources/SwiftOperators/OperatorTable+Folding.swift | 4 +--- Tests/SwiftOperatorsTest/OperatorTableTests.swift | 6 ++++++ 2 files changed, 7 insertions(+), 3 deletions(-) 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) + } }