From 180529c30282d39f3506633716e3fe439db03309 Mon Sep 17 00:00:00 2001 From: Chimrod <> Date: Fri, 3 Nov 2023 10:19:29 +0100 Subject: Extracting the report from the Location checker is now in it’s own function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/syntax/check.ml | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'lib/syntax/check.ml') diff --git a/lib/syntax/check.ml b/lib/syntax/check.ml index 2528914..a7095fc 100644 --- a/lib/syntax/check.ml +++ b/lib/syntax/check.ml @@ -394,11 +394,10 @@ module Make (A : App) = struct type instruction = Instruction.t' type t = result array - let location : S.pos -> instruction list -> t * Report.t list = + let location : S.pos -> instruction list -> t = fun pos args -> ignore pos; - let report = ref [] in let result = Array.init len ~f:(fun i -> let (E { module_ = (module A); instr'; location_witness; _ }) = @@ -406,10 +405,25 @@ module Make (A : App) = struct in let instructions = List.rev (Helper.expr_i args instr' i).values in - let value, re = A.Location.location pos instructions in - report := List.rev_append re !report; + let value = A.Location.location pos instructions in R { value; witness = location_witness }) in - (result, !report) + result + + let v : t -> Report.t list = + fun args -> + let report = ref [] in + let () = + Array.iteri args ~f:(fun i result -> + let (E { module_ = (module A); location_witness; _ }) = + Array.get A.t i + in + match get location_witness result with + | None -> failwith "Does not match" + | Some value -> + let re = A.Location.v value in + report := List.rev_append re !report) + in + !report end end -- cgit v1.2.3