heap-aliasing-literal-capture-mutate.ts 357 B

1234567
  1. // An object literal captures a live place; mutation THROUGH the literal's field
  2. // must stay visible through the original name.
  3. // Expected: ask#1 -> ask#2 data; ask#2 -> sink.
  4. const box: { f: string } = { f: "" };
  5. const wrap = { inner: box };
  6. wrap.inner.f = await agent("writer").ask<string>("secret");
  7. return agent("reader").ask<string>(`use ${box.f}`);