Skip to content

STDLIB-04a: Mut effect externs (make_ref / get / set) → real implementations #328

@hyperpolymath

Description

@hyperpolymath

Tracking issue for STDLIB-04a — first of five row-splits of the umbrella STDLIB-04 ledger item (docs/TECH-DEBT.adoc:162, Refs #175).

Scope

The Mut effect's externs in stdlib/effects.affine:

extern fn make_ref<T>(x: T) -> Ref<T> / Mut;
extern fn get<T>(r: Ref<T>) -> T / Mut;
extern fn set<T>(r: Ref<T>, x: T) -> Unit / Mut;

Current state (audit)

Per the 2026-05-24 audit, all three are stubs: surface syntax exists in js_codegen.ml (~line 144) for ref/deref/set operators, but no real wasm refcell type or host-import lowering is wired. Hermetic round-trip (make_ref → set → get) is unproven on all backends.

Acceptance

  • make_ref(x) allocates a real cell (wasm GC struct or host-side box per backend)
  • get(r) reads, set(r, x) writes, with Mut effect tracked end-to-end
  • Hermetic e2e test (round-trip + aliasing) added under test/
  • AOT gate stays green
  • CAPABILITY-MATRIX + TECH-DEBT updated in the same PR

Severity / class

S3 (polish, per STDLIB-04 sev). Affects: lib/codegen_*.ml, lib/interp.ml, stdlib AOT gate.

Refs #175.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions