merlin icon indicating copy to clipboard operation
merlin copied to clipboard

Occurrences of `None` returns invalid matches from default parameter

Open mattiase opened this issue 3 years ago • 3 comments

Consider the file:

(* test case *)
let f ?(x=1) () = 2 ;;
None

Occurrences on the location of None returns a match at that same position as well as one at an invalid position (line 0, column -1). It appears to be linked to the default argument somehow.

Of course we can filter out matches at invalid positions, either in merlin proper or in whatever code making use of the output (like the Emacs lisp code), but it would be better to to generate them in the first place. Maybe there are more such cases that become apparent if the source of them is found.

mattiase avatar Dec 07 '21 13:12 mattiase

Thank you for the report! I added a test illustrating the issue. A major rework of that feature is planned in a not-so-distant future...

voodoos avatar Dec 17 '21 12:12 voodoos

Thanks – I added a simple filter to the Emacs Xref PR (#1385) for the time being.

I presume you were thinking about making Occurrence project-wide? That would be really nice to have.

mattiase avatar Dec 17 '21 13:12 mattiase

Yes, that is part of the plan :-)

voodoos avatar Dec 17 '21 13:12 voodoos