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
len() family returns isize (pointer-width, signed): Sema sizes isize/usize per target (32 on wasm32); lib/std and rt flip the declarations #2262
Ruling (Eric, 2026-10-07): len(), count() and position() return isize, the signed pointer-width integer; usize/isize are pointer-width, 32 bits on wasm32. D11 ruled signedness only; the width was unruled and the C-interop argument decided it: a len() meeting a size_t is a sign change on every target and nothing more. The spec lands first; the compiler is NON-COMPLIANT until this is done.
Implementation:
Sema: ty_isize/ty_usize are registered at 64 bits regardless of target (src/Sema.w:3899-3901, "64-bit on arm64"); TypeLayout already sizes them by target_spec_ptr_bytes. Sema's width must follow the target (32 on wasm32) so widening and narrowing rules (§4.2.6) are right there: today let c: isize = b with b: i64 is accepted implicitly, which on wasm32 is a silent narrowing.
lib/std and rt: the six fn len() -> i64 declarations and the iterator count()/position() family return isize; len64() stays an alias of len() widened.
Separate mechanical sweep, not this issue: the 5223 .len() as i32 sites across src, build, lib/std and tools are legacy cast ceremony (a loop over 0..v.len() indexes directly).
Follow-on: #2261 (length param N facade clause for the sign change at the C boundary).
Items 1–3 are on main through #2327 (verified 2026-10-11 by running the compiler: Sema sizes isize by target_spec_size_bytes, wasm32 refuses the i64 → isize narrowing, every std len() is -> isize, count/position too). Item 4, the mechanical sweep, is PR #2346 on stack #2347: 5339 sites stripped, 803 casts remain at genuine i32 demands, gate green. The wasm32 proof stays with #2131.
Close-out verified 2026-10-13 on the installed compiler (main 5c31bf1): Sema registers isize/usize at the target's pointer width (src/Sema.w:4093-4094, size_bits) — the issue's own example now behaves: let c: isize = b with b: i64 under --target wasm32-wasi errors 'implicit integer narrowing or sign change from i64 to isize (§4.2.6)' instead of silently narrowing. lib/std's len() declarations return isize and no fn len() -> i64 remains in lib/ or rt/. What is left is the wasm32 width proof itself, tracked by #2131; the .len() as i32 sweep was always separate (item 4).
Activity
D108: length is pointer-width — len(), count() and position() return …
ehartford commentedon Oct 7, 2026
Spec landed: PR #2263 (D108, spec v7.28). This issue is the implementation.
ehartford commentedon Oct 11, 2026
Items 1–3 are on main through #2327 (verified 2026-10-11 by running the compiler: Sema sizes isize by target_spec_size_bytes, wasm32 refuses the i64 → isize narrowing, every std len() is -> isize, count/position too). Item 4, the mechanical sweep, is PR #2346 on stack #2347: 5339 sites stripped, 803 casts remain at genuine i32 demands, gate green. The wasm32 proof stays with #2131.
D108/D114 sweep (#2262 item 4): a `.len()` is an isize; the cast move…
ehartford commentedon Oct 13, 2026
Close-out verified 2026-10-13 on the installed compiler (main 5c31bf1): Sema registers isize/usize at the target's pointer width (src/Sema.w:4093-4094, size_bits) — the issue's own example now behaves:
let c: isize = bwithb: i64under--target wasm32-wasierrors 'implicit integer narrowing or sign change from i64 to isize (§4.2.6)' instead of silently narrowing. lib/std's len() declarations return isize and nofn len() -> i64remains in lib/ or rt/. What is left is the wasm32 width proof itself, tracked by #2131; the .len() as i32 sweep was always separate (item 4).Spec changelog: the NON-COMPLIANT sentences of fourteen entries whose…