From cca5bfbef1e6711f5f271d280ea73360f3ecbed7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulysse=20G=C3=A9rard?= Date: Mon, 27 Nov 2023 19:14:48 +0100 Subject: [PATCH] test: show that uid counters are not restored correctly --- src/analysis/occurrences.ml | 6 +++- tests/test-dirs/server-tests/stable-uids.t | 37 ++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 tests/test-dirs/server-tests/stable-uids.t diff --git a/src/analysis/occurrences.ml b/src/analysis/occurrences.ml index 03464152dc..e0deb05781 100644 --- a/src/analysis/occurrences.ml +++ b/src/analysis/occurrences.ml @@ -43,7 +43,7 @@ let index_buffer ~local_defs () = ~namespace:Shape.Sig_component_kind.Module env (Pident id) end) in - let f ~namespace env path lid = + let f ~namespace env path (lid : Longident.t Location.loc) = let not_ghost { Location.loc = { loc_ghost; _ }; _ } = not loc_ghost in if not_ghost lid then match Env.shape_of_path ~namespace env path with @@ -52,6 +52,10 @@ let index_buffer ~local_defs () = begin match Shape_reduce.reduce_for_uid env path_shape with | Shape.Approximated _ | Missing_uid -> () | Resolved uid -> + log ~title:"index_buffer" "Found %s (%a) wiht uid %a" + (Longident.head lid.txt) + Logger.fmt (Fun.flip Location.print_loc lid.loc) + Logger.fmt (Fun.flip Shape.Uid.print uid); Index_format.(add defs uid (LidSet.singleton lid)) | Unresolved s -> log ~title:"index_buffer" "Could not resolve shape %a" diff --git a/tests/test-dirs/server-tests/stable-uids.t b/tests/test-dirs/server-tests/stable-uids.t new file mode 100644 index 0000000000..0255b3d790 --- /dev/null +++ b/tests/test-dirs/server-tests/stable-uids.t @@ -0,0 +1,37 @@ + $ cat >main.ml <<'EOF' + > let x' = 1 + > let x = 41 + > let f x = x + > let y = f x + > EOF + + $ $MERLIN server occurrences -scope local -identifier-at 3:10 \ + > -log-file log_1 -log-section index \ + > -filename main.ml /dev/null + + $ cat >main.ml <<'EOF' + > let x' = 1 + > let x = 42 + > let f x = x + > let y = f x + > EOF + + $ $MERLIN server occurrences -scope local -identifier-at 3:10 \ + > -log-file log_2 -log-section index \ + > -filename main.ml /dev/null + +FIXME: The uids should be the same on both queries ! + $ cat log_1 | grep Found | cat >log_1g + $ cat log_2 | grep Found | cat >log_2g + $ diff log_1g log_2g + 1,3c1,3 + < Found x (File "main.ml", line 3, characters 10-11) wiht uid Main.3 + < Found f (File "main.ml", line 4, characters 8-9) wiht uid Main.2 + < Found x (File "main.ml", line 4, characters 10-11) wiht uid Main.1 + --- + > Found x (File "main.ml", line 3, characters 10-11) wiht uid Main.7 + > Found f (File "main.ml", line 4, characters 8-9) wiht uid Main.6 + > Found x (File "main.ml", line 4, characters 10-11) wiht uid Main.5 + [1] + + $ $MERLIN server stop-server