merlin icon indicating copy to clipboard operation
merlin copied to clipboard

Jump to definition: jumps to decl inside recursive modules

Open trefis opened this issue 4 months ago • 1 comments

  • /tmp/test.ml:
    module rec M : sig
      val f : unit -> unit
    end = struct
      let f () = ()
    end
    
    and N : sig
      val foo : unit -> unit
    end = struct
      let foo () = M.f ()
    end
    
    let foo () = M.f ()
    
  • tests:
$ ocamlmerlin single locate -position 10:18 -look-for implementation -filename test.ml < /tmp/test.ml | jq .value
{
  "file": "test.ml",
  "pos": {
    "line": 2,
    "col": 6
  }
}
$ ocamlmerlin single locate -position 13:16 -look-for implementation -filename test.ml < /tmp/test.ml | jq .value
{
  "file": "test.ml",
  "pos": {
    "line": 4,
    "col": 6
  }
}

trefis avatar Oct 21 '25 12:10 trefis

So, of course it's linked to shapes of recursive modules:

 # 0.02 locate - shape_of_path
 initial: M<Test.0> . "f"[value]

 # 0.02 locate - shape_of_path
 reduced: Missing uid

 # 0.02 locate - from_path
 No definition uid, falling back to the declaration uid: Test.4

Surprisingly, the shape of M does looks decent enough:

# module rec M : sig
    val f : unit -> unit
  end = struct
    let f () = ()
  end
  
  and N : sig
    val foo : unit -> unit
  end = struct
    let foo () = M.f ()
  end
  
  ;;
{} {}
{
 "M"[module] -> {
                 "f"[value] -> <.59>;
                 };
 "N"[module] -> {
                 "foo"[value] -> <.60>;
                 };
 }

We probably fail to find that shape in the environment.

voodoos avatar Oct 21 '25 15:10 voodoos