• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

moonbitlang / core / 4052 / 1
94%
main: 94%

Build:
DEFAULT BRANCH: main
Ran 28 Apr 2026 02:11AM UTC
Files 364
Run time 8s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

28 Apr 2026 02:10AM UTC coverage: 94.775% (-0.05%) from 94.822%
4052.1

push

github

web-flow
feat(range): add @range package with @range.iter generic constructor (#3492)

* feat(range): add @range package with generic range function

New focused package providing a single public generic `range` over a
small `Step` trait. Additive — does not deprecate or alter the existing
per-type `Int::until` / `Int64::until` / `Double::until` / `Float::until`
methods.

API surface:

    pub(all) enum Direction { Backward, Still, Forward } derive(Eq)

    pub(open) trait Step : Add + Compare {
      direction(Self) -> Direction
    }

    pub fn[T : Step] range(start, end, step, inclusive? : Bool = false)

Built-in `Step` impls cover Int, Int64, UInt, UInt64, Float, Double,
and BigInt. User types can opt in by implementing `Step`.

Design notes:
- `step` is required (no default) — keeps the trait usable for types
  without a natural unit step.
- Zero step aborts (programmer error), unlike legacy `::until` which
  silently returned an empty iterator.
- `Direction` is a public enum, not a sign-as-Int convention, so
  implementers can't lie about it.
- The progress guard uses strict comparison (`next > i` / `next < i`)
  so Float/Double sub-precision steps terminate instead of looping.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(range): handle NaN, broaden test coverage

Address the code-review findings on PR #3492:

1. Drop the `abort` on `Still` direction. Zero-step or NaN-step now
   yields the empty iterator (or `[start]` when `inclusive=true` and
   `start == end`), matching the existing `Float::until` semantics for
   NaN steps and avoiding a behavior split between the per-type
   methods and the new generic.

2. Use `i == end` (Eq) instead of `i.compare(end) == 0` for the
   inclusive boundary check. MoonBit's `Double::compare(NaN, x)`
   returns 0 (not unordered), so the previous form would treat any
   `NaN` end as equal under `inclusive=true` and could keep yielding
   forward indefinitely. `==` correctly returns false... (continued)

14855 of 15674 relevant lines covered (94.77%)

218926.67 hits per line

Source Files on job 4052.1
  • Tree
  • List 364
  • Changed 1
  • Source Changed 0
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 4052
  • 98394429 on github
  • Prev Job for on main (#4045.1)
  • Next Job for on main (#4055.1)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc