Skip to content

fix-ceremony: facts proven on the compiler, --check-with, and the src/ ceremony sweep (#2939, #2942) - #3079

Merged
ehartford merged 5 commits into
mainfrom
fix-ceremony-5
Nov 8, 2026
Merged

ehartford merged 5 commits into
mainfrom
fix-ceremony-5

Conversation

@ehartford

@ehartford ehartford commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Three commits before the sweep, the sweep, and its hash re-record.

1. fix-ceremony facts proven on the compiler itself, and --check-with. Running the tool over src/ found eleven facts it relied on that were wrong (each a case the tests had not drawn) and one compiler bug (#3062: a bare .Variant under an Option[E] demand resolved by bare name, so a second enum sharing the name split an if's arms; now resolved through the demand, pinned by behav_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, for src/) 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 str field 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 (the return v.text spelling already retained). The 178 .clone() removals uncovered it at capability_arg_str, where the freed text was a build.w generated-source path. materialize_tail_read_of_dropped_local now retains; fixture da_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 : str annotations, 2 Some); they go with the next seed under #3073. docs/with-abi.sha256 is re-recorded for the respelled src/TypeLayout.w (no layout changed).

Also filed from this work: #3077 (an enumerate() instantiation failure inside the tool's own loop).

Eric Hartford 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant