ocaml / merlin

Context sensitive completion for OCaml in Vim and Emacs
https://ocaml.github.io/merlin/
MIT License
1.56k stars 234 forks source link

Exception Not_found in merlin locate #1797

Open btjorge opened 2 weeks ago

btjorge commented 2 weeks ago

I get a Not_found exception when trying to locate an identifier with merlin 5.1-502 in a dune project.

let: unknown answer: "exception":"Not_found
Raised at Merlin_utils__Std.Option.get in file \"src/utils/std.ml\" (inlined), line 309, characters 14-29
Called from Merlin_analysis__Locate.move_to in file \"src/analysis/locate.ml\", line 293, characters 8-45
Called from Merlin_analysis__Locate.load_cmt in file \"src/analysis/locate.ml\", line 323, characters 6-28
Called from Merlin_analysis__Locate.find_definition_uid.Reduce.read_unit_shape in file \"src/analysis/locate.ml\", lines 547-548, characters 12-51
Called from Ocaml_typing__Shape_reduce.Make.reduce__ in file \"src/ocaml/typing/shape_reduce.ml\", line 179, characters 22-55
Called from Ocaml_typing__Shape_reduce.Make.in_memo_table in file \"src/ocaml/typing/shape_reduce.ml\", line 99, characters 18-23
Called from Ocaml_typing__Shape_reduce.Make.reduce__.reduce in file \"src/ocaml/typing/shape_reduce.ml\" (inlined), line 161, characters 23-36
Called from Ocaml_typing__Shape_reduce.Make.reduce__ in file \"src/ocaml/typing/shape_reduce.ml\", line 195, characters 20-34
Called from Ocaml_typing__Shape_reduce.Make.in_memo_table in file \"src/ocaml/typing/shape_reduce.ml\", line 99, characters 18-23
Called from Ocaml_typing__Shape_reduce.Make.reduce__.reduce in file \"src/ocaml/typing/shape_reduce.ml\" (inlined), line 161, characters 23-36
Called from Ocaml_typing__Shape_reduce.Make.reduce__ in file \"src/ocaml/typing/shape_reduce.ml\", line 195, characters 20-34
Called from Ocaml_typing__Shape_reduce.Make.in_memo_table in file \"src/ocaml/typing/shape_reduce.ml\", line 99, characters 18-23
Called from Ocaml_typing__Shape_reduce.Make.reduce_for_uid in file \"src/ocaml/typing/shape_reduce.ml\", line 328, characters 13-26
Called from Merlin_analysis__Locate.find_definition_uid in file \"src/analysis/locate.ml\", line 562, characters 16-47
Called from Merlin_analysis__Locate.from_path in file \"src/analysis/locate.ml\", line 607, characters 19-62
Called from Query_commands.dispatch in file \"src/frontend/query_commands.ml\", line 537, characters 16-69
Called from Merlin_commands__New_commands.run in file \"src/commands/new_commands.ml\", line 93, characters 15-53
Called from Merlin_utils__Std.let_ref in file \"src/utils/std.ml\", line 695, characters 8-12
Re-raised at Merlin_utils__Std.let_ref in file \"src/utils/std.ml\", line 697, characters 30-39
Called from Merlin_utils__Misc.try_finally in file \"src/utils/misc.ml\", line 45, characters 8-15
Re-raised at Merlin_utils__Misc.try_finally in file \"src/utils/misc.ml\", line 62, characters 10-24
Called from Stdlib__Fun.protect in file \"fun.ml\", line 34, characters 8-15
Re-raised at Stdlib__Fun.protect in file \"fun.ml\", line 39, characters 6-52
Called from Merlin_kernel__Mocaml.with_state in file \"src/kernel/mocaml.ml\", line 18, characters 8-38
Re-raised at Merlin_kernel__Mocaml.with_state in file \"src/kernel/mocaml.ml\", line 20, characters 42-53
Called from Dune__exe__New_merlin.run.(fun) in file \"src/frontend/ocamlmerlin/new/new_merlin.ml\", lines 106-107, characters 14-50
"

Steps to reproduce

$ opam install dune.3.16.0 merlin.5.1-502 why3.1.7.2

$ cat > dune-project <<EOF
(lang dune 3.16)
EOF

$ cat > dune <<EOF
(executable
 (name test)
 (libraries why3))
EOF

$ cat > test.ml <<EOF
let _ = Why3.Whyconf.read_config None
EOF

$ dune build

Then trying to locate Why3.Whyconf.read_config with emacs merlin-mode or ocamlmerlin single locate -log-file - -filename test.ml -position 1:30 -look-for ml < test.ml gives the previous exception and backtrace

voodoos commented 2 weeks ago

Thanks for you detailed report, I was able to reproduce. We will have a look.