[ty] Keep tuple inference off the stack for other expressions #31427
<!-- generated-comment typing-conformance -->
<!-- report-run:47317509834:1 -->
Typing conformance results
No changes detected ✅
<details>
<summary>Current numbers</summary>
<br>
The percentage of diagnostics emitted that were expected errors held steady at <b>98.60%</b>. The percentage of expected errors that received a diagnostic held steady at <b>98.86%</b>. The number of fully passing files held steady at <b>137/146</b>.
</details>
---
Results for 55cb776 · Workflow run
<!-- generated-comment memory -->
<!-- report-run:47317509520:1 -->
Memory usage report
Memory usage unchanged ✅
---
Results for 55cb776 · Workflow run
<!-- generated-comment ty-ecosystem -->
<!-- report-run:47317509744:1 -->
ecosystem-analyzer results
No diagnostic changes detected ✅
Full report with detailed diff · Timing results
---
Results for 55cb776 · Workflow run
Nice find, thank you.
carljm
MichaReiser
Summary
Tuple inference can build a speculative
TypeInferenceBuilderfor each member of an expected union. When LLVM inlines this code intoinfer_value_expression_impl, every expression reserves that space, including each operand ina + b + c.This PR keeps
infer_tuple_expressionout of line. In a Linux x86-64 profiling build, the dispatcher shrinks from 2,064 to 384 bytes and the total stack per addition falls from 4,656 to 2,976 bytes. This complements the on-demand stack growth in #29077.The semantic unit tests and mdtests pass, and ty now checks a chain of 2,200 method calls that previously overflowed the worker stack.