Skip to content

Commit

Permalink
test: show that uid counters are not restored correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
voodoos committed Nov 27, 2023
1 parent 7bb8ef3 commit cca5bfb
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/analysis/occurrences.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down
37 changes: 37 additions & 0 deletions tests/test-dirs/server-tests/stable-uids.t
Original file line number Diff line number Diff line change
@@ -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 <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 <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

0 comments on commit cca5bfb

Please sign in to comment.