aboutsummaryrefslogtreecommitdiff
path: root/lib/syntax/check.ml
diff options
context:
space:
mode:
authorChimrod <>2023-11-03 10:19:29 +0100
committerChimrod <>2023-11-03 10:19:29 +0100
commit180529c30282d39f3506633716e3fe439db03309 (patch)
tree4535ffa8574c2caf62ee087ca4e52d1db1e9e3d5 /lib/syntax/check.ml
parentfd02a44392304986a756e7d06f8142538b386529 (diff)
Extracting the report from the Location checker is now in it’s own function
Diffstat (limited to 'lib/syntax/check.ml')
-rw-r--r--lib/syntax/check.ml24
1 files changed, 19 insertions, 5 deletions
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