ppx_deriving icon indicating copy to clipboard operation
ppx_deriving copied to clipboard

ppx_deriving.create: use [Ast_helper.with_default_loc] to derive `create` function with location info

Open arvidj opened this issue 2 weeks ago • 0 comments

I'm not quite sure what I'm doing, but this seems to fix the following issue for me: https://github.com/ocaml/merlin/issues/1910

Here is a test file:

type b = | A [@@deriving enum]

type t = { foo : string } [@@deriving create, make, eq, ord, show, iter]

let () =
  let (t : t) = create ~foo:"test" () in
  let (t' : t) = make ~foo:"test" in
  let (_ : bool) = equal t t' in
  let (_ : int) = compare t t' in
  let (_ : string) = show t in
  let () = iter t in
  ()

With this PR, I can use merlin to jump from the derived functions create, make, etc, to the type declaration with the deriving attribute.

Without, I would just get errors like: merlin-call-locate: 'show' seems to originate from '_none_' whose ML file could not be found.

I've made same fix in all included derivers, perhaps in quite a brutish way. Feedback welcome!

arvidj avatar Dec 05 '25 13:12 arvidj