Typed throws, cached regexes, ISO8601FormatStyle, Swift 6.4 CI - #23
Merged
Merged
Conversation
RISCfuture
force-pushed
the
swift-6.4/modernization
branch
2 times, most recently
from
September 14, 2026 23:08
3309e6f to
62962c4
Compare
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
force-pushed
the
swift-6.4/modernization
branch
from
September 15, 2026 03:10
0569ae1 to
3606455
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NSRegularExpression;rxis now built with RegexBuilder fromallCasesand cached. A second run-time-string-builtRegex(joined fromDictionary.keys, which has no guaranteed order) is also replaced — that one was a latent nondeterminism bug.ISO8601DateFormatter→ cachedDate.ISO8601FormatStyle, the last holdout in a package already using FormatStyle in 184 places..strictMemorySafety()was trialled and removed — it produced ~40 warnings.LockedRegexandRegex+Sendableare untouched:Regexis still not Sendable in 6.4.🤖 Generated with Claude Code
https://claude.ai/code/session_01EbZbx5D2gGeXT8UxuiKEdq