1966 Commits
Author SHA1 Message Date
Karoy Lorentey a66de878e8 Merge pull request #731 from lorentey/release-prep
Finalize the 1.7.0 release
1.7.0
2026-09-22 19:44:20 -07:00
Karoy Lorentey 3cd6ca91d5 Drop bad Iterable tests 2026-09-22 19:19:20 -07:00
Karoy Lorentey e2c040bcaa BorrowingIteratorProtocol.map: Hide map2 and map3 behind underscores
`map2` and `map3` are merely illustrating problems with the throwing Iterable in higher-order functions in Swift 6.4; they aren’t really suitable for exposing as API, even behind a package trait.
2026-09-22 19:04:12 -07:00
Karoy Lorentey 2dcded505e Stop shipping retroactive Iterable conformances on standard types 2026-09-22 19:04:09 -07:00
Karoy Lorentey 021a54b8cc Update docs 2026-09-22 18:56:47 -07:00
Karoy Lorentey 9bf8a9763b Merge pull request #729 from lorentey/release-prep
1.7.0 release preparations
2026-09-22 12:42:05 -07:00
Karoy Lorentey 4e0c3576d5 Merge pull request #730 from Joseph-Cursio/check-set-algebra-twins
Check the mutating form* twins against their non-mutating originals
2026-09-22 11:28:31 -07:00
Karoy Lorentey edcbded708 Fix workflow spec 2026-09-22 11:15:48 -07:00
Karoy Lorentey 12dab234df Fix container validation on some 6.4 nightlies
6.4 branches don’t like the `throws(Never)` declarations that have slipped into the container validator. Get rid of them.
2026-09-22 11:15:46 -07:00
Joseph CursioandClaude Opus 5 de23cb86c8 Check the mutating form* twins against their non-mutating originals
formUnion against union, formIntersection against intersection,
subtract against subtracting, and formSymmetricDifference against
symmetricDifference, in both the Self-taking and Sequence-taking
overloads.

Each runs under withHiddenCopies at both sharing states, because a
mutating operation on a shared value is where copy-on-write bugs
live, and the original is checked afterwards to confirm it was not
mutated through the copy.

This is the highest-value law in the checker. The two implementations
should agree by construction, so a divergence is a real bug rather
than a debatable one — and nothing else here would catch a form*
method that is simply wrong: a formUnion that intersects passes every
law in the preceding commit.

Verified by injecting three defects into a stand-in conformance: a
formUnion that intersects, an isStrictSubset that drops strictness,
and a subtracting that returns a stale count. All three are caught,
and an unmodified control passes. The stale-count case is caught only
because contents and count are asserted separately.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-21 21:14:59 -05:00
Karoy Lorentey 8104faa3af Fix errors uncovered by new workflow configuration 2026-09-21 14:10:43 -07:00
Karoy Lorentey 0685a69944 Update workflows
- Stop testing Swift 6.0 and 6.1
- Run full unstable package trait test on 6.3 and nightly-6.4.x
- Use preconfigured install-cmake action that verifies SHA256 hash of downloaded tarball
2026-09-21 14:10:21 -07:00
Karoy Lorentey 79f41229ef Merge pull request #728 from lorentey/container-updates
`Producer.generate(into:)`: Switch to saturating semantics
2026-09-21 13:35:19 -07:00
Karoy Lorentey 9eb1e96d79 Add rudimentary swift-format configuration 2026-09-21 13:34:42 -07:00
Karoy Lorentey 537bf9cbfb Drop support for Swift 6.0 and 6.1
This allows the use of Span types without `#if compiler` guards.
2026-09-21 13:34:39 -07:00
Karoy Lorentey 78bb4bf6b9 Update README 2026-09-21 13:33:58 -07:00
Karoy Lorentey 5d0faff6c7 Update container design document 2026-09-21 13:07:04 -07:00
Karoy Lorentey 8e4f078441 Producer.generate(into:): Switch to saturating semantics
This noticeable simplifies client code, as clients invariably want to fully populate their buffer (when possible). It also is consistent with the semantics of `Iterable.skip(by:)`.
2026-09-21 13:07:01 -07:00
Karoy Lorentey c38a7173fc Merge pull request #720 from Joseph-Cursio/container-conformance-deques
Validate the Container conformance of RigidDeque and UniqueDeque
2026-09-21 12:54:59 -07:00
Karoy Lorentey a70b97e2bf Merge pull request #721 from hxperl/docc-parameter-name-backticks
Unbacktick parameter names so DocC binds the parameter docs
2026-09-21 12:54:44 -07:00
Karoy Lorentey c0c95f05a8 Merge pull request #722 from Joseph-Cursio/deque-allocation-tests
[DequeModule] Add tests for Deque's storage allocation behavior
2026-09-21 12:54:30 -07:00
Karoy Lorentey 45e7f63387 Merge pull request #725 from eliorpom-cmd/fix-typos-20260918
Fix typos in documentation and comments
2026-09-21 12:54:16 -07:00
Karoy Lorentey f959678e28 Merge pull request #719 from Joseph-Cursio/check-set-algebra
Add checkSetAlgebra, a law checker for set-like types
2026-09-21 11:02:44 -07:00
Karoy Lorentey 561d10ed84 Merge pull request #727 from lorentey/container-updates
Container: Reinstate requirement for Comparable indices
2026-09-21 11:01:37 -07:00
Karoy Lorentey b2424210b4 Container: Reinstate requirement for Comparable indices
I have a linked list prototype that can support comparable indices (and an O(1) `count`); accordingly, reinstate the requirement for index comparability. This eliminates a potential performance footgun for custom containers that define their own Index, as an incomparable index would make `func distance` 2x slower.
2026-09-21 10:41:46 -07:00
Karoy Lorentey f5db7175b3 Merge pull request #724 from lorentey/container-updates
MutableContainer: Add some bulk update operations
2026-09-21 10:10:34 -07:00
Karoy Lorentey d392f0cbff MutableContainer: Add tests; resolve issues uncovered 2026-09-21 09:54:29 -07:00
Elior Pommier cabf7390ce Fix typos in documentation and comments
Corrects 25 misspellings across DocC articles, design documentation and doc
comments. Prose only: no identifiers, no public API, no behaviour change.

