functions-summaries-default-param-earlier.ts 516 B

1234567891011
  1. // Default parameter referencing an EARLIER parameter: f(secret) leaves b to default
  2. // to a, so secret flows a -> b -> ask#2. The initializer is evaluated in the
  3. // function's own context where `a` is the param-0 placeholder.
  4. // Expected: ask#1 -> ask#2 data exact; ask#2 -> sink data exact.
  5. const judge = agent("judge");
  6. const secret = await agent("s").ask<string>("secret");
  7. function f(a: string, b: string = a): Node<string> {
  8. return judge.ask<string>(`judge ${b}`);
  9. }
  10. const out = await f(secret);
  11. return out;