From bc467468a9fb9ece00bc1337d77031c654c07d37 Mon Sep 17 00:00:00 2001 From: "carpentry-heartbeat[bot]" Date: Mon, 18 May 2026 19:17:53 +0200 Subject: [PATCH 1/2] Fix reference lifetime error in diff inner loop 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 --- diff.carp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/diff.carp b/diff.carp index 313388e..6ef6df2 100644 --- a/diff.carp +++ b/diff.carp @@ -27,14 +27,13 @@ (Array.unsafe-nth new inew) &[])] (for [i 0 (Array.length ol)] - (let-do [iold @(Array.unsafe-nth ol i)] - (set! _overlap - (Map.put _overlap - &iold - &(Int.inc + (let-do [iold @(Array.unsafe-nth ol i) + new-val (Int.inc (if (/= iold 0) (Map.get &overlap &(Int.dec iold)) - iold)))) + iold))] + (set! _overlap + (Map.put _overlap &iold &new-val)) (when-do (> (Map.get &_overlap &iold) sl) (set! sl (Map.get &_overlap &iold)) (set! sso (Int.inc (- iold sl))) From 7e61038b779f98766b50c5299d5240da41b703e5 Mon Sep 17 00:00:00 2001 From: Veit Heller Date: Tue, 19 May 2026 02:16:30 +0200 Subject: [PATCH 2/2] style: reformat diff.carp with carp-fmt --- diff.carp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/diff.carp b/diff.carp index 6ef6df2..1996ff5 100644 --- a/diff.carp +++ b/diff.carp @@ -29,11 +29,8 @@ (for [i 0 (Array.length ol)] (let-do [iold @(Array.unsafe-nth ol i) new-val (Int.inc - (if (/= iold 0) - (Map.get &overlap &(Int.dec iold)) - iold))] - (set! _overlap - (Map.put _overlap &iold &new-val)) + (if (/= iold 0) (Map.get &overlap &(Int.dec iold)) iold))] + (set! _overlap (Map.put _overlap &iold &new-val)) (when-do (> (Map.get &_overlap &iold) sl) (set! sl (Map.get &_overlap &iold)) (set! sso (Int.inc (- iold sl)))