Give each callable type its own `PyTrait::py_call`
Merged
RE
3mo ago+428+428+012345678901234567890123456789-161-161-012345678901234567890123456789
VM::call_heap_callable had grown into a hundred-line match over HeapData, one arm per callable type. py_call is added to PyTrait.
Closure, FunctionDefaults and ExtFunction gain the PyTrait impls they never had.
Note:py_call holds its HeapRead across the dispatch.
🤖 Generated with Claude Code
Summary by cubic
Moves callable dispatch out of a single match over heap callables into PyTrait::py_call, implemented by each callable type in its own module. No behavior change is intended; Closure, FunctionDefaults, and ExtFunction gain the PyTrait impls they previously lacked.
Refactors
- The trait default raises the same
TypeErrorfor non-callables the rejected match arm raised, while dropping the call's arguments. - A callable that dispatches onward holds its
HeapReadacross the nested call, which callers' own references make safe. - Regression tests cover leaking arguments on the non-callable
TypeErrorpath and the partial chainRecursionErrorbail-out path.