| Typo | Correction | Count |
|---|---|---|
| `offseting` | `offsetting` | 7 |
| `valud` | `value` | 4 |
| `necessarilly` | `necessarily` | 3 |
| `recommmend` | `recommend` | 2 |
| `Mutablility` | `Mutability` | 1 |
| `childs` | `child's` | 1 |
| `constaints` | `constraints` | 1 |
| `destintion` | `destination` | 1 |
| `explan` | `explain` | 1 |
| `forcuses` | `focuses` | 1 |
| `ot` | `or` | 1 |
| `succcess` | `success` | 1 |
| `unqiue` | `unique` | 1 |

Two of these are worth a second look, since they are not pure spelling:

- `_HTable+Removal.swift:18` reads "without marking it as unoccupied ot
  restoring the hash table's other invariants". Read as `or`, matching the
  sentence, and deliberately not as a prefix of `other` later on the line.
- `_Node.UnsafeHandle+Deletion.swift:369` reads "reuse the left childs node".
  Corrected to the possessive `child's` rather than `children`, which is what
  a plain spellchecker suggests but does not fit the sentence.

`valud` is corrected to `value` to match the wording of the equivalent
parameter documentation on `swapAt(_:_:)`.

One change is outside documentation: `CheckContainer.swift:476` fixes
`succcess` inside a test assertion message. It is a human-readable string, not
an expected value, so no test behaviour changes.

Deliberately left alone:

- `isDisjoint(with:)-54iy6` in `OrderedSet.md` is a DocC disambiguation hash,
  not a misspelling.
- `Peristent` in the 2022 ShareableHashedCollections review document, which is
  an archived record of a past review rather than living documentation.

Found with `typos-cli`, then reviewed by hand; the tool's raw output also
flagged identifiers and symbol hashes, which are not included here.
2026-09-18 14:31:47 +02:00
Karoy Lorentey 4ea0e4443d MutableContainer: Also add copying variants of bulk updates 2026-09-16 20:44:13 -07:00
Karoy Lorentey c031de73d0 MutableContainer: Add some bulk update operations 2026-09-16 19:58:28 -07:00
Karoy Lorentey 3ceaf1ac39 Merge pull request #723 from lorentey/container-updates
Refactor DrainableContainer/RangeReplaceableContainer/DynamicContainer
2026-09-16 13:40:56 -07:00
Karoy Lorentey 5cebba6f29 Refactor DrainableContainer/RangeReplaceableContainer/DynamicContainer
Range replacement operations generally need to invalidate all indices, and that means that we lose our position in the container after each insertion/removal, unless we happen to be using a container with looser index invalidation (such as arrays or deques).

A linked list is an example for a container type where insertions/removals need to invalidate all indices — as we need to track index validation using a single version counter that is stored in the list’s head. However, it would not be acceptable to lose our place whenever we insert a new item to the list; therefore, to mitigate the validation issue, this commit changes all range-replacement operations to return a valid index range to the affected items in the container.

This is a radical break from `RangeReplaceableCollection`. It fixes a long-standing defect with it, but it also makes it tricky to conform the same type to both protocol families, as the two require the “same” methods to return different types (`Void` vs `Range<Index>`).

Given that the LSG has intentionally diverged `UniqueArray.removeAll()` from RangeReplaceableCollection semantics, I expect this isn’t going to be an issue. For example, types with existing collection conformances can expose container views, mitigating such semantic differences.

To allow SubrangeConsumers to work without losing position, add a new protocol, `ContainerDrain` with a consuming `finalize` operation that returns a valid index in the resulting container state.

While we’re here, apply the API tweaks from SE-0527:
- Revert the `replace(removing:…:)` names, rolling back to `replaceSubrange(_:…:)` .
- Similarly, rename `consume(_:)` → `consumeSubrange(_:)`
- Rename `reallocate(capacity:)` → `setCapacity(_:)`.
2026-09-14 20:37:12 -07:00
Joseph D CursioandClaude Opus 5 fe2b083fae [DequeModule] Add tests for Deque's storage allocation behavior
#113 switched `append(contentsOf:)` to exponential capacity reservation
without adding tests. This covers Deque's allocation behavior:

- Implement the empty `test_reserveCapacity` stub: reservations grow
  storage linearly to exactly the requested capacity, never shrink it,
  and leave sufficiently large unique storage in place.
- Initializers with a known element count allocate exactly that much.
- Single-element insertions follow the same capacity sequence as
  `UniqueDeque`.
- Repeated bulk insertions (append/prepend/insert/replaceSubrange, from
  contiguous arrays, collections and sequences) grow storage by a
  constant factor rather than reallocating on each call.
- Reserved capacity is used without reallocating.
- Inserting into shared storage keeps capacity when there is room and
  otherwise grows it by the same factor, leaving the original untouched.

Resolves #129.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016NTKVRe3aXMteHVrhbrTYE
2026-09-13 13:55:10 -05:00
hxperl 80216ab026 Unbacktick parameter names so DocC binds the parameter docs
Six `- Parameter` entries in `Deque` and `BitSet` write the parameter
name inside backticks (``- Parameter `i`:``). DocC binds parameter
documentation by bare identifier, so these never attach: no Parameters
section is rendered at all, and the entry instead falls into the
Discussion as a literal "Parameter `i`: ..." bullet, which also swallows
the `- Complexity:` callout that follows it.

Dropping the backticks around the name restores the Parameters section on
all six pages. Backticks inside the description text are left alone.
2026-09-11 14:07:13 +09:00
Joseph CursioandClaude Opus 5 bd9e63899a Validate the Container conformance of RigidDeque and UniqueDeque
Six types conform to Container and four of them call checkContainer
from their tests. RigidDeque and UniqueDeque are the two that do not,
so neither deque's conformance is validated by anything: both have
substantial test files, but everything in them is written by hand and
none of it routes through the checker.

Each new test enumerates every ring buffer layout of capacities 0, 1,
2, 3, 5 and 10 with withEveryDeque(_:ofCapacities:), which is the
space DequeTests.test_CollectionConformance already walks for
checkBidirectionalCollection. For a deque the internal layout is the
state that matters -- the wrapped arrangements are where index
arithmetic and the nextSpan chunking in checkContainer can disagree --
so enumerating it is worth more here than the flat layouts the array
call sites pass.

Both tests sit behind the same #if compiler(>=6.4) &&
UnstableContainersPreview gate as the existing call sites, and check
the tracked instance count alongside the conformance so a checker that
copied elements while borrowing them would be caught too.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-10 15:09:51 -05:00
Joseph CursioandClaude Opus 5 c99e944570 Add checkSetAlgebra, a law checker for set-like types
SetAPIChecker verifies that a set-like type has the right shape: it is
a protocol with no assertions, so conforming makes the compiler check
that the API surface exists. This adds the other half — that the
operations behave as documented.

Constrained on SetAPIChecker rather than SetAlgebra, because
OrderedSet deliberately does not conform to SetAlgebra (only its
UnorderedView does, for documented reasons about order-sensitive
equality). Constraining on the stdlib protocol would exclude the type
that needs this most.

Follows the house pattern of validating the specification before the
implementation. A Set<Element> model is only as sound as Element's
Hashable conformance, so _checkSetAlgebraModels runs _checkHashable
over the model elements and verifies each model survives a round trip
through Array before any instance is judged; it returns false and the
caller stops rather than reporting defects in the wrong artefact. A
broken model and a broken implementation can agree with each other,
which fails quietly in a way a wrong implementation does not.

Per-instance: contents and count against the model, isEmpty against
count independently of it, the empty set's identity and absorption
cases, the reflexive containment predicates, and filter at both
extremes and in between.

Per-pair: the four operations against the model and again through the
Sequence-taking overloads, which are separate entry points and can
diverge from the Self-taking ones; commutativity, both absorption
laws, and symmetricDifference against its definition in terms of the
other three; and the containment predicates against the model and
against each other. A type can implement each predicate plausibly and
still have them disagree.

Contents and count are asserted separately throughout: a type that
maintains a stored count can return the right elements alongside a
stale one.

Call sites for BitSet, OrderedSet and TreeSet.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-09 10:45:24 -05:00
Karoy Lorentey 774d6ba631 Merge pull request #718 from dylanpulver/bitset-isequalset-empty-range
[BitSet] Fix isEqualSet(to: Range<Int>) for empty ranges
2026-09-04 10:48:55 -07:00
Karoy Lorentey 396fee354f Merge pull request #717 from Azoy/rigiddictionary-layout-update
[RigidDictionary] Store a sentinel value for values ptr if null
2026-09-02 17:12:29 -07:00
Karoy Lorentey e738b9b5d7 Merge pull request #716 from lorentey/resinstate-exported-imports
Reinstate exported imports in Collections module
2026-09-02 17:09:12 -07:00
Dylan Pulver 85342a6a49 [BitSet] isEqualSet(to: Range<Int>) is wrong for an empty range
`_toUInt()` returns nil whenever a bound is negative, and the guard maps that
straight to `false`. That is right for a nonempty range -- a bit set can never
hold a negative value -- but an empty range equals the empty set regardless of
where its bounds sit, so `BitSet().isEqualSet(to: -5 ..< -5)` answered false.

Five of the six `Range<Int>` predicates already handle this: isSubset and
isDisjoint clamp, isStrictSubset composes those two, and isSuperset and
isStrictSuperset test `other.isEmpty` before converting. isEqualSet was the
one that did not, which let a bit set be both a subset and a superset of a
range while reporting that it was not equal to it.
2026-09-03 02:59:42 +03:00
Alejandro Alonso b2110d3563 Use single module conditional 2026-09-02 14:52:44 -07:00
Alejandro Alonso e773108091 Make RigidDictionary store a sentinel value for values ptr if null 2026-09-02 14:25:00 -07:00
Karoy Lorentey 08bbdd3def Reinstate exported imports in Collections module 2026-09-01 13:46:05 -07:00
Karoy Lorentey 26f299bd49 Merge pull request #715 from lorentey/no-dynamic-conformance-checks-in-embedded
Disable `_UniqueCollection` fast paths in embedded Swift
2026-09-01 10:50:17 -07:00
Karoy Lorentey 920d46bc42 Merge pull request #713 from lorentey/container-updates
Conform RigidSet/UniqueSet to Container and add Container validator
2026-09-01 10:34:58 -07:00
Karoy Lorentey e611f62e67 Disable _UniqueCollection fast paths in embedded Swift
As of 2026-09-01, conformance checks are now diagnosed as errors:

```
 70 |     // Fast paths for when we know elements are all unique
 71 |     if elements is _UniqueCollection {
    |                 `- error: cannot perform a dynamic cast to a type involving protocol '_UniqueCollection' in Embedded Swift
```
2026-09-01 10:31:54 -07:00
Karoy Lorentey 786e4e3546 Merge pull request #711 from apple/dependabot/github_actions/swiftlang/github-workflows/dot-github/workflows/soundness.yml-0.0.15
Bump swiftlang/github-workflows/.github/workflows/soundness.yml from 0.0.14 to 0.0.15
2026-09-01 10:28:47 -07:00
Karoy Lorentey 9fc7c65667 Merge pull request #712 from apple/dependabot/github_actions/swiftlang/github-workflows/dot-github/workflows/swift_package_test.yml-0.0.15
Bump swiftlang/github-workflows/.github/workflows/swift_package_test.yml from 0.0.14 to 0.0.15
2026-09-01 10:28:21 -07:00
Karoy Lorentey 1f94ac8f54 Implement (partial) Container validation 2026-09-01 10:14:42 -07:00
Karoy Lorentey 225bd07e56 RigidSet, UniqueSet: Add Container conformance 2026-09-01 09:34:05 -07:00