Description
When building a package that depends on swift-syntax with the Embedded Swift SDK, compilation fails because _SwiftSyntaxGenericTestSupport uses key path syntax which is not available in Embedded Swift.
Error
error: cannot use key path in embedded Swift
|
18 | .map { $0.droppingLast(while: \.isWhitespace) }
| `- error: cannot use key path in embedded Swift
Location
Sources/_SwiftSyntaxGenericTestSupport/String+TrimmingTrailingWhitespace.swift:18
Suggested Fix
Replace key path with explicit closure:
// Before
.map { $0.droppingLast(while: \.isWhitespace) }
// After
.map { $0.droppingLast(while: { $0.isWhitespace }) }
Environment
- Swift 6.2.3 (swift-6.2.3-RELEASE)
- SDK: swift-6.2.3-RELEASE_wasm-embedded
- Build command:
swift build --swift-sdk swift-6.2.3-RELEASE_wasm-embedded
Notes
This only affects test support code, not the core SwiftSyntax library. However, downstream packages that include swift-syntax as a dependency cannot build for Embedded Swift targets even if they don't use the test support module, because SwiftPM builds all targets.
Description
When building a package that depends on swift-syntax with the Embedded Swift SDK, compilation fails because
_SwiftSyntaxGenericTestSupportuses key path syntax which is not available in Embedded Swift.Error
Location
Sources/_SwiftSyntaxGenericTestSupport/String+TrimmingTrailingWhitespace.swift:18Suggested Fix
Replace key path with explicit closure:
Environment
swift build --swift-sdk swift-6.2.3-RELEASE_wasm-embeddedNotes
This only affects test support code, not the core SwiftSyntax library. However, downstream packages that include swift-syntax as a dependency cannot build for Embedded Swift targets even if they don't use the test support module, because SwiftPM builds all targets.