We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5e2b2ea commit 5b090f5Copy full SHA for 5b090f5
1 file changed
src/phl/ecPhlLoopTx.ml
@@ -362,7 +362,11 @@ let process_unroll_for ~cfold side cpos tc =
362
let tcenv = FApi.t_onalli doi tcenv in
363
364
if cfold then begin
365
- let cpos = EcMatching.Position.Notations.(cpos <+| 1) in
+ (* Use normalized position: pos - 1 is the loop counter initialization
366
+ assignment that immediately precedes the while loop at pos.
367
+ We cannot reuse the original match-based cpos here because t_doit
368
+ has transformed the code, potentially invalidating the match. *)
369
+ let cpos = ([], EcMatching.Position.cpos1 (pos - 1)) in
370
let clen = blen * (List.length zs - 1) in
371
372
FApi.t_last (EcPhlCodeTx.t_cfold ~eager:false side cpos (Some clen)) tcenv
0 commit comments