( call: Node, arg: Node, module: SourceModule, held: Held, params: Relation[] )
| 5694 | // callback, which is unknown unless the build reads it: each parameter |
| 5695 | // holds it by its relation in `params` |
| 5696 | private mayWriteInCallback( |
| 5697 | call: Node, |
| 5698 | arg: Node, |
| 5699 | module: SourceModule, |
| 5700 | held: Held, |
| 5701 | params: Relation[] |
| 5702 | ): Node | undefined { |
| 5703 | if (arg.type === "SpreadElement") return this.escape(call) |
| 5704 | const fn = this.calleeOf(arg, module) |
| 5705 | if (!fn) { |
| 5706 | // e.g. `"a"` or `list.find(Boolean)` |
| 5707 | return ( |
| 5708 | isReadOnlyArg(arg, this.kindOf(arg, module)) || |
| 5709 | this.readsOnly(arg, module) |
| 5710 | ) ? |
| 5711 | undefined |
| 5712 | : this.escape(call) |
| 5713 | } |
| 5714 | // `arguments` aliases each parameter |
| 5715 | if (readsArguments(fn[0])) return this.escape(call) |
| 5716 | for (const [i, param] of runtimeParamsOf(fn[0]).entries()) { |
| 5717 | const isRest = param.type === "RestElement" |
| 5718 | // e.g. `(...args) => args[0].a = 1`, whose parameter holds anything |
| 5719 | const through = |
| 5720 | isRest ? unbounded : heldThrough(held, params[i] ?? "none") |
| 5721 | const write = |
| 5722 | through && |
| 5723 | this.mayWriteThrough(isRest ? param.argument : param, through, fn[1]) |
| 5724 | // one in another module is reported where it's passed |
| 5725 | if (write) { |
| 5726 | return ( |
| 5727 | fn[1] === module ? write |
| 5728 | : this.escapes.has(write) ? this.escape(call) |
| 5729 | : call |
| 5730 | ) |
| 5731 | } |
| 5732 | } |
| 5733 | } |
| 5734 | |
| 5735 | // each use of a value is followed to what holds it next, and any the build |
| 5736 | // doesn't know leaves its value unknown, as code it can't see may write it |
no test coverage detected