Repository navigation
Fix #1287 (Atomic stores an element view's address), #1289 (derive on enums generates nothing), #1288 (derive(Debug) on f64/u32 fields) - #1311
Merged
Conversation
added 3 commits
September 22, 2026 11:15
…iew materializes its pointee
`a.store(xs[i], .SeqCst)` stored the element's ADDRESS on a global Atomic
and nothing on a local one. Root cause (src/SemaCheck.w
method_expected_arg_type): for `Atomic[T]` only the ordering operands
were published as expected argument types (atomic_method_expected_arg_type
in SemaDecl.w), so check_method_call never called
record_contextual_copy_adjustment for the value operand, and
MirLower.lower_method_arg_with_expected (the intrinsic argument path,
which consults exactly that record) lowered the `&i32` view unchanged.
Evidence (`with-stage1 check repro.w --dump-mir`, fn main, bb4):
before: _8 = ref(shared, _1[_7]);
call sym(store)(copy _6, copy _8, const 4) // the address
after: _8 = ref(shared, _1[_7]); _9 = copy _8;
call sym(store)(copy _6, copy _9.*, const 4) // the pointee
Fix: publish `T` as the expected type for store/swap/fetch_*'s value
operand and compare_exchange's expected/new operands, so the §3.8 / D27
contextual-copy record is made and consumed like any owned parameter.
No ownership or drop-scheduling path changes; this is a missing
expected-type publication at one intrinsic family.
Test: test/behavior/atomic_store_element_view.w (store, fetch_add, swap,
compare_exchange through `xs[i]` and `xs.get(i)`, global and local).
…ms; the derived debug_str observes
`@[derive(Debug, Clone)]` on an enum was accepted and generated nothing
(ct_generate_debug_derive / ct_generate_clone_derive returned an empty
vec for every non-Struct kind, no diagnostic), while §11.8's own example
derives on an enum. "No Silent Fallbacks": generate or diagnose. §11.8
says Debug derives always and Clone when every field is Clone, so the
enum case generates:
Debug: match self { Variant(p0, p1) => "Type.Variant(" ++ p0.debug_str()
++ ", " ++ p1.debug_str() ++ ")" | Unit => "Type.Unit" }
Clone: match self { Variant(p0, p1) => .Variant(p0, p1.clone()) }
(a Copy payload is read, any other payload is cloned)
Payload names are positional (the parser keeps no payload names). An
explicit derive whose payload cannot supply the trait is now an error
(ct_validate_explicit_enum_derive_payloads, the enum twin of the struct
validator), and `derive(all)` on an enum takes Debug and Clone when the
payloads qualify.
Found on the way: the derived debug_str took a consuming `move self`
receiver although the trait declares `fn debug_str(self: &Self)`, so
`self.tag.debug_str()` on a non-Copy field moved the field out (D32
error) and `d.debug_str()` moved the caller's binding (use-of-moved on
the next line). The derive now generates a `&Self` receiver like the
Clone derive does.
Evidence: test/behavior/derive_enum_debug_clone.w prints all seven
expected lines on the rebuilt stage1 and `run --debug-alloc` reports
leak count=0 (the generated Clone neither aliases nor double-frees the
str payload). test/compile_errors/err_derive_clone_enum_payload.w pins
the diagnostic. #1310 filed for the unrelated `S.A.tag()` bare
variant-path receiver lowering failure the first draft of the test hit.
…) succeeds on every primitive field
§11.8 derives Debug unconditionally, but lib/std/traits.w implemented
Debug only for i32/i64/u8/bool/str, so `@[derive(Debug)] type P { x: f64 }`
failed with "unknown method 'debug_str' for type 'f64'". Add the missing
primitive impls; each formats through the f-string, the one formatter
for every width.
Not added: Unit. `impl Debug for Unit` compiles but never dispatches
(method lookup on Unit fails, and `f"{()}"` is rejected as
"cannot interpolate a Unit value"), a separate defect outside this fix.
Test: test/behavior/derive_debug_wide_primitives.w.
ehartford
added a commit
that referenced
this pull request
Sep 22, 2026
…g (release-only segfault); da_match_place_observes never allocated (#1322) * ComptimeTransform: own the texts taken from intern.resolve — the derive generators held a view across interning `out/release/bin/with check test/behavior/derive_enum_debug_clone.w` segfaulted (rc 139, no output); the same test passed on the stage1 built by the pinned seed, so main went red only in the battery (behavior-tests lane, release binary) after #1311 and #1314 merged. Root cause (lldb on the cffb1cb release binary, frame Sema.ct_generate_debug_derive +1432): -> ldp x8, x9, [x20] ; x20 = [sp+0x28], the `type_name` &str ... bl with_str_concat_n ; type_name ++ ".debug_str" EXC_BAD_ACCESS address == x20; x27 (the live symbol_texts buffer) is in another region; the page under x20 reads as zeros. `InternPool.resolve` returns `&str`, a view into `symbol_texts: Vec[str]` (InternPool.w:136). Every generator bound it — `let type_name = intern.resolve(type_name_sym)` — then interned new texts (`ct_build_string_lit`, `intern.intern`) before its last use, so the table grew, the old buffer was freed, and the tail read through the dangling view. Which compiler generation lowers that `let` as a true D27 view (the current one) versus a header copy (the older seed) is the "layout" that made it release-only; which derives run in one module is what made the growth land inside this function. Fix: own the text at every such binding (17 sites, one `with -p` rewrite: `intern.resolve(sym).clone()`), the same spelling SemaDecl.w:907 already uses for its own pool text. No generator logic changes. Evidence: the rebuilt release binary compiles and passes derive_enum_debug_clone.w and the derive/match suites; :move-audit and :drop-audit ran on the batch (results in the PR). * da_match_place_observes: build the str payloads at runtime so the allocator report exists The fixture's payloads were all-literal `++` chains (`"one" ++ "two"`), which MirLower.try_fold_literal_str_concat folds to one constant (`_1 = const "sym…"` in --dump-mir), so the program never allocated, `with_debug_alloc_report_leaks` returned before printing (dbg_base == 0), and the lane failed on `want: 'leak count=0'` with no report line to read. The match-observes rule under test was never exercised over heap payloads, which is the point of the fixture. A two-parameter helper (`fn heap(a: str, b: str): a ++ b`) keeps every asserted length and produces a runtime concat (`str_concat_n` in the MIR); `run --debug-alloc` now prints `leak count=0` and the lane driver passes the fixture. --------- Co-authored-by: Eric Hartford <[email protected]>
ehartford
added a commit
that referenced
this pull request
Sep 22, 2026
…mpiler defects (#1338) * examples: ephemerality-and-lowering stores the element directly, store(order[2], ...) (#1287 fixed in #1311) The typed-binding detour around #1287 (Atomic intrinsics passed an element view's address as the value) is gone with its comment. Package test output unchanged on a release compiler built from ae609cd. * examples: json-parser matches byte literals as patterns and returns &entry.value inline (#1295, #1297 fixed) Byte arms are Some(b'{') patterns, not guards (#1295, fixed in #1312); json_get_field returns Some(&entry.value) from a for loop over the entries, and the kv_value helper is gone (#1297, fixed in #1327). Workaround comments removed. Demo and package test output unchanged on a release compiler built from ae609cd. * examples: nebula's Status and Telemetry carry @[derive(Debug, Clone)] again (§11.8; #1288, #1289 fixed in #1311) The parking comment is removed. Demo and package test output unchanged on a release compiler built from ae609cd. * examples: service builds its change list and SET clause with the §7.2 builder (#1298 fixed in #1319) describe_changes and PgUserRepo.update spell with Vec.new() as mut ...: with a trailing if; the var desugaring and its comments are gone. Demo and package test output unchanged on a release compiler built from ae609cd (neither function is reached by the demo; the same shape was run separately under --debug-alloc: correct result, zero leaks). * examples: ecs cites D43 for DenseStorage.insert's -> Unit, not #1296 insert's tail if has an assignment arm (a value of type T) and a push arm (Unit): two meanings remain, so -> Unit is the spelling D43 requires, not a workaround. The compiler currently infers Unit without it because the assignment arm is a multi-statement block (#1337); the one-statement spellings of the same arm are rejected as D43 requires. --------- 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.
Three validated compiler defects, one logical change per commit.
#1287 —
Atomic.store(xs[i])stored the element's address.src/SemaCheck.wmethod_expected_arg_typepublished only the ordering operands forAtomic[T], so no contextual-copy record was made for the value operand and the intrinsic argument path (lower_method_arg_with_expected) passed the&i32view as-is. NowTis published for store/swap/fetch_*'s value operand and compare_exchange's expected/new.--dump-mirbefore/after:call store(copy _6, copy _8, …)with_8 = ref(shared, _1[_7])becomescopy _9.*(the materialized pointee). No ownership or drop-scheduling change (one expected-type publication);:move-auditnot required.#1289 —
@[derive(Debug|Clone)]on an enum was inert.ct_generate_debug_derive/ct_generate_clone_derivereturned an empty vec for non-Struct kinds with no diagnostic. §11.8 says Debug derives always and Clone when every field is Clone (its own example derives on an enum), so both now generate for data enums (Type.Variant(p0, p1)Debug form, positional; Clone rebuilds the variant cloning non-Copy payloads). An explicit derive with an unsupporting payload is an error;derive(all)on an enum takes Debug/Clone when the payloads qualify. Also found and fixed: the deriveddebug_strtook amove selfreceiver against the trait's&Self, so it moved non-Copy fields out (D32) and moved the caller's binding; it now generates&Selflike the Clone derive.run --debug-allocon the new test: leak count=0.#1288 —
Debugimpls for i8/i16/u16/u32/u64/f32/f64 inlib/std/traits.w.Unitis deliberately not added:impl Debug for Unitcompiles but never dispatches (andf"{()}"is rejected), a separate defect.Tests:
test/behavior/atomic_store_element_view.w,test/behavior/derive_enum_debug_clone.w,test/behavior/derive_debug_wide_primitives.w,test/compile_errors/err_derive_clone_enum_payload.w. Existingspec_ss11_8_derive,spec_ss11_8_derive_builder,spec_ss17_3_user_defined_derive,spec_ss14_17_1_atomic_generic,codegen_global_atomic,behav_enumand the derive compile_errors cases pass on the rebuilt stage1.Filed on the way: #1310 (
S.A.tag()— method call on a bareType.Variantpath receiver fails MIR lowering; pre-existing on main).Verified:
with check src/main.wok,build :devgreen (stage1 rebuilt twice).:fixpoint/:testnot run per the brief; battery pending.