My quick suspicion is that this isn’t specific to ppx_deriving_yojson’s strict
flag, but rather about the placement of [@@deriving]
attributes in recursive type declarations.
In ppxlib, the deriver is given all the type declarations in a set of mutual declarations simultaneously as a list, so only the [@@deriving]
attribute after all of them would actually derive for all the types in the set, if I remember correctly. I don’t know if the intermediate attribute is even handled in such case.
Maybe the old ppx_deriving transformation somehow worked differently. I think I have only ever seen the attribute attached to the entire set, which is also what ppx_deriving_yojson tests show: ppx_deriving_yojson/src_test/test_ppx_yojson.ml at 61f2d63138ec1efea0a3fb4afa682f40497ec380 · ocaml-ppx/ppx_deriving_yojson · GitHub.
EDIT: Indeed ppx_deriving transformation has some interesting logic around this: ppx_deriving/src/api/ppx_deriving.cppo.ml at 32f7c31ecfcbca6d53f3655a00e8852f4751123e · ocaml-ppx/ppx_deriving · GitHub and ppx_deriving/src/api/ppx_deriving.cppo.ml at 32f7c31ecfcbca6d53f3655a00e8852f4751123e · ocaml-ppx/ppx_deriving · GitHub,
Basically, if any declaration in the set has the attribute, the entire set is derived and the attributes of all of them are concatenated and used for each declaration.