ppxlib icon indicating copy to clipboard operation
ppxlib copied to clipboard

Compiler error with OCaml 5.2.0 and an identity ppx

Open Octachron opened this issue 2 years ago • 2 comments

Using the ppxlib preview for OCaml 5.2.0 leads to a compiler error appearing even for an identity ppx in the following configuration:

  • value.ml:
  type t
  • symbol.ml
   type t = private Value.t
  • main.ml
let f x = (x:Symbol.t :> Value.t)

(See https://github.com/Octachron/bug-reproduction-archives/tree/main/ppxlib_and_include for a full reproduction case)

The error disappear either when the identity ppx is not included, or when switching to a handwritten ppx.

Octachron avatar Feb 20 '24 13:02 Octachron

ppxlib seems to rewrite

let f x = (x:Symbol.t :> Value.t)

into

let f x : Symbol.t:> Value.t= (x : Symbol.t  :> Value.t)

Here is the command I ran with your repro repo

$ ocamlc -dsource _build/default/src/form.pp.ml 
[@@@ocaml.ppx.context
  {
    tool_name = "ppx_driver";
    include_dirs = [];
    hidden_include_dirs = [];
    load_path = ([], []);
    open_modules = [];
    for_package = None;
    debug = false;
    use_threads = false;
    use_vmthreads = false;
    recursive_types = false;
    principal = false;
    transparent_modules = false;
    unboxed_types = false;
    unsafe_string = false;
    cookies = [("library-name", "x")]
  }]
let f x : Symbol.t:> Value.t= (x : Symbol.t  :> Value.t)
File "src/form.ml", line 1, characters 14-22:
1 | let f x = (x: Symbol.t :> Value.t)
                  ^^^^^^^^
Error: Unbound module Symbol

hhugo avatar Feb 20 '24 14:02 hhugo

thanks @hhugo! @gasche it looks like you had the right idea too in https://github.com/ocaml/ocaml/issues/12982#issuecomment-1954405646

kit-ty-kate avatar Feb 20 '24 17:02 kit-ty-kate

I'm closing this as it's been fixed on trunk-support

NathanReb avatar Apr 15 '24 09:04 NathanReb