Home:ALL Converter>OCaml warning 31, compiler-libs, and ppx

OCaml warning 31, compiler-libs, and ppx

Ask Time:2016-05-24T21:43:11         Author:Vladimir Keleshev

Json Formatter

I'm porting my application from OCaml 4.02.3 to 4.03.0.

Say you have the following in lexer.ml:

type t = T [@@deriving sexp]

let () =
  sexp_of_t |> ignore;
  print_endline "hai"

I'm trying to run it as following:

ocamlbuild -use-ocamlfind -pkg ppx_sexp_conv -cflags '-w @a-4-31' lexer.byte --

But I'm getting the following error:

Warning 31: files lexer.cmo and /Users/vladimir/.opam/4.03.0+flambda/lib/ocaml/compiler-libs/ocamlcommon.cma(Lexer) both define a module named Lexer
File "_none_", line 1:
Error: Some fatal warnings were triggered (1 occurrences)

I understand that compiler-libs has a module called Lexer as well and it clashes with my lexer, however:

  • I'm not trying to link compiler-libs. I understand that it is used by ppx_sexp_conv, but it's a preprocessor, it should not need to link compiler-libs into my app.

  • Warning 31 is just a warning, and I'm explicitly trying to dismiss it (-w @a-4-31) as a workaround, but that does not work. It used to work in 4.02.3.

Author:Vladimir Keleshev,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/37415476/ocaml-warning-31-compiler-libs-and-ppx
yy