-
Notifications
You must be signed in to change notification settings - Fork 122
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
Uninterpreted extension
with ppx rewriter in the same project
#696
Comments
Trying to narrow this down, since it makes it quite difficult to work with ppxs in my monorepo: I added the following here to check if merlin is being invoked with the correct ppx and that the ppx is built: let ppx = config.ocaml.ppx in
List.iter ~f:(fun x ->
let f = List.hd (String.split_on_char ~sep:' ' x.Merlin_utils.Std.workval) in
Printf.eprintf "XXX %s %b\n%!" x.workval (Sys.file_exists f);
) ppx;
Printf.eprintf "XXX %s\n%!" (Merlin_utils.Std.Json.to_string (Mconfig.dump config)); I also added logging to make sure that the diagnostic is actually coming from merlin.
Resulting config:
Unfortunately, everything looks correct. The correct ppx is being passed to merlin, as per dune rules:
The error is the same as running ocaml without a ppx. What could cause merlin to "skip" the ppx, or how could I narrow it down further? |
One thing that would help narrow this down: is it an issue with regular merlin? |
No, with regular merlin the issue doesn't happen. |
Narrowing it down further, I logged the potential exception that is caught in merlin's ppx code (here): let caught = ref [] in
Msupport.catch_errors Mconfig.(config.ocaml.warnings) caught @@ fun () ->
Printf.eprintf "XXX CONFIG IN MPIPELINE: %s\n%!" (Json.to_string (Mconfig.dump config));
let parsetree = Mppx.rewrite config parsetree in
List.iter (fun e -> Printf.eprintf "EXCEPTION: %s\n%!" (Printexc.to_string e)) !caught;
{ Ppx. config; parsetree; errors = !caught } And it prints:
|
Try this fix:
|
In the vendored submodule of merlin in ocamllsp |
Actually, never mind. I think I understand the issue. The scheduler is calling waitpid and that's probably reaping it for the ppx. |
Try #735 and let me know if it fixes the issue. |
I can confirm that #735 fixes the issue for me. |
CHANGES: ## Fixes - Fix preprocessing, ppx, and reason support (ocaml/ocaml-lsp#735 fixes ocaml/ocaml-lsp#696, ocaml/ocaml-lsp#706) - Support `include` in folding ranges (ocaml/ocaml-lsp#730)
Consider this simplified executable and its ppx rewriter:
After running
dune build test.exe
once, and making trivial changes to either ppx.ml or test.ml, ocaml-lsp reportsUninterpreted extension
errors in either of the files. The errors are spurious and sometimes go away after making another change. The symptoms are a bit like if ocaml-lsp was running the incorrect preprocessor (e.g. ppxlib.metaquot on test.ml or ppx.exe on ppx.ml).Here are two logs from nvim (the first one with a spurious error in ppx.ml and the second with an error in test.ml):
The text was updated successfully, but these errors were encountered: