merlin icon indicating copy to clipboard operation
merlin copied to clipboard

Jump to definition with let-punning

Open liam923 opened this issue 1 year ago • 1 comments

Consider the program:

let (let+) x f = List.map f x

let f x =
  let+ x in
  x

Locating x on line 4 gives:

$ ocamlmerlin single locate -position 4:7 -filename test.ml < test.ml | jq .value
"Already at definition point"

In my opinion, for this command it would be better to treat x as the variable bound on line 3 rather than the one on line 4. I believe that if a user is querying the definition point of x on line 4, they likely want the definition that isn't on that line.

liam923 avatar Jul 08 '24 19:07 liam923

Yes I agree, there is a similar frustrating thing happening when asking for the definition of punned record arguments (but in that case it is less clear which is the correct answer).

It suspect that the interesting node is given a ghost location, so Merlin chooses the other one.

voodoos avatar Jul 09 '24 14:07 voodoos