lean4
lean4 copied to clipboard
fix: accidental ownership with specialization
The old compiler tried to avoid borrowing that could inhibit mutual TCO, but the implementation was wrong and in an unnecessary way:
ownVaris called but it can only mark variables of the current function, so the wrong variable was marked- there was no mutual recursion as the additional declaration came from specialization
- the old compiler only supports TCO for self-calls anyway
Thus we restrict the borrow inhibition to self-calls. More extensive TCO could be considered in the new compiler.
Fixes #4240
!bench
Here are the benchmark results for commit e8981f68836d1fda671b6b3923c58662edd004e9. The entire run failed. Found no significant differences.
!bench
Mathlib CI status (docs):
- ❌ Mathlib branch lean-pr-testing-4269 built against this PR, but testing failed. (2024-05-24 17:43:22) View Log
- ❌ Mathlib branch lean-pr-testing-4269 built against this PR, but testing failed. (2024-05-24 18:47:32) View Log
Here are the benchmark results for commit d565cc5581221e1b6c00ef920c53f172f74517df. There were significant changes against commit b0c1112471a3f38859d9738184d21132b7d9cd0c:
Benchmark Metric Change
==============================================
- parser instructions 20.1% (13154.3 σ)
- parser task-clock 26.7% (11.8 σ)
- parser wall-clock 26.7% (11.8 σ)
- qsort instructions 4.3% (3149.6 σ)
+ stdlib type checking -2.9% (-58.8 σ)
We deemed the parser-specific slowdown (which effectively must be random chance given that the removed heuristic did not do what it intended to do) acceptable in exchange for a clear fix to the code and a modest overall stdlib boost.