From 10a8a7ce0f6c492fb578ca291a07d4f339110e23 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Mon, 10 Apr 2023 16:31:16 -0400 Subject: [PATCH] fix(CCParse): fix issue in `recurse` recursively parsing a slice means we temporarily switch the state to the slice; but once the sub-parser returns we need to switch back to the old state. --- src/core/CCParse.ml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/core/CCParse.ml b/src/core/CCParse.ml index 3e690f57..e1d76178 100644 --- a/src/core/CCParse.ml +++ b/src/core/CCParse.ml @@ -1,4 +1,3 @@ - open CCShims_ module Memo_tbl = Hashtbl.Make (struct @@ -300,11 +299,11 @@ end let recurse slice p : _ t = { run = - (fun _st ~ok ~err -> + (fun st ~ok ~err -> (* make sure these states are related. all slices share the same reference as the initial state they derive from. *) - assert (CCShims_.Stdlib.(_st.cs == slice.cs)); - p.run slice ~ok ~err); + assert (CCShims_.Stdlib.(st.cs == slice.cs)); + p.run slice ~ok:(fun _st x -> ok st x) ~err); } let all =