merlin icon indicating copy to clipboard operation
merlin copied to clipboard

Incorrect module type from `type-enclosing`

Open liam923 opened this issue 2 months ago • 1 comments

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)

liam923 avatar May 10 '24 15:05 liam923