stedolan / ppx_stage

Staged metaprogramming in stock OCaml
MIT License
150 stars 7 forks source link

Scoping of module names in staged functor parameters #10

Open stedolan opened 6 years ago

stedolan commented 6 years ago

Due to how staging is currently implemented for functors, telescoped scopes are broken (i.e. the first argument to a functor is not in scope in the module type of the second, so sharing constraints don't work properly)

OlivierNicole commented 2 months ago

Scoping is also broken in signatures. Consider the following example:

type 'a t

module type M = sig
  val x : 'a t
end

when preprocessed with ppx_stage, results in a scoping error. Adding the flag -dsource to make clear the source of the problem:

[@@@ocaml.ppx.context
  {
    tool_name = "ppx_driver";
    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", "tpf_staged")]
  }]
module Staged_206014691 =
  struct
    let modcontext''_ = Ppx_stage.Internal.empty_modcontext
    module type M  = sig val x : 'a t end
  end
type 'a t
module type M  = sig val x : 'a t end
File "lib/failure.ml", line 4, characters 13-14:
4 |   val x : 'a t
                 ^
Error: Unbound type constructor t