Open pdonadeo opened 7 years ago
ppx_deriving was designed with namespacing in mind; use [@yojson.default None]
everywhere to work around issues like this.
@whitequark thanks for your suggestion but something is going wrong:
File "src/configuration.ml", line 11, characters 45-59:
Error: Attribute `yojson.default' was not used
Any ideas? Maybe the culprit is not ppx_deriving
but the specific filter, yojson
?
@mjambon FYI
In this moment I worked around downgrading ppx_deriving
to 4.1.
@pdonadeo Try [@deriving.yojson.default]
.
@whitequark nope, same error as before :sweat_smile:
File "src/configuration.ml", line 11, characters 45-68:
Error: Attribute `deriving.yojson.default' was not used
Hmm, this might be a ppx_type_conv issue... I'll look at it
Thanks @whitequark. It's not urgent for me, I can happily live with version 4.1 for a while. Do you need a minimal code that stimulate this issue?
That would be helpful
New OPAM switch:
$ opam switch --alias-of=4.04.1 4.04.1-ISSUE-148
$ opam install core ppx_deriving ppx_deriving_yojson
main.ml
:
open Core
type person = {
first_name : string;
last_name : string;
age : (int option [@deriving.yojson.default None]);
} [@@deriving sexp, yojson]
let _ =
Printf.printf "Hello!\n%!"
Compile with:
ocamlbuild -use-ocamlfind \
-cflag -thread -lflag -thread \
-package core -package ppx_deriving_yojson -package ppx_sexp_conv \
main.native
The error is:
File "main.ml", line 7, characters 22-45:
Error: Attribute `deriving.yojson.default' was not used
Command exited with code 2.
Compilation unsuccessful after building 1 target (0 cached) in 00:00:00.
Downgrading compiles again:
$ opam pin add ppx_deriving 4.1
$ ocamlfind ocamlc -thread -i -package ppx_sexp_conv -package ppx_deriving_yojson -package core main.ml > main.inferred.mli
$ cat main.inferred.mli
type person = { first_name : string; last_name : string; age : int option; }
val person_of_sexp : Sexplib.Sexp.t -> person
val sexp_of_person : person -> Sexplib.Sexp.t
val person_to_yojson : person -> Yojson.Safe.json
val person_of_yojson :
Yojson.Safe.json -> person Ppx_deriving_yojson_runtime.error_or
I confirm that this happens also with [@compare]
and [@equal]
.
It seems that it's also triggering errors when other extensions like ppx_blob
are used in the same file. ("Extension `blob' was not translated").
The error is actually raised by ppx_core
that is used by ppx_sexp_conv
.
Indeed, ppx_core
does some sanity checks and reports unused attributes,
not knowing that another non-ppx_core
-based deriver will use them later on.
With @diml, we discussed the possibility to change these errors into warnings
plugged into the AST (i.e. [@@ocaml.ppwarning "some message"]
), and
have a patch ready. However, it does "silence" the issue but does not really
solve it.
Temporary workaroud until ppx_core
is fixed: Add -no-check
to the command line of ppx_sexp_conv
or ppx_jane
.
The latest versions of ppx_driver
(0.9.2) disables the checks by default.
They can be enabled through a new command-line switch, namely -do-check
.
I also have this problem. As a non-ppx expert, how do I add -no-check
to my Makefile-based build?
I also have this problem. As a non-ppx expert, how do I add -no-check to my Makefile-based build?
Find the -pp
or -ppx
flags and add -no-check
after each preprocessor. It should look something like this:
ocamlfind ocamlopt … -pp 'ppx-jane -no-check'
Do I correctly understand that marking ppx_deriving 4.2.x as conflicting with ppx_driver < 0.9.2
would make people's life easier by ruling this bug out?
Probably, but on the other hand it seems impossible to install ppx_driver.0.9.2
on 4.04.2
or 4.05.0
, so this would restrict a lot the potential users of ppx_deriving.4.2
.
@xclerc would you consider releasing 4.04.2 or 4.05.0 versions of ppx_driver with the disabled check?
ppx_driver
only constraints available: [ ocaml-version >= "4.03.0" ]
;
the problem comes from ppx_ast
that, in its v0.9.2 version, uses a function
that does not exist (or rather has a different name) before 4.06.
(I still have to check whether it is the only problem.)
I have this type definition:
It works with version 4.1 but fails in 4.2 with this error:
default
is actually used by yojson but not by sexp. Is this behaviour the expected one? This actually prevents to mix two generators.