heap-aliasing-param-literal-wrap.ts 489 B

12345678910
  1. // The callee writes through a SUB-OBJECT of its parameter; the caller's argument is
  2. // a literal wrapping the live box, so at runtime p.box === box and box.f receives
  3. // ask#1's output on every execution.
  4. // Expected: ask#1 -> ask#2 data; ask#2 -> sink.
  5. const box: { f: string } = { f: "" };
  6. async function poke(p: { box: { f: string } }): Promise<void> {
  7. p.box.f = await agent("writer").ask<string>("secret");
  8. }
  9. await poke({ box });
  10. return agent("reader").ask<string>(`use ${box.f}`);