Repository navigation
fix-ceremony: facts proven on the compiler, --check-with, and the src/ ceremony sweep (#2939, #2942) - #3079
Merged
Conversation
added 5 commits
November 7, 2026 18:48
…check-with for a second compiler Running the rewriter over src/ found eleven facts it relied on that were wrong, each a case the tests had not drawn: an element name that lexes as a keyword or is bound later in the function, or that a sibling loop also chose (Sema now chooses the name where the scope is known, per function, saved around nested body checks); a loop base that is a str, or a list the body mutates; a vacate that is a write of its root; a `&temporary` whose `&` must stay; a bare `None` that takes its type from the demand; a `&str` annotation that keeps the binding a view; a cast initializer whose annotation is the demand the cast removal relies on; and the module path of a node checked lazily from another module (every per-node path fact now comes from the node's own file). One compiler bug came with them: a bare `.Variant` under an `Option[E]` demand resolved by bare name, so a second enum sharing the name split an if's arms (#3062, pinned by behav_3062_option_shorthand_cross_module). `--check-with <compiler>`: after the tool's own re-check, a second compiler (the pinned seed, for src/) must accept the result; a rewrite it refuses is kept as written and reported, mapped by the name the diagnostic quotes, until it checks.
… 98 files, every one a fact of Sema's `with fix-ceremony --apply --check-with src/main src/main.w` over the compiler: `List.new()`/`HashMap.new()` under a written type become the literal (2,807), `var` never rebound becomes `let` (1,651), an index loop that only reads its list iterates it (765 loops), a redundant annotation goes (465), a widening cast under its demand goes (387), `.clone()` on a str goes (178), `Some(x)` under an Option demand becomes `x` (9). The tree's compiler and the pinned seed both check the result; 242 rewrites the seed refuses (165 str clones, 69 shift-count casts, 4 `: str` annotations, 2 `Some`) stay as written until a post-D197 seed is pinned (#3073). No byte outside src/ changed; the census counts fall (list-new 4250 → 1443, index-loop 2105 → 1575, clone-call 87 → 75).
…no layout changed; abi_roadmap.md Level 0 keys the .wo bundles on the file's bytes)
materialize_tail_read_of_dropped_local reads a projected copy into a temp before the scope's drops (#1991) but gave the copy no hold, so a counted type gained a holder without a retain: `let v = make(); …; v.text` lowered to `_5 = copy _2.text; drop(_2); _0 = copy+take _5` and returned a freed str (the `return v.text` spelling already lowered to `copy+retain`). The temp retains as any owning destination does. The src/ ceremony sweep exposed it: the `.clone()` it removed on `capability_arg_str`'s `value.text` had hidden it, and the freed text was a build.w generated-source path (cli-selfhost-build-w-tests). Fixture: test/debug_alloc/da_3080_tail_field_read_retains.w.
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.
Three commits before the sweep, the sweep, and its hash re-record.
1.
fix-ceremonyfacts proven on the compiler itself, and--check-with. Running the tool oversrc/found eleven facts it relied on that were wrong (each a case the tests had not drawn) and one compiler bug (#3062: a bare.Variantunder anOption[E]demand resolved by bare name, so a second enum sharing the name split anif's arms; now resolved through the demand, pinned bybehav_3062_option_shorthand_cross_module). Every fix is in Sema's facts or the compiler, never in a rewritten program.--check-with <compiler>makes a second compiler (the pinned seed, forsrc/) accept the result too: a rewrite it refuses is kept as written and reported, mapped by the name the diagnostic quotes.2. #3080, a compiler bug the sweep exposed. A
strfield read as a function's tail from an owned local lowered to_5 = copy _2.text; drop(_2); _0 = copy+take _5: a holder without a retain, so the function returned a freed str (thereturn v.textspelling already retained). The 178.clone()removals uncovered it atcapability_arg_str, where the freed text was a build.w generated-source path.materialize_tail_read_of_dropped_localnow retains; fixtureda_3080_tail_field_read_retains.3. The sweep (#2939, #2942). 6,397 rewrites in 98 files under
src/, nothing else touched; the tree's compiler and the pinned seed both check the result. Census: list-new 4250 → 1443, index-loop 2105 → 1575, clone-call 87 → 75, len-cast 823 → 819. 242 rewrites stay as written because the seed predates D197 (69(k as u32)shift counts) and D111's str value semantics (165.clone()on a str, 4: strannotations, 2Some); they go with the next seed under #3073.docs/with-abi.sha256is re-recorded for the respelledsrc/TypeLayout.w(no layout changed).Also filed from this work: #3077 (an
enumerate()instantiation failure inside the tool's own loop).