functions-summaries-reflect-apply.ts 544 B

1234567891011
  1. // Reflect.apply(f, null, [secret]): the same runtime dispatch as f.apply, but here f
  2. // rides in the ARGUMENTS of an unknown call, so the keystone rule pessimistically
  3. // applies it with the receiver-union — the flow should survive (inexact).
  4. // Expected: ask#1 -> ask#2 data inexact; ask#2 -> sink data.
  5. const judge = agent("judge");
  6. const secret = await agent("s").ask<string>("make secret");
  7. function f(x: string): Node<string> {
  8. return judge.ask<string>(`judge ${x}`);
  9. }
  10. const out = await Reflect.apply(f, null, [secret]);
  11. return out;