You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Implement D12: mut fn on str/fat-pointer owners lowers via share-place (IndirectPlace) #678
mut fn mutates the caller's place on every owner type. This issue implements the str / fat-pointer shape, the delicate sibling of #677 (scalar primitives): a mut fn on a str owner (or a distinct-over-str) lowers via D5 share-place (PassMode::IndirectPlace) over the {ptr, len} fat pointer, so reassigning self rewrites the caller's binding.
extend str:
mut fn trim_first(): self = self.slice(1, self.len())
var s = "abc"
s.trim_first() // s == "bc"
str is a fat pointer ({ptr: *const u8, len}), currently PassMode::Fat. IndirectPlace for str = a pointer to the 16-byte fat struct (str*), and the callee writes both fields — a distinct ABI shape from a scalar i32*, with its own drop/lifetime cell (view-origin tracking, §22 ephemeral rules: reassigning self to a sub-slice must not outlive the source). It has its own root-cause line too: src/SemaDecl.w:1089 excludes str owners explicitly (separate from the aggregate gate at ~1093 that #677 addresses).
Approach
Remove the blanket str exclusion in fn_param_uses_value_ref_abi for non-moveself; classify mut self: str as share-place over the fat pointer.
Verify the Fat ↔ IndirectPlace interaction in compute_fn_abi/PassMode (D6) — the receiver is a pointer-to-fat, and the callee prologue must load/store both fields. Confirm via --dump-abi.
Enforce view-origin / ephemeral rules on self = <sub-slice-of-self>: the reassigned view must be provably within the caller's original allocation (no escape of a shorter-lived slice).
Acceptance
mut fn on str reassigning self to a sub-slice mutates the caller's var; let receiver rejected cleanly.
--dump-abi shows SHARE-PLACE for mut self: str.
Ephemeral/view-origin: a mut fn that tries to set self to a view outliving the source is rejected (§22).
/drop-audit clean for the fat-pointer share-place receiver cells.
IMPLEMENTED (e823026, battery-green incl. the allocator lane, reseeded ge823026b0 + asset). Every acceptance item: mut-self str receivers classify SHARE-PLACE over the {ptr,len} fat pointer (--dump-abi verified); 'self = self ++ x' and 'self = self.slice(...)' rewrite the caller's binding — both fields travel (len-change pinned); by-value str params still copy; let receiver gets the clean 'cannot mutate immutable binding' error. Read/plain self on str deliberately stays by-value (a read borrow of a Copy fat pointer is observationally a copy; str reads are the hottest stdlib path). Drop cells are nil (str is Copy, no destructor); the §22 reject-shorter-lived-view cell is VACUOUS under the provisional A5/#608 str backing (heap, never freed — dangling is unconstructible today); real enforcement lands with #691's ownership migration, noted in that campaign. Also closes the silent-no-op window e101e7e opened (str bare-self compiled but mutations vanished — now they land).
Activity
Docs: canonize D12 — mut fn mutates in place on every owner type (#644)
ehartford commentedon Jul 19, 2026
IMPLEMENTED (e823026, battery-green incl. the allocator lane, reseeded ge823026b0 + asset). Every acceptance item: mut-self str receivers classify SHARE-PLACE over the {ptr,len} fat pointer (--dump-abi verified); 'self = self ++ x' and 'self = self.slice(...)' rewrite the caller's binding — both fields travel (len-change pinned); by-value str params still copy; let receiver gets the clean 'cannot mutate immutable binding' error. Read/plain self on str deliberately stays by-value (a read borrow of a Copy fat pointer is observationally a copy; str reads are the hottest stdlib path). Drop cells are nil (str is Copy, no destructor); the §22 reject-shorter-lived-view cell is VACUOUS under the provisional A5/#608 str backing (heap, never freed — dangling is unconstructible today); real enforcement lands with #691's ownership migration, noted in that campaign. Also closes the silent-no-op window e101e7e opened (str bare-self compiled but mutations vanished — now they land).
Sema: mut fn on str owners lowers via share-place over the fat pointe…
Docs: handoff — D12 COMPLETE (#678 done, #644 closed); queue advances…