ocaml-ppx / ppxlib

Base library and tools for ppx rewriters
MIT License
246 stars 98 forks source link

Compiler error with OCaml 5.2.0 and an identity ppx #477

Closed Octachron closed 5 months ago

Octachron commented 7 months ago

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

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

hhugo commented 7 months ago

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
kit-ty-kate commented 7 months ago

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

NathanReb commented 5 months ago

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