Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libraries/System.Linq/src/System/Linq/Range.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private sealed partial class RangeIterator<T> : Iterator<T> where T : INumber<T>

public RangeIterator(T start, T endExclusive)
{
Debug.Assert(int.CreateChecked(endExclusive - start) >= 0);
Debug.Assert(endExclusive - start >= T.Zero);
_start = start;
_endExclusive = endExclusive;
}
Expand Down
7 changes: 7 additions & 0 deletions src/libraries/System.Linq/tests/SequenceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ public void SmallIntegers_ProducesFullRange()
}
}

[Fact]
public void LargeSequence_TryUseRange()
{
var sequence = Enumerable.Sequence(0L, 2L + int.MaxValue, 1L);
Assert.Equal(0L, sequence.First());
}

private sealed class ReferenceAddable(int value) : INumber<ReferenceAddable>
{
public static ReferenceAddable One => throw new NotImplementedException();
Expand Down
Loading