janestreet / ppx_sexp_conv

Generation of S-expression conversion functions from type definitions
MIT License
88 stars 17 forks source link

"Attribute `deriving' was not used" unless ppx_jane used #15

Closed kevinqiu closed 4 years ago

kevinqiu commented 7 years ago

Hi, I'm trying to use ppx_sexp_conv with ocamlfind and am running into issues when I try to include other Janestreet ppx. It works if I am just using ppx_sexp_conv but attempting to include ppx_assert in compilation (without even using it), results in Error: Attribute 'deriving' was not used. It looks like this issue is related: https://github.com/janestreet/ppx_let/issues/5 But adding -no-check doesn't seem to work. Using ppx_jane works but I'm not sure why and want to know what I'm doing wrong when I'm not using it.

Code:

open Core
module Test = struct
  type t = (string * string) [@@deriving sexp]
end

Build command that fails. I added the all the -ppxopt bits per the issue above, but it is still broken with those:

ocamlfind ocamlc -linkpkg -thread -package core,ppx_sexp_conv,ppx_assert -ppxopt "ppx_assert,-no-check" -ppxopt "ppx_driver,-no-check" -ppxopt "ppx_sexp_conv,-no-check" -ppxopt "core,-no-check" test.ml -o test.byte

Build command that works(by adding ppx_jane):

ocamlfind ocamlc -linkpkg -thread -package core,ppx_jane,ppx_sexp_conv,ppx_assert test.ml -o test.byte
ghost commented 7 years ago

What versions of Jane Street ppx rewriters are you using?

kevinqiu commented 7 years ago

Ah yes, sorry, should have included that:

OCaml: 4.04.2 core: v0.9.1 ppx_sexp_conv: v0.9.0 ppx_assert: v0.9.0 ppx_jane: v0.9.0 ppx_driver: v0.9.1 ppx_deriving: 4.1

I noticed in a perhaps related issue, https://github.com/janestreet/ppx_type_conv/issues/6, you mentioned including ppx_jane in utop enabled the ppx_type_conv ppx_deriving compatibility layer. What is the mechanism by which it does that? It wasn't immediately apparent looking at the repo. Do I need to do that here?

kevinqiu commented 7 years ago

I found a different workaround that might be illuminating as to what is going on here.

I was not actually passing the --no-check option to ppx_assert because of the introduction of deprecated-ppx-method.

So this works now:

ocamlfind ocamlc -linkpkg -thread -package core,ppx_sexp_conv,ppx_assert -ppxopt "ppx_assert.deprecated-ppx-method,-no-check" test.ml -o test.byte

But it seems strange that ppx_assert would need that directive. Is it somehow invoking ppx_driver? Adding another ppx like ppx_inline_test causes the same error again and adding -no-check to ppx_inline_test fixes it.

ghost commented 7 years ago

Hmm, that doesn't seems right indeed. Basically when you do -package ppx_assert, this gets translated to a -ppx <somedir>/ppx.exe option. This ppx.exe uses ppx_driver but in a special mode to apply a single transformation. Checks should be disabled in this mode

aalekseyev commented 4 years ago

I don't know if this is still an issue and what package the issue is in (it's probably in ppx_driver, which itself is deprecated). I'm closing it because it's old. Feel free to re-open if it's still a problem.