yomimono / ppx_deriving_crowbar

a ppx_deriving plugin for crowbar generators
MIT License
21 stars 4 forks source link

ppx_deriving_crowbar emits unused `rec` flags #1

Open yomimono opened 6 years ago

yomimono commented 6 years ago

Easiest fix is probably to surround our generated blocks with annotations disabling warning 39.

yomimono commented 6 years ago

We already surround with [@ocaml.warning -A], but when the user's provided their own generator, we don't put it in the right place:

type t = (int * int * int) [@generator Crowbar.(map [uint8; uint8; uint8] (fun a b c -> a, b, c))]
[@@deriving crowbar]

generates

let rec to_crowbar : t Crowbar.gen Lazy.t =
  let __0 () =
    let open Crowbar in
      map [uint8; uint8; uint8] (fun a -> fun b -> fun c -> (a, b, c)) in
  ((let open! Ppx_deriving_runtime in lazy (__0 ()))[@ocaml.warning "-A"])

The annotation isn't added by ppx_deriving_crowbar itself but by ppx_deriving in sanitize, called by us via with_quoter.