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
std.time: Duration is a bare i32 alias of milliseconds since 2026-03-02 with no ruling; it should be a value type over i64 nanoseconds (D114), with 50.millis() as the spec writes it #2957
Found while probing §14 (2026-11-02 conformance audit; #2955 item 1). pub type Duration = i32 ("a duration in milliseconds") was written in the 2026-03-02 architecture port and never revisited: no ruling, no decision-log entry, no spec sentence chooses its width or unit. The spec uses Duration only abstractly (Duration.seconds(30), timeout: Duration) and §14.6/§14.10 write sleep(50.millis()) and timeout(1.secs()), neither of which exists.
Why i32 ms is wrong
Range: overflows at ~24.9 days. D114: a value not bounded by memory takes a fixed, adequate width.
Precision: the runtime is nanoseconds (with_clock_nanos, with_fiber_sleep_until, now_ns); sleep multiplies by 1,000,000 and throws the resolution away. A 500 µs sleep cannot be written.
A bare alias is not a type: sleep(50) compiles, Duration + i32 is allowed, a duration mixes with a count. Under D111 a duration is a value (Copy, arithmetic), but it should be its own type so sleep(50) is a type error naming the unit.
Why not isize (asked by Eric 2026-11-02): isize is the width of memory (D114: size_t/ptrdiff_t), for lengths and positions. A duration is not bounded by memory and crosses into C (struct timespec) and into files, so it takes a fixed width on every target. On wasm32 an isize of nanoseconds overflows at 2.1 s and the same program would mean different things on two targets. Go (int64 ns on all platforms), Rust (u64 s + u32 ns) and Swift (128-bit) agree.
Proposal (for Eric's blessing): Duration is a value type over i64 nanoseconds: constructors nanos/micros/millis/secs/minutes/hours; integer extensions so 50.millis() reads as the spec writes it (needs the lexer to read 50.millis as a method call, not the float 50.; Swift and Kotlin do this); + - * / and comparison; as_secs_f64(), as_millis(); Instant.now() with elapsed(); sleep(Duration); timeout(Duration) -> Task[Unit] so §14.10's example exists. Spec: a §14/§18.6 sentence naming the unit and width.
D188 (delegated, spec v7.35, #2970): Duration is a value type over i64 nanoseconds with constructors, extensions, Instant and timeout; the lexer follows §30's FLOAT_LIT (digits after the dot). Implementation next.
Done in #2971 (D188): Duration is a value type over i64 nanoseconds with nanos/micros/millis/secs/minutes/hours constructors and integer extensions, Instant.now().elapsed(), sleep(Duration), timeout(Duration); the lexer follows §30's FLOAT_LIT so 50.millis() is a member access.
Activity
ehartford commentedon Nov 2, 2026
D188 (delegated, spec v7.35, #2970): Duration is a value type over i64 nanoseconds with constructors, extensions, Instant and timeout; the lexer follows §30's FLOAT_LIT (digits after the dot). Implementation next.
ehartford commentedon Nov 2, 2026
Done in #2971 (D188):
Durationis a value type over i64 nanoseconds with nanos/micros/millis/secs/minutes/hours constructors and integer extensions, Instant.now().elapsed(), sleep(Duration), timeout(Duration); the lexer follows §30's FLOAT_LIT so50.millis()is a member access.