classes-2-cross-instance-conflation.ts 803 B

123456789101112131415161718
  1. // Cross-instance conflation (sound-by-design over-approximation, per spec residual 6):
  2. // one instance's ctor stores the secret; a DIFFERENT instance is read into ask#2. At
  3. // runtime clean.v is "clean", but all instances of a class conflate into one abstract
  4. // instance, so the analyzer SHOULD emit ask#1 -> ask#2 anyway. This is a regression
  5. // test that the deliberate over-approx edge is present (its absence would signal the
  6. // conflation model broke).
  7. // Expected: source -> ask#1, ask#1 -> ask#2 (conflated instances), ask#2 -> sink.
  8. const secret = await agent("writer").ask<string>("secret");
  9. class Box {
  10. v: string;
  11. constructor(x: string) {
  12. this.v = x;
  13. }
  14. }
  15. new Box(secret);
  16. const clean = new Box("clean");
  17. const out = await agent("reader").ask<string>(`use ${clean.v}`);
  18. return out;