swiftlang / swiftlang/swift-syntax

_SwiftSyntaxGenericTestSupport uses key paths which are unavailable in Embedded Swift

Open
#3,227 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
3.7k
Forks
553
Avg merge
5d 13h
Merged PRs (30d)
16

Description

## 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:

```swift
// 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.