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: Custom Indexing Operators are sometimes re-ordered #972

Closed
mseri opened this issue Aug 16, 2019 · 0 comments · Fixed by #975
Closed

Bug: Custom Indexing Operators are sometimes re-ordered #972

mseri opened this issue Aug 16, 2019 · 0 comments · Fixed by #975
Assignees

Comments

@mseri
Copy link

mseri commented Aug 16, 2019

Describe the bug
ocamlformat moves around the extended indexing operators (https://caml.inria.fr/pub/docs/manual-ocaml/manual042.html) if the module containing them is not open in a bigger scope. I attach here the diff from a recent owl example, and below a small repro:

-        sol_planets.Mat.${[ []; [ 3*i ] ]}
-        sol_planets.Mat.${[ []; [ 3*i + 1 ] ]};
-
+        (Mat.( .${} ) sol_planets [ []; [ 3 * i ] ])
+        (Mat.( .${} ) sol_planets [ []; [ (3 * i) + 1 ] ]);

How to Reproduce
Steps to reproduce the behavior:

  • What is the formatted file? Please try to minimize the code snippet.

The following code

open Owl

let () =
  let m = Mat.zeros 5 5 in
  m.Mat.${[[2];[5]]} |> ignore;
  let open Mat in
  m.${[[2];[5]]} |> ignore;

produces the following diff:

@@ -2,6 +2,6 @@ open Owl
 
 let () =
   let m = Mat.zeros 5 5 in
-  m.Mat.${[[2];[5]]} |> ignore;
+  Mat.( .${} ) m [ [ 2 ]; [ 5 ] ] |> ignore;
   let open Mat in
-  m.${[[2];[5]]} |> ignore;
+  m.${[ [ 2 ]; [ 5 ] ]} |> ignore
  • What are the selected options?

My .ocamlformat file is:

profile=janestreet
wrap-comments=false
let-binding-spacing=sparse

The option --print-config prints the configuration on the standard output, please put the result of this command in the report if you are not sure which option causes the issue.

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

Successfully merging a pull request may close this issue.

2 participants