Skip to content

Explicit receivers outside trait bodies: 19 trait impls + 18 build-layer dotted methods, then refuse explicit self #727

Open

Description

@ehartford

Restated (2026-10-25 triage)

The last explicit receivers outside trait bodies: 19 trait impls and 18 dotted top-level methods in the build layer (seed-gated), then the refusal of an explicit self parameter (eliminate-self.md phase 4).


Original report

Repro

./out/release/bin/with analyze out/deep-debug-tool-tests/ownership-input.w audit:receiver-surface
# violation: receiver surface still contains 63 explicit `self` parameter(s); query kind=declaration,flags&=256
# receiver-surface-audit: facts=3731 violations=1 FAILED

Fails on the seed too (rc=1) — pre-existing relative to the D22 batch, surfaced when the deep-debug-tool-tests lane first executed against current inputs (it had been masked behind serial lane aborts since 2026-07-22).

Tension to resolve

The audit enforces the receiver-migration invariant (no explicit self in impl/trait declarations). But Parser.w:3212 makes a plain fn in a trait declaration a STATIC method — so a trait that wants an instance method must spell self: &Self explicitly (#716's IntoIter.iter(self: &Self) did exactly this, adding trait-decl explicit selfs by necessity). Counts: explicit=63, in-impl=39, trait-impl=39, trait-decl=24, top-level=0.

Either the audit needs a trait-decl exemption (and the 39 in-impl sites need migration), or the parser's static-method rule for traits needs a different spelling so traits can declare instance methods without explicit self. The second is a language-surface question for Eric; the audit red is correct until one side is ruled.

Blocks the deep-debug-tool-tests lane (with #726) and therefore reseed.

Activity

  1. ehartford commented on Jul 26, 2026

    @ehartford
    ContributorAuthor

    Note from the #726 fix: audit:receiver-surface still fails standalone on the fixed compiler (rc=1, same 63 explicit selfs) — it is genuinely independent of the pool corruption. Also observed: audit:all's aggregate verdict returns rc=0 while audit:receiver-surface alone returns rc=1 — either receiver-surface is advisory in the aggregate by design or the aggregate misses its verdict; worth settling when this issue is picked up.

  2. ehartford commented on Aug 31, 2026

    @ehartford
    ContributorAuthor

    Triage re-scope 2026-08-31: the audit still fails standalone and the count grew (75 explicit selfs: 51 trait-impl + 24 trait-decl, violations=1 FAILED) — but no lane gates on audit:receiver-surface anymore, so 'blocks the lane and reseed' is dead (reseeds have happened repeatedly). Remaining fork for Eric: extend D7's receiver-prefix keywords to trait declarations (src/SemaDecl.w:2092 still demands explicit self spellings in traits) and migrate the trait-impl sites, or give the audit a trait exemption.

  3. added a commit that references this issue on Aug 31, 2026
  4. ehartford commented on Aug 31, 2026

    @ehartford
    ContributorAuthor

    Executed per Eric's ruling (2026-08-31, carve-out stands, items 1–3 approved): landed in 2d9759b.

    • Item 1 — audit codifies the carve-out: trait-decl READ contracts with explicit self: &Self count as conforming (carve-out=24 in the note line); everything else explicit still fails. The failure message now names the carve-out.
    • Item 2 — trait-impl migration + probes: the D7-era conservative skip in tools/migrate_receivers.w is retired (synthesis is trait-contract-driven — pinned by the new behav_trait_impl_keyword_receivers fixture, including the instance-contract-whose-body-never-touches-self case). 50 sites migrated across lib/std; full with build :test green afterward. Two generator-side fixes rode along: pub error desugar marks its synthesized receivers SYNTH (they no longer pollute the audit), and the lane's ownership input respells its drop.
    • Item 3 — precise census before running: zero real sites. The two TRAIT-DECL-MUT grep hits were doc comments.
    • Gate re-armed: deep-debug-tool-tests now runs audit:receiver-surface rc-checked — violations=0 ok on the regenerated input.

    Residue, left open on this issue with reduced scope: top-level dotted instance methods (fn Type.m(self: &Self)) need extend-block relocation, which the migrate tool deliberately skips — 9 in the compiler unit (LspState.*) and ~168 outside it (lib/std/build.w ~125, sync ~21, compiler ~11, plus stragglers). That's tools/relocate_methods.w territory and a separate mechanical slice awaiting a go.

  5. changed the title [-]analyze audit:receiver-surface fails: 63 explicit self parameters (39 in-impl, 24 trait-decl) — invariant vs parser's static-method rule[/-] [+]D7 self-less surface residue: relocate top-level dotted instance methods (fn Type.m(self: &Self)) into extend blocks (~177 sites)[/+] on Aug 31, 2026
  6. changed the title [-]D7 self-less surface residue: relocate top-level dotted instance methods (fn Type.m(self: &Self)) into extend blocks (~177 sites)[/-] [+]Explicit receivers outside trait bodies: 19 trait impls + 18 build-layer dotted methods, then refuse explicit self[/+] on Oct 25, 2026
  7. ehartford commented on Oct 25, 2026

    @ehartford
    ContributorAuthor

    Triage 2026-10-25, with v0.15.3.0 (main a261b65): the bulk is done (the carve-out codified in 2d9759b; the dotted relocations happened). What remains: explicit receivers outside trait bodies, 37 of them, 19 in trait impls (lib/std/sync.w, the collections' IndexGet impls) and 18 dotted top-level methods (lib/std/alloc.w Arena/FrameArena/Pool, lib/std/build.w ToolFs, build-layer spellings the pinned seed's evaluator compiles). The plan for the refusal that closes this is eliminate-self.md §4 phase 4.

    post-release: surface cleanup, seed-gated for the build layer.

  8. added this to the post-v0.16.0 milestone on Oct 28, 2026
  9. ehartford commented on Nov 24, 2026

    @ehartford
    ContributorAuthor

    The mechanical half is merged (#3586): lib/std writes no explicit receiver outside a trait body (205 dotted methods moved into impl blocks, 17 trait-impl methods in the keyword form).

    What the tree still holds, by kind:

    • trait declarations, fn m(self: &Self) (the ruled carve-out: 26 in std.traits, std.context, std.json, std.builtins, std.collections);
    • source text inside programs the tools and build fixtures write (tools/drop_audit.with, tools/move_audit.with, build/selfhost.with, one in build.with), and the embedded guide text in src/InitTemplates.with. These have to move with the refusal, since several of them exist to exercise today's spelling.

    What is left is the refusal itself (eliminate-self.md phase 4): an explicit self parameter outside a trait body becomes an error with a fix-it. That rejects programs that compile today, so it is Eric's go, not mine. Labelling human attn needed for that one decision.

    Found on the way and fixed in the same PR: attributes above an impl-block method (@[suspends], @[must_use], @[tailrec], @[inline], @[noinline], @[no_alloc]) were read and dropped by the parser.

  10. ehartford commented on Nov 25, 2026

    @ehartford
    ContributorAuthor

    Ruled by Eric, 2026-11-25 (answers to briefs.md).

    B: refuse after the second half of eliminate-self is ruled and landed. Two things need not wait and are mine now: the count of contract programs that use the explicit form, and the fix-it shipped as a fix-ceremony rewrite (which proves it exact before it backs a refusal). Label removed.

  11. ehartford commented on Nov 27, 2026

    @ehartford
    ContributorAuthor

    Following up on the two immediate deliverables from the 2026-11-25 ruling:

    1. Contract-program explicit-self count across all 55 .with files in uat/ (7 files) and examples/ (48 files):

      • Outside trait bodies (what phase-4 refusal will reject): 0 files, 0 methods.
      • Inside trait bodies (D7 read carve-out fn m(self: &Self)): 2 files, 17 methods:
        • examples/nebula/src/schema.with — 2 methods in pub trait SqlRecord (lines 38–39)
        • examples/service/src/traits.with — 15 methods across UserRepository, CacheService, NotificationService, AuditLog (lines 9–38)
    2. with fix-ceremony explicit-self rewrite: implemented in draft PR fix-ceremony: rewrite explicit self parameters to implicit receivers (#727) #3654 (rewrites impl/extend and non-read trait explicit self parameters to fn / mut fn / move fn, preserves the D7 trait read carve-out, and reports top-level dotted methods pointing to with migrate-receivers). Battery is running now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions