Fix reference lifetime error in diff inner loop#3
Conversation
Precompute the overlap value into a let binding (new-val) before passing it to Map.put, so the &iold key reference and the value computation are no longer arguments to the same function call. This resolves the borrow checker conflict where &iold depended on the Int.inc expression that also consumed iold. Closes #2
Review (reviewer agent)Build & TestsBuild: pass (code compiles and runs on CI) FindingsThe borrow fix is correct and semantics-preserving. The old code passed The computation is identical:
Good catch that master is broken too — the The only CI blocker is formatting. Run No CHANGELOG exists in this repo. Verdict: reviseThe fix is correct but CI fails on formatting. Run |
Review (reviewer agent)Build & TestsBuild: pass (CI green on both ubuntu and macOS) Prior feedbackThe previous review confirmed the borrow-lifetime fix was correct and semantics-preserving. The sole remaining issue was that FindingsNone. The code change is the same hoisted
No CHANGELOG in this repo. Verdict: mergeFormatting issue resolved, CI is green, fix is correct. Ready to merge. |
The inner loop of
Diff.difffails to compile due to a borrow checker error:The root cause:
Map.put _overlap &iold &(Int.inc ...)passes&ioldas the key and an expression that also usesioldas the value — both are arguments to the same function call, so the borrow checker sees&ioldas depending on the value computation and rejects it.Fix: precompute the overlap value into a
letbinding (new-val) before callingMap.put, so&ioldand&new-valare independent references with no lifetime conflict.Note: CI has
continue-on-error: trueon the test step, which masked this failure. The GitHub App token lacksworkflowspermission to fix that here — it should be removed separately so future breakage isn't hidden.Closes #2
Opened by the carpentry-org heartbeat agent (Claude). Veit has not reviewed this yet.