heap-aliasing-nested-ternary-alias-write.ts 1.0 KB

1234567891011121314151617
  1. // SYNTACTICALLY nested conditional place: the inner ternary is an ARM of the outer one,
  2. // so its place wrapper lands directly in the outer wrapper's may-alias set. Divergence
  3. // repro: that wrapper used to be rebuilt every fixpoint pass, defeating the identity dedup
  4. // the may-alias union relies on, and the analysis ran to ITERATION_CAP. (The chained form
  5. // `a = flag ? b : c; d = flag2 ? a : e` converged only because binding `a` to an env slot
  6. // made its wrapper persistent by accident — heap-aliasing-chained-ternary-alias-write.)
  7. // Conditional places are now canonical per ternary node.
  8. // Expected: ask#1 -> ask#2 data inexact (the write may land on any of the three boxes);
  9. // ask#2 -> sink.
  10. const box1: { p: string } = { p: "" };
  11. const box2: { p: string } = { p: "" };
  12. const box3: { p: string } = { p: "" };
  13. const flag = Math.random() > 0.5;
  14. const flag2 = Math.random() > 0.5;
  15. const x = flag2 ? (flag ? box1 : box2) : box3;
  16. x.p = await agent("writer").ask<string>("secret");
  17. return agent("reader").ask<string>(`use ${box1.p} and ${box2.p} and ${box3.p}`);