functions-summaries-closure-reassigned.ts 518 B

1234567891011
  1. // A closure captures `topic`, which is reassigned to a tainted value AFTER the
  2. // closure is defined; the closure runs again after the reassignment. Runtime flow:
  3. // ask#2 result -> topic -> ask#1 instructions. Flow-insensitivity must produce
  4. // ask#2 -> ask#1 (the single env slot unions the reassignment).
  5. const judge = agent("judge");
  6. let topic = "seed";
  7. const go = () => judge.ask<string>(`judge ${topic}`);
  8. await go();
  9. topic = await agent("t").ask<string>("new topic");
  10. const second = await go();
  11. return second;