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
The pinned seed predates D183: len() into an i32 parameter still needs as i32 in src/ (807 sites); goes with the next seed #3073
D183 made an isize narrow into an i32 demand with a range check, so f(xs.len()) for f(n: i32) needs no cast in a program the installed compiler builds. src/ is compiled by the pinned seed (seed.lock), which predates D183, so the gate refuses the castless spelling there:
error: implicit integer narrowing or sign change from `isize` to `i32` (argument 3 of `ensure_generic_inst_type`); use an explicit `as` cast (§4.2.6)
807 .len() as i32 sites in src/ carry the cast for the seed alone (the census counts them as len-cast). Two more were added in #3069 with a comment naming this.
Done when: a post-D183 seed is pinned (tools/bump_seed_pins.w, with build :seed), then a with fix-ceremony pass (#3061, the widening-cast pass extended to the narrowing-with-range-check case) removes every .len() as i32 whose target is an i32 demand, as one PR, and the len-cast census count falls by that many.
The first src/ sweep (fix-ceremony-5) ran with --check-with src/main, so the pinned seed gated every rewrite. 242 stayed as written because the seed predates the rule that admits them; they are this issue's work once a post-D197 seed is pinned, together with the 807 len() as i32:
kept as written
count
rule the seed lacks
.clone() on a str
165
D111 (a str is a value; the seed's move checker still sees a move)
Progress under the new seed (nightly-20261110-local-1): the 242 kept rewrites are applied in the seed-bound sweep PR (330 rewrites in 31 files, nothing kept as written, the seed checks the result).
The 807 len() as i32 are a different matter. The cast is not what the seed refused any more: dropping one is admitted by D183 and lowers to the range-checked conversion, but it also raises D183's lint, "isize narrows to i32 with a range check: widen the i32 declaration it flows into", at every site. That lint is deliberate (D183: it names the declaration whose width is wrong, never the use), so the right removal is the one it asks for: the i32 parameters and fields that receive a length or an index widen to isize (D108, D114), and the casts fall away with no lint. That is a declaration sweep over the compiler's own signatures, not a rewrite of the uses; it stays on this issue as the remaining work, and len-cast stays in the census at 819 until it lands.
The 242 seed-bound rewrites landed in #3082. What remains here is the 807 len() as i32, which is a declaration-widening sweep (the i32 parameters and fields that receive a length or index become isize), not a cast removal: see the comment above.
Shape of the declaration sweep, measured on a tree at the #3091 stack top with every .len() as i32 in src/ stripped (758 sites in 56 files; the census's 819 includes spaced spellings) and with check src/main.w under the installed post-D183 compiler:
990 D183 lints, 26 hard errors.
642 lints name a call target ((argument N of f)), across 230 distinct declarations; 348 name none (a let annotation, a field store, an index, a comparison). Top targets: comptime_value_list arg 3, add_type arg 3, pairs_list_i32 arg 1 (9 each), wl_struct_set_body arg 3 (8), add_sig arg 4, wl_function_type arg 3 (7), wl_struct_type arg 3 (6), then a long tail of 1–5.
The 26 errors are the uses that change type when the cast goes: HashMap.contains/Memo.contains/HashMap.get with an isize probe against an i32 key (no conversion on a probe) and if arms joining isize with i32 (§4.2.6 refuses the implicit join).
Two floors the sweep stops at, where the cast is a real narrowing and stays:
the C bridge (wl_*, clang_*): unsigned/int parameters are the ABI; D114 says a value crossing into C is fixed width;
values stored into an i32 table (type_extra, sema_type_d1, extra_values, the MIR arrays): the element type is a layout choice, and widening it doubles the compiler's largest tables.
Everything else — an i32 parameter or field that receives a length or index and is only compared, iterated or indexed with — widens to isize (D108, D114), and its casts fall away. The work is the classification of the 230 (plus the 348 no-note sites by their binding), one PR per area so a battery can bisect. Not started yet; the stripped tree is ~/.local/with-staging/i3073 (uncommitted).
The declaration sweep is done on branch i3073 (one commit, 39 files, 410 lines): gate running, battery next.
Method, so it can be rerun: strip every .len() as i32 in src/ (758), let D183's lint name the declaration each narrowing flows into, and iterate three tools to a fixpoint — widen a named i32 parameter to isize unless it is the C bridge or a table store (add_node, add_extra, add_type, add_sig, comptime_value_*, pack_*, new_rvalue); put the cast back at a value's binding when the lint's target is a store into an i32 list/map/array, a table-id return, or a C call; widen a var x: i32 or a field f: i32 the lint points at. Then revert any widened parameter whose body still lints (an id, not a position) and cast at its callers. Returns were the trap: widening 77 -> i32 returns cascaded to 1204 lints, because those are table ids by construction; returns stay i32.
Result: about a hundred parameters, six variables and seven fields widened; with check src/main.w clean (0 lints, 0 errors). The census's len-cast in src falls 784 → 617. What remains is the floor — a value stored into an AST/type/MIR/comptime table or crossing into C — where the cast is the narrowing it says it is. The issue's "done when" was "every .len() as i32 whose target is an i32 demand"; that set is exactly the floor, so the sweep closes this issue with the floor documented rather than cast-free.
Activity
ehartford commentedon Nov 8, 2026
The first
src/sweep (fix-ceremony-5) ran with--check-with src/main, so the pinned seed gated every rewrite. 242 stayed as written because the seed predates the rule that admits them; they are this issue's work once a post-D197 seed is pinned, together with the 807len() as i32:.clone()on a str(k as u32)at a shift count: strannotation restating the initializerSome(x)under an Option demandas u64wideningRecipe after the seed bump:
with fix-ceremony --apply --check-with src/main src/main.wagain; the tool reports whatever the new seed still refuses.fix-ceremony: facts proven on the compiler, --check-with, and the src…
seed.lock: nightly-20261110-local-1-d02ac04992f8 on the four gating p…
ehartford commentedon Nov 8, 2026
Progress under the new seed (nightly-20261110-local-1): the 242 kept rewrites are applied in the seed-bound sweep PR (330 rewrites in 31 files, nothing kept as written, the seed checks the result).
The 807
len() as i32are a different matter. The cast is not what the seed refused any more: dropping one is admitted by D183 and lowers to the range-checked conversion, but it also raises D183's lint, "isizenarrows toi32with a range check: widen thei32declaration it flows into", at every site. That lint is deliberate (D183: it names the declaration whose width is wrong, never the use), so the right removal is the one it asks for: thei32parameters and fields that receive a length or an index widen toisize(D108, D114), and the casts fall away with no lint. That is a declaration sweep over the compiler's own signatures, not a rewrite of the uses; it stays on this issue as the remaining work, andlen-caststays in the census at 819 until it lands.The seed-bound ceremony rewrites, now that the seed is past D197 and …
ehartford commentedon Nov 8, 2026
The 242 seed-bound rewrites landed in #3082. What remains here is the 807
len() as i32, which is a declaration-widening sweep (thei32parameters and fields that receive a length or index becomeisize), not a cast removal: see the comment above.ehartford commentedon Nov 8, 2026
Shape of the declaration sweep, measured on a tree at the #3091 stack top with every
.len() as i32insrc/stripped (758 sites in 56 files; the census's 819 includes spaced spellings) andwith check src/main.wunder the installed post-D183 compiler:(argument N of f)), across 230 distinct declarations; 348 name none (aletannotation, a field store, an index, a comparison). Top targets:comptime_value_listarg 3,add_typearg 3,pairs_list_i32arg 1 (9 each),wl_struct_set_bodyarg 3 (8),add_sigarg 4,wl_function_typearg 3 (7),wl_struct_typearg 3 (6), then a long tail of 1–5.HashMap.contains/Memo.contains/HashMap.getwith anisizeprobe against ani32key (no conversion on a probe) andifarms joiningisizewithi32(§4.2.6 refuses the implicit join).Two floors the sweep stops at, where the cast is a real narrowing and stays:
wl_*,clang_*):unsigned/intparameters are the ABI; D114 says a value crossing into C is fixed width;i32table (type_extra,sema_type_d1,extra_values, the MIR arrays): the element type is a layout choice, and widening it doubles the compiler's largest tables.Everything else — an
i32parameter or field that receives a length or index and is only compared, iterated or indexed with — widens toisize(D108, D114), and its casts fall away. The work is the classification of the 230 (plus the 348 no-note sites by their binding), one PR per area so a battery can bisect. Not started yet; the stripped tree is~/.local/with-staging/i3073(uncommitted).ehartford commentedon Nov 8, 2026
The declaration sweep is done on branch
i3073(one commit, 39 files, 410 lines): gate running, battery next.Method, so it can be rerun: strip every
.len() as i32insrc/(758), let D183's lint name the declaration each narrowing flows into, and iterate three tools to a fixpoint — widen a namedi32parameter toisizeunless it is the C bridge or a table store (add_node,add_extra,add_type,add_sig,comptime_value_*,pack_*,new_rvalue); put the cast back at a value's binding when the lint's target is a store into ani32list/map/array, a table-id return, or a C call; widen avar x: i32or a fieldf: i32the lint points at. Then revert any widened parameter whose body still lints (an id, not a position) and cast at its callers. Returns were the trap: widening 77-> i32returns cascaded to 1204 lints, because those are table ids by construction; returns stayi32.Result: about a hundred parameters, six variables and seven fields widened;
with check src/main.wclean (0 lints, 0 errors). The census'slen-castin src falls 784 → 617. What remains is the floor — a value stored into an AST/type/MIR/comptime table or crossing into C — where the cast is the narrowing it says it is. The issue's "done when" was "every.len() as i32whose target is ani32demand"; that set is exactly the floor, so the sweep closes this issue with the floor documented rather than cast-free.#3073: positions in the compiler are isize; the len() casts that fed …