From 0d92bf6b08bc3660c37db90c7e789f88f565fd82 Mon Sep 17 00:00:00 2001 From: Clinton Nkwocha <32041805+clintonpi@users.noreply.github.com> Date: Thu, 5 Dec 2024 11:16:11 +0000 Subject: [PATCH] Enable strict concurrency (#53) Motivation: To catch potential data races at build time. Modifications: - Enable strict concurrency in Package.swift. - Add `Sendable` conformance to `StructuredFieldType`. - Swap [concurrency-unsafe](https://github.com/swiftlang/swift/issues/66213) `CommandLine.arguments` for `ProcessInfo.processInfo.arguments`. Result: Strict concurrency adoption. --- Package.swift | 6 ++++++ Sources/StructuredFieldValues/StructuredFieldValue.swift | 2 +- Sources/sh-parser/main.swift | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Package.swift b/Package.swift index dacc987..80da2b4 100644 --- a/Package.swift +++ b/Package.swift @@ -45,3 +45,9 @@ let package = Package( ), ] ) + +for target in package.targets { + var settings = target.swiftSettings ?? [] + settings.append(.enableExperimentalFeature("StrictConcurrency=complete")) + target.swiftSettings = settings +} diff --git a/Sources/StructuredFieldValues/StructuredFieldValue.swift b/Sources/StructuredFieldValues/StructuredFieldValue.swift index ad1370d..c9b3324 100644 --- a/Sources/StructuredFieldValues/StructuredFieldValue.swift +++ b/Sources/StructuredFieldValues/StructuredFieldValue.swift @@ -22,7 +22,7 @@ public protocol StructuredFieldValue: Codable { } /// The kinds of header fields used in HTTP Structured Headers. -public enum StructuredFieldType { +public enum StructuredFieldType: Sendable { /// An item field consists of a single item, optionally with parameters. case item diff --git a/Sources/sh-parser/main.swift b/Sources/sh-parser/main.swift index 54a1366..21f305c 100644 --- a/Sources/sh-parser/main.swift +++ b/Sources/sh-parser/main.swift @@ -21,8 +21,9 @@ struct Flags { init() { // Default to item self.headerType = .item + let arguments = ProcessInfo.processInfo.arguments - for argument in CommandLine.arguments.dropFirst() { + for argument in arguments.dropFirst() { switch argument { case "--dictionary": self.headerType = .dictionary