ocaml / merlin

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

The request for documentation of function argument gives documentation for whole function #1809

Open Kakadu opened 3 months ago

Kakadu commented 3 months ago

I could guess why it works this way, but I believe this may be misleading in some cases. The test should look like that

  $ cat >test2.ml <<EOF
  > (** some doc *)
  > let foo ?(pp=(fun _ _ -> ())) () =
  >   Format.pp_print_list pp Format.std_formatter []
  > EOF
  $ cat test2.ml
  (** some doc *)
  let foo ?(pp=(fun _ _ -> ())) () =
    Format.pp_print_list pp Format.std_formatter []
  $ ocamlc test2.ml

  $ $MERLIN single document -position 3:23 -filename test2.ml < test2.ml
  {
    "class": "return",
    "value": "some doc",
    "notifications": []
  }
  $ $MERLIN single document -position 3:24 -filename test2.ml < test2.ml
  {
    "class": "return",
    "value": "some doc",
    "notifications": []
  }
  $ $MERLIN single document -position 3:25 -filename test2.ml < test2.ml
  {
    "class": "return",
    "value": "some doc",
    "notifications": []
  }

I reproduced this on 414 branch

voodoos commented 2 months ago

Thanks for the report and the reproduction @Kakadu

This does look like a bug, I don't see why we would report the function documentation when hovering on one of it's parameter usages.