mirror of
https://github.com/navanchauhan/swift-chess-neo.git
synced 2026-04-02 23:58:46 -06:00
Address Swift 6 concurrency-safety warnings #8
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @navanchauhan on 9/15/2025
Summary
Swift 6 stricter concurrency checks now flag all of our precomputed tables and cached values in
SwiftChessCore, so the engine emits dozens of#MutableGlobalVariablewarnings duringswift build. We need to harden the module for Swift 6 compatibility.Affected Diagnostics
Sources/SwiftChessCore/Tables.swift(_whitePawnAttackTable,_blackPawnAttackTable,_kingAttackTable,_knightAttackTable,_whiteBishopAttackTable,_blackBishopAttackTable,_whiteRookAttackTable,_blackRookAttackTable,_whiteQueenAttackTable,_blackQueenAttackTable,_whiteKingRayTable,_blackKingRayTable,_lineTable).Square.allinSources/SwiftChessCore/Square.swift:226._standard/_upsideDowninSources/SwiftChessCore/Variant.swift.Bitboardand other supporting types lackSendable.Goals
Proposed Plan
Bitboard,Variant, etc.).Sendableor@unchecked Sendableconformances where the representation is value-typed (e.g.Bitboard,Square,Variant).letinto a dedicatedstruct Tablesnamespace asstatic let.@usableFromInline static letcomputed via@Sendableclosures.@MainActorif we cannot make the stored typeSendable.Square.allinto a computed property or lazily initializedstatic letwithin aSendableextension.Squareenums conform toSendableto satisfy compiler checks._standard/_upsideDownwith computed properties orstatic letinside aSendablecontainer.@MainActoronly if true thread-safety cannot be proven.swift buildandswift testunder Swift 5.9 and Swift 6 toolchains (on macOS and Linux CI) to ensure no regressions.--swift-version 6to keep the warnings from reappearing.Acceptance Criteria
swift buildwith--swift-version 6completes without concurrency warnings.