heap-literal-arg-writeback.ts 849 B

1234567891011121314
  1. // The callee writes a NEW field on its parameter and hands the object back; the caller's
  2. // argument is an inline literal — storage with no name of its own. The note written through
  3. // the parameter must be readable through the returned reference.
  4. // Expected: ask#1 -> ask#2 data (through r.note); ask#2 -> sink.
  5. // Convergence pin: while a literal was a per-pass fresh value this never converged — the
  6. // parameter write-back landed on storage recreated every pass and re-reported a change forever
  7. // (docs/analysis.md, "Convergence": literals are allocation-site places).
  8. function tag(box: { name: string; note?: string }, t: string): { name: string; note?: string } {
  9. box.note = t;
  10. return box;
  11. }
  12. const t = await agent("writer").ask<string>("draft");
  13. const r = tag({ name: "x" }, t);
  14. return agent("reader").ask<string>(`use ${r.note}`);