heap-aliasing-cyclic-self.ts 420 B

1234567891011
  1. // Cyclic structure: `a.self = a` makes the abstract value genuinely cyclic. The
  2. // write through a.self!.self! lands on `a` itself; convergence AND flow must hold.
  3. // Expected: no crash; ask#1 -> ask#2 data; ask#2 -> sink.
  4. interface Rec {
  5. f: string;
  6. self?: Rec;
  7. }
  8. const a: Rec = { f: "" };
  9. a.self = a;
  10. a.self!.self!.f = await agent("writer").ask<string>("secret");
  11. return agent("reader").ask<string>(`use ${a.f}`);