Skip to content

Split(step) and Values(step) end early when n × step overflows (Int64, Decimal, Float64, Float32) #219

Closed

Description

@CaffeinatedCoder

Problem

Split(step) and Values(step) stop early, without an error, when n × step overflows while start + n × step would still fit. Each type's Steps lambda computes the n-th boundary as start + n * step. RangeSplitting.Steps catches the overflow and returns null, which SplitWalk/ValuesWalk read as "the domain has ended". Found by the pre-tag analysis (#179) on origin/main 3ce68d9.

  • Int64Range.CreateFinite(-9e18, 9e18).Values(4e18) → -9e18, -5e18, -1e18. It drops 3e18 and 7e18.
  • .Split(4e18) returns a last piece [-1e18,9e18], 10e18 wide for a 4e18 step.
  • The same happens for DecimalRange ([-7e28,7e28).Split(3e28)), Float64Range ([-1.7e308,1.7e308).Split(1e308)) and Float32Range ([-3.3e38,3.3e38).Split(2e38)).
  • Int32Range is safe because it computes n * step in long.

This breaks R39 ("Values(step) yields every k-th value") and the "pieces of the step length" contract. Every test passes with the defect present: Split_PiecesAreTheRange_AdjacentAndOneStepLong and R39's oracles never draw a negative start with a step near the domain's width.

Where: Int64Range.cs:234,252, DecimalRange.cs:205, Float64Range.cs:287, Float32Range.cs:287, Internals/RangeSplitting.

Change

Return null only when the boundary itself leaves the domain. For example, step from the previous boundary (previous + step, which is exact for integers and decimal) once n × step overflows, or compute in a wider type. For the floats, check that stepping from the previous boundary doesn't accumulate rounding error in a way that disagrees with start + n × step; if it does, pick one rule and document it.

Done when

  • Int64Range.CreateFinite(-9e18, 9e18).Values(4e18) is [-9e18, -5e18, -1e18, 3e18, 7e18].
  • The Split/Values oracle draws a row with start ≈ MinValue/2 and step ≈ MaxValue/2 for each type, and fails with the defect restored.

Activity

  1. added this to the 10.0.0 milestone on Oct 18, 2026
  2. added
    bug
    silent
    area/ranges
    package/core
    severity/medium
    on Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/rangesbugpackage/coreseverity/mediumsilent

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions