Repository navigation
Conversation
added 3 commits
October 2, 2026 10:28
…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.
Contributor
Author
|
Note: this PR was merged from the stack UI into its base branch |
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.
Fixes #1239. Spec: README v7.4 / D71 — a positional collection has no
get;xs[i]is the one spelling. On mainv.get(0)on Vec compiled (arrays/slices already refused). Sema now refuses it namingxs[i]; the c-facade renderer and derive(SoA) emitters updated; tools/migrate_vec_get.w (Lexer-based, from check logs) rewrote 876 sites in 233 files to a fixpoint. Two compile_errors fixtures pin the diagnostic.Also fixes a pre-existing miscompile it exposed (473b029): a block tail
let t = f(); t[id].xlowereddrop(t)before the element read (lldb + --dump-mir); MirLower now materializes the read first; behav_tail_element_read_before_drop.w panics on main, passes now. The pinned seed still carries that bug, so the seed-built stage1 miscompiles one function until the next seed bump; stage2/release are correct.examples/ecs changed
.get(i)→[i]: a spec-required spelling (D71), per the 2026-09-22 ruling that examples track the spec. Gate green, drop-audit 254/0 on the stack top. Battery with the next batch.