Skip to content

Four tools stale after the read-only &str ABI flip (migrate_d22_copy_views, annotate_receivers, insert_std_uses, materialize_predicate) #1069

Closed

Description

@eas4ai

At 450733e, four committed tools no longer compile under their canonical with run invocation. All four share one drift signature: they were written before 7d8d085 flipped the read-only ABI to &str (str is not Copy; D22 map-view Vec[str].get() yields &str). Reproduced under the seed; the audit also confirmed identical failure under stage2/installed compiler (see probe files). Exact seed outputs:

tools/migrate_d22_copy_views.w — &str passed to str params:

error: wrong argument type in call to 'edit_key'
 --> tools/migrate_d22_copy_views.w:76:21
  = label @76:21 argument expression 'edits.paths.get(i as i64)' has type &str
  = note: parameter 'path' expects str

tools/annotate_receivers.w — same signature (:51 return mismatch, :59 if-needs-Copy, :313/:315/:323):

error: if would need to copy a `str`, which is not Copy
 --> tools/annotate_receivers.w:59:22
59 |     if nearest >= 0: facts.modes.get(nearest as i64) else: ""

tools/insert_std_uses.w — bare extern calls plus &str-to-str:

error: manual extern function call requires unsafe context
 --> tools/insert_std_uses.w:74:13
74 | let diags = with_fs_read_file(diags_file)
error: wrong argument type in call to 'vec_contains'
 --> tools/insert_std_uses.w:101:34

tools/materialize_predicate.w:38 — owned/borrowed if-arms:

error: if would need to copy a `str`, which is not Copy
 --> tools/materialize_predicate.w:38:36
38 |     child.push(if arg == "{file}": materialized else: arg)

Probable repair (not applied — read-only audit): take &str parameters and clone only at the Vec[str].push sinks, matching the already-green tools/rename_rt_libc_externs.w style; wrap the three extern calls in insert_std_uses in unsafe.

Evidence: .audit/modules/tools__{migrate_d22_copy_views,annotate_receivers,insert_std_uses,materialize_predicate}.w.md and .audit/probes/tools_*/

Activity

  1. ehartford commented on Sep 16, 2026

    @ehartford
    Contributor

    Review: reproduced

    Verdict. Reproduced: all four tools fail to compile under with run, each with the exact error the report cites. They share one drift signature — written before the read-only ABI flip to &str (and D22 map-view Vec[str].get() returning &str, with str not Copy), so they pass &str where str is expected or use str non-Copy if-arms; insert_std_uses additionally makes bare extern calls. Same stale-tool family as #1066/#1067/#1068.

    Tested.

    Source main @ 5809ac1 (2026-09-14); the four tools predate 450733e
    Compilers with v0.15.2.1 built from 5809ac1 (staging worktree); a compiler built from 450733e with the nightly-20260903 seed (spot-checked materialize_predicate, same error)
    Platform macOS Darwin 25.6.0 arm64

    Note: these are implicit-main tools, so with check rejects them with "expected declaration" (top-level statements are a CLI-entry form only, §18.5); the real errors surface under with run, as the report used.

    with run tools/<t>.w ..., HEAD:

    tool error (matches report)
    migrate_d22_copy_views.w wrong argument type in call to 'edit_key' — edits.paths.get(i) is &str, param path expects str (:76)
    annotate_receivers.w if would need to copy a 'str', which is not Copy (:59) plus return type mismatch (:51)
    insert_std_uses.w manual extern function call requires unsafe context (:74) plus wrong argument type in call to 'vec_contains' (:101)
    materialize_predicate.w if would need to copy a 'str', which is not Copy (:38, child.push(if arg == "{file}": materialized else: arg))

    Control: tools/rename_rt_libc_externs.w (the report's already-green reference) compiles and runs — it fails only at runtime on a missing input file, confirming the "&str params, clone at the Vec[str].push sink" style is the working pattern.

    Root cause. The read-only ABI change (commit 7d8d085) made &T the borrow form and Vec[str].get()/map lookups return &str (D22), while str is not Copy. Code that fed &str into a str parameter, or produced a str from an if whose arms differ in ownership, no longer type-checks. insert_std_uses separately calls with_fs_read_file (a D30-deprecated with_fs_* extern) outside unsafe. The checker is behaving correctly; the tools are stale. Established by the runs above.

    Severity. Low: internal migration/annotation tools that no longer run. No user-facing impact, but they are dead until migrated.

    Related. #1066/#1067/#1068/#1073 — the same "committed tool rotted" wave. No open PR.

    Recommendation — champion, mechanical (bundle with #1068/#1073). Per the report and the green rename_rt_libc_externs template: change the helpers to take &str parameters and clone only at the Vec[str].push sinks; give the ownership-divergent if expressions a clone on the borrowed arm (the owned(...) / ++ "" idiom); wrap insert_std_uses's extern calls in unsafe or, better, switch to std.fs.read_file. Acceptance criteria: each of the four runs to completion under its canonical invocation; no bare with_fs_* extern remains. A lightweight guard (a with run --check sweep of tools/*.w, or wiring these into a tools-compile lane) would keep the tool set from rotting again.

    Blockers / not tested. Read-only, so nothing fixed; I confirmed the compile failures, not each tool's downstream logic. Linux/Windows not exercised.

  2. ehartford commented on Oct 25, 2026

    @ehartford
    Contributor

    Triage 2026-10-25, with v0.15.3.0 (main a261b65): does not reproduce; all four tools compile.

    $ with check tools/migrate_d22_copy_views.w   # ok
    $ with check tools/annotate_receivers.w       # ok
    $ with check tools/insert_std_uses.w          # ok
    $ with check tools/materialize_predicate.w    # ok
    
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

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions