heap-aliasing-index-assign-adopt.ts 418 B

12345678
  1. // Alias established through a container-field ASSIGNMENT (not a literal element):
  2. // `slots[0] = box` must share the reference, so `slots[0].f = secret` mutates box.f.
  3. // Expected: ask#1 -> ask#2 data; ask#2 -> sink.
  4. const box: { f: string } = { f: "" };
  5. const slots: { f: string }[] = [];
  6. slots[0] = box;
  7. slots[0]!.f = await agent("writer").ask<string>("secret");
  8. return agent("reader").ask<string>(`use ${box.f}`);