Wrap a lambda so each invocation is counted against `recursionLimit`: a * runaway user-function recursion (`f(x) := … f(x-1) …` with no reachable base * case) throws a `CancellationError` (`cause: 'recursion-depth-exceeded'`) * instead of overflowing the native JS call stack with a `RangeError`.
( ce: ComputeEngine, fn: (params: ReadonlyArray<Expression>) => Expression | undefined )
| 433 | * The canonical body of such a literal reads each parameter as a possible |
| 434 | * number, so it may have folded `x/x` to `1`, and it types its result from |
| 435 | * that reading. A binder over elements that are not numbers must not apply |
| 436 | * that body: the parameter takes the element type, and the body is |
| 437 | * canonicalized again from this written form with that type, as an inline |
| 438 | * literal is. For the values of a VALUE KIND |
| 439 | * (`Map(f, [ResidueClass(2, 4), ResidueClass(3, 4)])`, with `f` boxed before |
| 440 | * the call) the folded body gave a wrong value |
| 441 | * (`docs/plans/2026-10-26-value-kinds.md`, section 4.2, decision B). For rows |
| 442 | * (`Scan([[1, 2], [3, 4]], f, 0)` with `f = (a, t) ↦ a + t`) the body typed |
| 443 | * the running sum as a number, so the scan was typed as a list of numbers. |
| 444 | * |
| 445 | * `scope` is the lexical scope in which `x` was canonicalized. The written |
| 446 | * form must be canonicalized again in that scope, not in the scope of the |
| 447 | * caller: a free name of the body (`k` in `x ↦ k·x`) is then bound to the |
| 448 | * definition that `x` reads, also when the scope of the caller declares |
| 449 | * another `k`. |
| 450 | */ |
no test coverage detected