diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index d7e87ad..3ec9a4a 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -35,10 +35,14 @@ jobs: enable_windows_checks: false embedded: - name: Embedded Test (Linux nightly-6.3) + name: Embedded Test (Linux nightly-${{ matrix.swift_version }}) runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + swift_version: ["6.3", "6.4.x"] container: - image: swiftlang/swift:nightly-6.3-jammy + image: swiftlang/swift:nightly-${{ matrix.swift_version }}-jammy steps: - name: Swift version run: swift --version diff --git a/EmbeddedExample/EmbeddedParser.swift b/EmbeddedExample/EmbeddedParser.swift index 4df6658..de3149e 100644 --- a/EmbeddedExample/EmbeddedParser.swift +++ b/EmbeddedExample/EmbeddedParser.swift @@ -24,6 +24,10 @@ struct EmbeddedTest { precondition(a == 1) precondition(b == 0x203) - print(c) + precondition(c == 0x405) + print("Should print '1 / 515 / 1029' on separate lines") + print(a) // 1 + print(b) // 515 + print(c) // 1029 } } diff --git a/Sources/BinaryParsing/Parser Types/ParserSource.swift b/Sources/BinaryParsing/Parser Types/ParserSource.swift index 4afe91c..27f40f6 100644 --- a/Sources/BinaryParsing/Parser Types/ParserSource.swift +++ b/Sources/BinaryParsing/Parser Types/ParserSource.swift @@ -107,7 +107,7 @@ public protocol ParserSpanProvider { } extension ParserSpanProvider { - #if !$Embedded + #if !$Embedded || compiler(>=6.4) /// Executes the given closure with a `ParserSpan` over the contents of this /// type, consuming the given parser range instead of the full span. @_alwaysEmitIntoClient diff --git a/Sources/BinaryParsing/Parser Types/ParsingError.swift b/Sources/BinaryParsing/Parser Types/ParsingError.swift index 733ac61..a39bb2b 100644 --- a/Sources/BinaryParsing/Parser Types/ParsingError.swift +++ b/Sources/BinaryParsing/Parser Types/ParsingError.swift @@ -49,7 +49,7 @@ public struct ParsingError: Error { _location >= 0 ? _location : nil } - #if !$Embedded + #if !$Embedded || compiler(>=6.4) /// The user-provided error associated with this parsing error. public var userError: (any Error)? @@ -78,13 +78,15 @@ public struct ParsingError: Error { } } -#if !$Embedded +#if !$Embedded || compiler(>=6.4) extension ParsingError { public init(userError: any Error) { self = .init(status: .userError, userError: userError) } } +#endif +#if !$Embedded extension ParsingError: CustomStringConvertible { public var description: String { if let location { @@ -109,19 +111,20 @@ extension ParsingError.Status: CustomStringConvertible { } #endif -#if !$Embedded +#if !$Embedded || compiler(>=6.4) /// An error thrown by the library user. /// -/// In a build for non-embedded Swift, `ThrownParsingError` aliases `any Error`, -/// so you can throw an error of any kind from closures passed to methods that -/// are designated as `throws(ThrownParsingError)`. When the method throws an -/// error, it will always be either your error or an instance of -/// `ParsingError`. +/// In a build for non-embedded Swift, or any build using a 6.4 or newer compiler, +/// `ThrownParsingError` aliases `any Error`, so you can throw an error of +/// any kind from closures passed to methods that are designated as +/// `throws(ThrownParsingError)`. When the method throws an error, +/// it will always be either your error or an instance of `ParsingError`. /// -/// In a build for embedded Swift, `ThrownParsingError` instead aliases the -/// specific `ParsingError` type. Because embedded Swift supports only -/// fully-typed throws, and not the existential `any Error`, this allows you to -/// still use error-throwing APIs in an embedded context. +/// In a build for embedded Swift using a pre-6.4 compiler, `ThrownParsingError` +/// instead aliases the specific `ParsingError` type. Because this version of +/// embedded Swift supports only fully-typed throws, and not the existential +/// `any Error`, this allows you to still use error-throwing APIs in an embedded +/// context. public typealias ThrownParsingError = any Error #else // Documentation is built using the non-embedded build. diff --git a/Sources/BinaryParsing/Parsers/Array.swift b/Sources/BinaryParsing/Parsers/Array.swift index 86d84d0..8aac8ed 100644 --- a/Sources/BinaryParsing/Parsers/Array.swift +++ b/Sources/BinaryParsing/Parsers/Array.swift @@ -44,7 +44,7 @@ extension Array where Element == UInt8 { } extension Array { - #if !$Embedded + #if !$Embedded || compiler(>=6.4) /// Creates a new array by parsing the specified number of elements from the given /// parser span, using the provided closure for parsing. /// diff --git a/Sources/BinaryParsing/Parsers/InlineArray.swift b/Sources/BinaryParsing/Parsers/InlineArray.swift index b87c88a..eec6fc6 100644 --- a/Sources/BinaryParsing/Parsers/InlineArray.swift +++ b/Sources/BinaryParsing/Parsers/InlineArray.swift @@ -28,7 +28,7 @@ extension InlineArray where Element == UInt8 { @available(macOS 26, iOS 26, watchOS 26, tvOS 26, visionOS 26, *) extension InlineArray where Element: ~Copyable { - #if !$Embedded + #if !$Embedded || compiler(>=6.4) /// Creates a new array by parsing the specified number of elements from the given /// parser span, using the provided closure for parsing. /// diff --git a/Sources/BinaryParsing/Parsers/Range.swift b/Sources/BinaryParsing/Parsers/Range.swift index 2c97bfe..b096a84 100644 --- a/Sources/BinaryParsing/Parsers/Range.swift +++ b/Sources/BinaryParsing/Parsers/Range.swift @@ -12,7 +12,7 @@ // MARK: Start & Count extension Range where Bound: FixedWidthInteger { - #if !$Embedded + #if !$Embedded || compiler(>=6.4) /// Creates a new half-open range by parsing the start and count of the range, /// using the given parser closure for each value. /// @@ -68,7 +68,7 @@ extension Range where Bound: FixedWidthInteger { } extension ClosedRange where Bound: FixedWidthInteger { - #if !$Embedded + #if !$Embedded || compiler(>=6.4) @available( *, deprecated, message: @@ -112,7 +112,7 @@ extension ClosedRange where Bound: FixedWidthInteger { // MARK: Start & End extension Range { - #if !$Embedded + #if !$Embedded || compiler(>=6.4) /// Creates a new half-open range by parsing the start and end of the range, /// using the given parser closure for each value. /// @@ -168,7 +168,7 @@ extension Range { } extension ClosedRange { - #if !$Embedded + #if !$Embedded || compiler(>=6.4) /// Creates a new closed range by parsing the start and end of the range, /// using the given parser closure for each value. ///