Skip to content

_SwiftSyntaxGenericTestSupport uses key paths which are unavailable in Embedded Swift #3227

@coenttb

Description

@coenttb

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions