Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Incorrectly added any-pattern into signature of functor #2646

Open
nikolaushuber opened this issue Jan 14, 2025 · 0 comments
Open

Bug: Incorrectly added any-pattern into signature of functor #2646

nikolaushuber opened this issue Jan 14, 2025 · 0 comments

Comments

@nikolaushuber
Copy link

nikolaushuber commented Jan 14, 2025

Describe the bug
ocamlformat seems to insert an any-pattern into the signature of a functor, which results in a syntax error.

How to Reproduce
The following code is accepted by the OCaml compiler:

module type X = sig
  val x : int
end

module M : X -> X =
  functor (X : X) -> struct
    let x = X.x
end 

Following is the output of running ocamlformat on the above code (both if called directly or through dune fmt):

module type X = sig
  val x : int
end

module M : (_ : X) -> X =
functor
  (X : X)
  ->
  struct
    let x = X.x
  end

This results in the following error when trying to compile with OCaml:

File "example/mini_example.ml", line 5, characters 12-13:
5 | module M : (_ : X) -> X =
                ^
Error: Syntax error

I am using version 0.27.0 of ocamlformat, and 5.2.1 of OCaml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant