You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 8edc13f
Browse filesBrowse the repository at this point in the historyBrowse files
fixup! feat: HashSet and ISet modules with the vocabulary of the FSharp.Core Set module
Every `seq<'T>` parameter rejects `null` and a default flat list that is given as a sequence
with an `ArgumentNullException` that names the parameter of our function (ADR 0001, D6). A
default flat list is a boxed, non-null struct, so the check for `null` alone let it reach the
BCL call, which failed with `InvalidOperationException` when it enumerated the sequence.
- `HashSet.ofSeq` and the member `ofSeq` of `CustomComparerHashSet` (`elements`), `addRange`
and `removeRange` of `HashSet` and `ISet` (`elements`), and `intersectMany` and `unionMany`
of `HashSet` and `ISet` (`sets`) call `checkNotNullOrDefaultSeq` first. The check of each set
of `sets` stays. `ofList` and `ofArray` take another type and keep their check for `null`.
- The `yield!` overloads of `hashSet { }` for a sequence, an array and a hash set (`items`) and
its `for` (`source`) check their input before the buffer is returned. A `null` array or hash
set reached `UnionWith`, so the exception named `other`, and a `null` source made `for` throw
`NullReferenceException`.
- The exception documentation of the affected functions says "null or a default flat list", as
the documentation of `FlatList` does.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: src/FSharp.Collections.Immutable/HashSet/HashSet.CustomComparer.fsi
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -102,7 +102,7 @@ type CustomComparerHashSet<'T> =
102
102
/// The hash set of the elements that are distinct in the comparer; of the elements that the comparer considers equal,
103
103
/// it holds the first one.
104
104
/// </returns>
105
-
/// <exceptioncref="T:System.ArgumentNullException">Thrown when <paramrefname="elements"/> is <seelangword="null"/>.</exception>
105
+
/// <exceptioncref="T:System.ArgumentNullException">Thrown when <paramrefname="elements"/> is <seelangword="null"/> or a default flat list.</exception>
/// <returns>The hash set of the distinct elements of the sequence.</returns>
126
-
/// <exceptioncref="T:System.ArgumentNullException">Thrown when <paramrefname="elements"/> is <seelangword="null"/>.</exception>
126
+
/// <exceptioncref="T:System.ArgumentNullException">Thrown when <paramrefname="elements"/> is <seelangword="null"/> or a default flat list.</exception>
127
127
/// <remarks>
128
128
/// O(n log n), or O(1) for a hash set that compares with the default comparer: the function returns such a hash set
129
129
/// without a copy, and gives a hash set with another comparer the default one. The function wraps
@@ -438,7 +438,7 @@ val add : value : 'T -> set : HashSet<'T> -> HashSet<'T>
438
438
/// A hash set of the elements and the elements of the sequence, with the comparer of the input; the input itself when the
439
439
/// sequence adds no element.
440
440
/// </returns>
441
-
/// <exceptioncref="T:System.ArgumentNullException">Thrown when <paramrefname="elements"/> or <paramrefname="set"/> is <seelangword="null"/>.</exception>
441
+
/// <exceptioncref="T:System.ArgumentNullException">Thrown when <paramrefname="elements"/> is <seelangword="null"/> or a default flat list, or <paramrefname="set"/> is <seelangword="null"/>.</exception>
442
442
/// <remarks>
443
443
/// <para>
444
444
/// O(m log (n + m)), where n and m are the numbers of elements of the hash set and the sequence. The function wraps
/// <returns>The intersection, with the comparer of the first hash set.</returns>
529
-
/// <exceptioncref="T:System.ArgumentNullException">Thrown when <paramrefname="sets"/> or one of its hash sets is <seelangword="null"/>.</exception>
529
+
/// <exceptioncref="T:System.ArgumentNullException">Thrown when <paramrefname="sets"/> is <seelangword="null"/> or a default flat list, or one of its hash sets is <seelangword="null"/>.</exception>
530
530
/// <exceptioncref="T:System.ArgumentException">Thrown when the sequence is empty.</exception>
531
531
/// <remarks>
532
532
/// O(N log n), where N is the total number of elements of the other hash sets and n the number of elements of the first
@@ -573,7 +573,7 @@ val remove : value : 'T -> set : HashSet<'T> -> HashSet<'T>
573
573
/// A hash set of the other elements, with the comparer of the input; the input itself when it has no element equal to an
574
574
/// element of the sequence.
575
575
/// </returns>
576
-
/// <exceptioncref="T:System.ArgumentNullException">Thrown when <paramrefname="elements"/> or <paramrefname="set"/> is <seelangword="null"/>.</exception>
576
+
/// <exceptioncref="T:System.ArgumentNullException">Thrown when <paramrefname="elements"/> is <seelangword="null"/> or a default flat list, or <paramrefname="set"/> is <seelangword="null"/>.</exception>
577
577
/// <remarks>
578
578
/// O(m log n), where n and m are the numbers of elements of the hash set and the sequence. The function wraps
@@ -620,7 +620,7 @@ val union : set1 : HashSet<'T> -> set2 : HashSet<'T> -> HashSet<'T>
620
620
/// The union, with the comparer of the first hash set; the empty hash set with the default comparer for an empty
621
621
/// sequence.
622
622
/// </returns>
623
-
/// <exceptioncref="T:System.ArgumentNullException">Thrown when <paramrefname="sets"/> or one of its hash sets is <seelangword="null"/>.</exception>
623
+
/// <exceptioncref="T:System.ArgumentNullException">Thrown when <paramrefname="sets"/> is <seelangword="null"/> or a default flat list, or one of its hash sets is <seelangword="null"/>.</exception>
624
624
/// <remarks>
625
625
/// O(N log N), where N is the total number of elements of the hash sets. The function unites the hash sets from the first
Copy file name to clipboardExpand all lines: src/FSharp.Collections.Immutable/HashSet/ISet.fsi
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -260,7 +260,7 @@ val add : value : 'T -> set : IImmutableSet<'T> -> IImmutableSet<'T>
260
260
/// A set of the elements and the elements of the sequence, with the implementation and the comparer of the input; the
261
261
/// input itself when the sequence adds no element.
262
262
/// </returns>
263
-
/// <exceptioncref="T:System.ArgumentNullException">Thrown when <paramrefname="elements"/> or <paramrefname="set"/> is <seelangword="null"/>.</exception>
263
+
/// <exceptioncref="T:System.ArgumentNullException">Thrown when <paramrefname="elements"/> is <seelangword="null"/> or a default flat list, or <paramrefname="set"/> is <seelangword="null"/>.</exception>
264
264
/// <remarks>
265
265
/// <para>
266
266
/// The complexity depends on the implementation of the set: O(m log (n + m)) for an
/// <returns>The intersection, with the implementation and the comparer of the first set.</returns>
363
-
/// <exceptioncref="T:System.ArgumentNullException">Thrown when <paramrefname="sets"/> or one of its sets is <seelangword="null"/>.</exception>
363
+
/// <exceptioncref="T:System.ArgumentNullException">Thrown when <paramrefname="sets"/> is <seelangword="null"/> or a default flat list, or one of its sets is <seelangword="null"/>.</exception>
364
364
/// <exceptioncref="T:System.ArgumentException">Thrown when the sequence is empty.</exception>
365
365
/// <remarks>
366
366
/// The complexity depends on the implementation of the first set: O(N log n) for an
@@ -406,7 +406,7 @@ val remove : value : 'T -> set : IImmutableSet<'T> -> IImmutableSet<'T>
406
406
/// A set of the other elements, with the implementation and the comparer of the input; the input itself when it has no
407
407
/// element equal to an element of the sequence.
408
408
/// </returns>
409
-
/// <exceptioncref="T:System.ArgumentNullException">Thrown when <paramrefname="elements"/> or <paramrefname="set"/> is <seelangword="null"/>.</exception>
409
+
/// <exceptioncref="T:System.ArgumentNullException">Thrown when <paramrefname="elements"/> is <seelangword="null"/> or a default flat list, or <paramrefname="set"/> is <seelangword="null"/>.</exception>
410
410
/// <remarks>
411
411
/// <para>
412
412
/// The complexity depends on the implementation of the set: O(m log n) for an
@@ -465,7 +465,7 @@ val union : set1 : IImmutableSet<'T> -> set2 : IImmutableSet<'T> -> IImmutableSe
465
465
/// <seecref="T:FSharp.Collections.Immutable.HashSet`1"/>, which compares with
/// <exceptioncref="T:System.ArgumentNullException">Thrown when <paramrefname="sets"/> or one of its sets is <seelangword="null"/>.</exception>
468
+
/// <exceptioncref="T:System.ArgumentNullException">Thrown when <paramrefname="sets"/> is <seelangword="null"/> or a default flat list, or one of its sets is <seelangword="null"/>.</exception>
469
469
/// <remarks>
470
470
/// The complexity depends on the implementation of the first set: O(N log N) for an
471
471
/// <seecref="T:System.Collections.Immutable.ImmutableHashSet`1"/>, where N is the total number of elements of the sets.
0 commit comments