Repository navigation
Conversation
Merged
added 5 commits
October 2, 2026 12:16
…1239) Spec (README v7.4, D71): "a positional collection has no `get`, `xs[i]` is the one spelling (§ Element access, D27)". Arrays and slices already had no `get`; `Vec[T].get(i)` still typed as the element view, so one meaning had two spellings. Sema (SemaCheck.check_method_call_parts): `Vec.get` is an error naming the spelling — "Vec has no 'get': element access is spelled 'xs[i]' (§ Element access, D71)" — and still types as `&T` so checking continues past it. Emitters that synthesized the old spelling move to the index node: the `c facade` renderer's retained-free loop (FacadeRender.w) and the `@[derive(SoA)]` row rebuild (ComptimeTransform.ct_build_index). tools/migrate_vec_get.w rewrites the sites the compiler reports: it reads `with check` logs, takes each diagnostic's location and caret span, matches the call's parentheses with the Lexer (bytes inside an f-string interpolation), and applies the byte edits in one pass; stale sites (a stage binary's embedded std predating a rewrite) and synthesized sources are skipped and named. 876 sites in 233 files across src/, lib/std, build/, tools/, examples/ and test/ were rewritten with it, to a fixpoint: the stage1 built from this tree (`src/main build :dev` rc=0) checks `src/main.w` clean, and the pinned seed checks the migrated tree (`src/main check src/main.w` ok). Fixtures: the two `Vec.get` bad-index compile-error tests now pin the D71 diagnostic; behav_pipeline_methods' `v |> get(0)` is `v[0]`.
… the block drops reads before the scope-exit drop `fn arity(id: i32) -> i32: let t = table(); t[id].arity` lowered as `drop(_2) @ scope-exit; _0 = copy _2[_4].f` — the tail was left a lazy place operand (bare place tails stay lazy for view returns), the block's pop_scope_inline emitted the Vec's drop, and the consumer's assignment read the element from the freed Vec: "panic: index out of bounds" from the cleared length. Pre-existing on main (the minimal repro panics with the installed compiler); the D71 migration exposed it in MathBuiltins.math_fn_arity, where `t.get(id).arity` — a call, so materialized — became `t[id].arity`, and every program calling a math builtin then crashed the compiler (sema-order-check, examples-tests and benchmarks-check in the gate). Root cause (lldb: with_panic_ref <- math_fn_arity MathBuiltins.w:82 <- Sema.check_intrinsic_call; `--dump-mir` of the repro shows the order): lower_block_mode materializes only the explicit `move owned.field` tail (materialize_tail_field_move). Fix: materialize_tail_read_of_dropped_local copies a lazy OK_COPY projected-place tail into a temp before pop_scope_inline when the place's base local is in the closing scope's drop list and the read is not a reference or pointer (a view-typed tail stays lazy for its `&`-typed destination; Sema refuses one that outlives its origin). The repro's MIR is now `_5 = copy _2[_4].f; drop(_2); _0 = copy _5`. test/behavior/behav_tail_element_read_before_drop.w pins it (panics on main, passes under the stage1 built from this tree). Note: the pinned seed still carries the bug, so the seed-built stage1's own math_fn_arity is miscompiled until the next seed bump; stage2 and the release binary are built by stage1's fixed lowering and are correct.
The spec change (README v7.4, D71) updates the example in the same change: storage.w and world.w read `entries.get(i)` on a Vec; the ecs sources are a multi-module project whose modules the per-file corpus check could not resolve, so examples-tests reported them. Rewritten with tools/migrate_vec_get.w from the release binary's own diagnostics.
… (D71, #1239) The sweep rewrote the sites the compiler reported for the roots it checked; these sites sat in roots it never reached: the spec and comptime-diff corpora, the debug-alloc lane, and programs embedded as strings in build/selfhost.w (the one-liner parity case, the build.w and project cases, the emit-c collections case), lib/std/build.w (the https_fetch and zlib_gunzip twins) and the pre-D action-filesystem runner fixture. The real files were rewritten by tools/migrate_vec_get.w from stage1's own diagnostics; the embedded strings by a with -p regex over the string lines. Three fixtures whose purpose was get are re-pinned to the one spelling with the same intent: behav_vec_get_bounds_panics expects exit 134 and "index out of bounds" (get's bounds check went through with_panic_core and rt_exit(1); the index panic goes through with_panic_ref and aborts like the array and slice index fixtures); err_d27_mut_get_chain_read_only reads the element through a borrowed &Vec so the read-only chain, not the retired get, is what the D27 E1 error rejects; err_d27_view_liveness_get_after_push binds the let-bound view with items[0] and still gets E3's live-view error.
…71, #1239) eval_index took arrays, tuples, vecs and str; a Vec[u8] from ToolFs.read_binary or StringBuilder.bytes is the evaluator's CV_BYTES value, which only the retired `get` method path read. With `get` gone the toolfs-ok build.w selfhost case (`loaded[0] == 0 as u8`) failed with "comptime index requires an array, tuple, vec, or str" at build.w:15:12. The index now reads the byte like the str case; the unreachable `Vec[u8].get` evaluator branch is removed (Sema rejects the spelling before evaluation).
Contributor
Author
|
Battery GREEN on stack top 7bdd704 (seed-driven, |
ehartford
marked this pull request as ready for review
October 2, 2026 22:30
This was referenced Oct 2, 2026
This was referenced Oct 2, 2026
Closed
ehartford
pushed a commit
that referenced
this pull request
Oct 3, 2026
… a use after drop (#1991) #1991's stage1-only "index out of bounds" in math_fn_arity was the pre-#1968 lowering in the old pinned seed (nightly-20260929, 8f84428): `let t = math_fn_table(); t[id].arity` lowered to `drop(_2); _0 = copy _2[_4].f`. The seed-built stage1's machine code frees the Vec and then panics on every path (the optimizer folded the cleared length into the bounds check), and the seed's own `check --validate-all` said ok: the drop-state lattice marks a dropped place Uninit, like StorageDead, and judges only whole-local reads of Maybe places, never a projection. validate_read_after_drop: a forward must-analysis of the locals every path has whole-dropped (Drop, drop-and-goto) and nothing rewrote (whole Assign, StorageLive, call destination). A value read of such a local, whole or through a projection, in a statement or a terminator operand is refused. Swept with stage1 `check --validate-all` over test/behavior, test/phase and test/spec (2049 files): one hit, a real one (behav_c_facade_resource_drop_once: `drop(_1); _0 = copy _1.repr`), fixed in the next commit. test/internals/mir_read_after_drop_test.w builds the MIR directly (fails with the call removed): read after drop, after a drop-and-goto, as a call argument; clean for read-before-drop, drop-rewrite-read, and a drop on one arm only.
ehartford
pushed a commit
that referenced
this pull request
Oct 3, 2026
…ck drops reads before the drop (#1991) The read-after-drop validator named `fn scope() -> *mut db: let d = Database.new(1).unwrap(); d.repr` in behav_c_facade_resource_drop_once: `drop(_1); _0 = copy _1.repr`. materialize_tail_read_of_dropped_local (#1968) left a TY_PTR tail lazy beside a TY_REF one, but a raw pointer is a value the place stores, not a view of the place: `let t = rows(); t[0].p` read the freed Vec and panicked "index out of bounds" with the release compiler. Only a view-typed tail stays lazy now. test/behavior/behav_1991_tail_pointer_field_read_before_drop.w panics on the installed release compiler and passes under the stage1 built from this tree; the facade fixture now passes validate-all.
ehartford
pushed a commit
that referenced
this pull request
Oct 3, 2026
… a use after drop (#1991) #1991's stage1-only "index out of bounds" in math_fn_arity was the pre-#1968 lowering in the old pinned seed (nightly-20260929, 8f84428): `let t = math_fn_table(); t[id].arity` lowered to `drop(_2); _0 = copy _2[_4].f`. The seed-built stage1's machine code frees the Vec and then panics on every path (the optimizer folded the cleared length into the bounds check), and the seed's own `check --validate-all` said ok: the drop-state lattice marks a dropped place Uninit, like StorageDead, and judges only whole-local reads of Maybe places, never a projection. validate_read_after_drop: a forward must-analysis of the locals every path has whole-dropped (Drop, drop-and-goto) and nothing rewrote (whole Assign, StorageLive, call destination). A value read of such a local, whole or through a projection, in a statement or a terminator operand is refused. Swept with stage1 `check --validate-all` over test/behavior, test/phase and test/spec (2049 files): one hit, a real one (behav_c_facade_resource_drop_once: `drop(_1); _0 = copy _1.repr`), fixed in the next commit. test/internals/mir_read_after_drop_test.w builds the MIR directly (fails with the call removed): read after drop, after a drop-and-goto, as a call argument; clean for read-before-drop, drop-rewrite-read, and a drop on one arm only.
ehartford
pushed a commit
that referenced
this pull request
Oct 3, 2026
…ck drops reads before the drop (#1991) The read-after-drop validator named `fn scope() -> *mut db: let d = Database.new(1).unwrap(); d.repr` in behav_c_facade_resource_drop_once: `drop(_1); _0 = copy _1.repr`. materialize_tail_read_of_dropped_local (#1968) left a TY_PTR tail lazy beside a TY_REF one, but a raw pointer is a value the place stores, not a view of the place: `let t = rows(); t[0].p` read the freed Vec and panicked "index out of bounds" with the release compiler. Only a view-typed tail stays lazy now. test/behavior/behav_1991_tail_pointer_field_read_before_drop.w panics on the installed release compiler and passes under the stage1 built from this tree; the facade fixture now passes validate-all.
ehartford
added a commit
that referenced
this pull request
Oct 3, 2026
…fore the drop (#2050) * MIR ownership validator: a read through a local every path dropped is a use after drop (#1991) #1991's stage1-only "index out of bounds" in math_fn_arity was the pre-#1968 lowering in the old pinned seed (nightly-20260929, 8f84428): `let t = math_fn_table(); t[id].arity` lowered to `drop(_2); _0 = copy _2[_4].f`. The seed-built stage1's machine code frees the Vec and then panics on every path (the optimizer folded the cleared length into the bounds check), and the seed's own `check --validate-all` said ok: the drop-state lattice marks a dropped place Uninit, like StorageDead, and judges only whole-local reads of Maybe places, never a projection. validate_read_after_drop: a forward must-analysis of the locals every path has whole-dropped (Drop, drop-and-goto) and nothing rewrote (whole Assign, StorageLive, call destination). A value read of such a local, whole or through a projection, in a statement or a terminator operand is refused. Swept with stage1 `check --validate-all` over test/behavior, test/phase and test/spec (2049 files): one hit, a real one (behav_c_facade_resource_drop_once: `drop(_1); _0 = copy _1.repr`), fixed in the next commit. test/internals/mir_read_after_drop_test.w builds the MIR directly (fails with the call removed): read after drop, after a drop-and-goto, as a call argument; clean for read-before-drop, drop-rewrite-read, and a drop on one arm only. * MirLower: a block tail copying a raw-pointer field of a local the block drops reads before the drop (#1991) The read-after-drop validator named `fn scope() -> *mut db: let d = Database.new(1).unwrap(); d.repr` in behav_c_facade_resource_drop_once: `drop(_1); _0 = copy _1.repr`. materialize_tail_read_of_dropped_local (#1968) left a TY_PTR tail lazy beside a TY_REF one, but a raw pointer is a value the place stores, not a view of the place: `let t = rows(); t[0].p` read the freed Vec and panicked "index out of bounds" with the release compiler. Only a view-typed tail stays lazy now. test/behavior/behav_1991_tail_pointer_field_read_before_drop.w panics on the installed release compiler and passes under the stage1 built from this tree; the facade fixture now passes validate-all. --------- Co-authored-by: Eric Hartford <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces #1962, which was merged into its stack base
fix-1356(not main) from the stack UI. Same three commits, rebased: Sema refusesVec.getnamingxs[i]; the c-facade renderer and derive(SoA) emitters updated; tools/migrate_vec_get.w rewrote 876 sites in 233 files; two compile_errors fixtures pin the diagnostic. Also a pre-existing miscompile it exposed: a block taillet t = f(); t[id].xlowereddrop(t)before the read (lldb + --dump-mir); MirLower materializes the read first; behav_tail_element_read_before_drop.w panics on main, passes now. examples/ecs.get(i)→[i]is the spec's spelling (D71; 2026-09-22 ruling). Layer 4 of the batch stack.