ppx_deriving_yojson icon indicating copy to clipboard operation
ppx_deriving_yojson copied to clipboard

Bad (inexistent) error location

Open lambdalex-ocp opened this issue 7 months ago • 2 comments

Hello,

I'm adding ppx_deriving_yojson into a large project, and sadly at some point, it reports errors at line 1, which we guess is the default location. It makes fixing the errors borderline impossible :(

lambdalex-ocp avatar Sep 26 '25 12:09 lambdalex-ocp

Sorry about that. Would you have a repro case to test?

gasche avatar Sep 26 '25 14:09 gasche

I'll look into this as I think it's just a matter of generating code with a sensible location. A good place to start would be to make the generated code point to the [@@deriving ...] attribute or the type declaration as is done in other derivers.

I think a typical example of when this bites is something like:

type t = M.t
[@@deriving yojson]

which generates code that relies on M.to_yojson being present. If it's not, the compiler will report the error with the location of the generated code.

I'll add a test case for this as well.

NathanReb avatar Sep 29 '25 08:09 NathanReb