Skip to content

audit:all reports a leak for a mut fn str receiver reassigned in place (self = self ++ "!"): the caller's place is not an owned local #1822

Closed

Description

@ehartford

Repro

extend str:
    mut fn bang(): self = self ++ "!"
fn main:
    var m = "hello"
    m.bang()
    print(m)

with analyze repro.w audit:all (fix-lang stage1, 2026-09-27):

violation: ownership MIR: fn sym13492 bb0: owned local _1 is still Init at return — no path drops or moves it (a leak)
compiler-analysis-audit: ... violations=1 FAILED

with run --debug-alloc repro.w prints hello! and debug-alloc: leak count=0.

Expected

self in a mut fn is the caller's place (SHARE-PLACE in --dump-abi, D12/D21): the callee never owns it, so leaving it Init at return is the contract, not a leak. The #1488 leak rule treats the in-place receiver local as an owned local. Either the validator's leak rule exempts in-place receiver (value-ref-ABI) parameters, or MIR types that local as a place it does not own — one owner of the fact (D65).

Found building the #1810 matrix; independent of the &str representation (same verdict before and after).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions