ocaml / merlin

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

Incorrect module type from `type-enclosing` #1763

Open liam923 opened 5 months ago

liam923 commented 5 months ago

With test.ml having contents:

include struct
  open struct
    let hidden = 3
  end
  let visible = 4
end

I get the following unexpected behavior:

$ ocamlmerlin single type-enclosing -position 6:0 < scratch/test.ml | jq '.value[].type'
"sig val hidden : int val visible : int end"
"sig val visible : int end"

Although the correct type is included in the returned list, in VSCode with the OCaml Platform extension (I haven't tested other editors), the incorrect sig val hidden : int val visible : int end module type is shown.

Note that this error does not occur with the following similar programs:

module Foo = struct
  let hidden = 3
end

include struct
  open Foo
  let visible = 4
end
$ ocamlmerlin single type-enclosing -position 8:0 < scratch/test.ml | jq '.value[].type'
"sig val visible : int end"
include struct
  module Foo = struct
    let hidden = 3
  end
  open Foo
  let visible = 4
end
$ ocamlmerlin single type-enclosing -position 7:0 < scratch/test.ml | jq '.value[].type'
"sig module Foo : sig val hidden : int end val visible : int end"

Version: 9afb03689bc500fed0f18d612f3b13ad668e2455 (master at the time of creating this)

voodoos commented 5 months ago

That's surprising, and definitely a bug, thanks for the report.