Skip to content

Typed throws, cached regexes, ISO8601FormatStyle, Swift 6.4 CI - #23

Merged
RISCfuture merged 2 commits into
mainfrom
swift-6.4/modernization
Sep 15, 2026
Merged

RISCfuture merged 2 commits into
mainfrom
swift-6.4/modernization

Conversation

@RISCfuture

Copy link
Copy Markdown
Owner
  • Typed throws on 145 signatures across 92 files.
  • Removes the lone NSRegularExpression; rx is now built with RegexBuilder from allCases and cached. A second run-time-string-built Regex (joined from Dictionary.keys, which has no guaranteed order) is also replaced — that one was a latent nondeterminism bug.
  • ISO8601DateFormatter → cached Date.ISO8601FormatStyle, the last holdout in a package already using FormatStyle in 184 places.
  • Adds Swift 6.4 CI legs.

.strictMemorySafety() was trialled and removed — it produced ~40 warnings. LockedRegex and Regex+Sendable are untouched: Regex is still not Sendable in 6.4.


🤖 Generated with Claude Code

https://claude.ai/code/session_01EbZbx5D2gGeXT8UxuiKEdq

@RISCfuture
RISCfuture force-pushed the swift-6.4/modernization branch 2 times, most recently from 3309e6f to 62962c4 Compare September 14, 2026 23:08
RISCfuture and others added 2 commits September 14, 2026 20:09
Swift 6.4 modernization pass.

Typed throws: every throwing API in SwiftMETAR now declares `throws(Error)`,
from the leaf date/visibility/weather parsers up through `METAR.from(string:)`,
`TAF.from(string:)`, and `CodedRepresentable.init(coded:)`. `LockedRegex` gains
a narrowing shim, since `Regex` matching declares `any Error` even though the
only thing it can throw is what this package's own `transform:` closures throw.
`Codable`'s `init(from:)`/`encode(to:)` and `XMLParseResult.get()` keep untyped
`throws`, as their errors are `DecodingError` and a caller-supplied error.
Closure literals do not infer a contextual thrown type, so the few closures
passed to typed-throwing parameters became local functions, method references,
or `for` loops.

Regex construction: the `RegexCases` case alternation and the remark direction
alternation were both assembled as pattern strings and compiled at run time
(one via `NSRegularExpression.escapedPattern(for:)`, the last use of
`NSRegularExpression` in the package). Both now fold their alternatives with
RegexBuilder's `AlternationBuilder`, matching each alternative literally. Case
alternations are cached per conforming type instead of being rebuilt on every
access, and `rx` no longer throws, which removes 31 `try!` sites and every
`force_try` lint exemption. Direction abbreviations are now matched
longest-first from a deterministic order, so `ALQDS` and the two-letter
quadrants can no longer be shadowed by a shorter abbreviation they start with —
`Dictionary.keys` gave no ordering guarantee before.

Dates: XML timestamps parse with `Date.ISO8601FormatStyle`, the package's only
remaining `ISO8601DateFormatter`.

CI: adds a Swift 6.4 leg for each OS already in the build matrix.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EbZbx5D2gGeXT8UxuiKEdq
Enable SE-0458 `.strictMemorySafety()` alongside the package's upcoming-feature
flags and audit every diagnostic it raises.

All 44 diagnostics came from two constructs, both acknowledged in place with the
`unsafe` expression marker rather than rewritten:

- `String(format:)`, 42 diagnostics over 43 call sites — variadic `CVarArg`
  formatting. Every call passes a literal format string whose specifiers match
  the arguments given.
- `XMLParser.delegate` assignment, 2 diagnostics — the property is
  `unowned(unsafe)`; the delegate is held strongly by the enclosing frame for the
  whole parse and read again after it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EbZbx5D2gGeXT8UxuiKEdq
@RISCfuture
RISCfuture force-pushed the swift-6.4/modernization branch from 0569ae1 to 3606455 Compare September 15, 2026 03:10
@RISCfuture
RISCfuture merged commit dbc7a9d into main Sep 15, 2026
9 of 10 checks passed
@RISCfuture
RISCfuture deleted the swift-6.4/modernization branch September 15, 2026 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant