Closed mcclure closed 9 years ago
The problem you have is that your build system is unable to work on syntactically incorrect files. Merlin works later in the workflow, having a working build system is a requirement. But you're right that this case is a weak spot.
The blocking point here is dependency computation. Luckily, it is possible to approximate dependency computations in this case (as shown by merlin, which is able to ask for Value and Token modules, so dependencies are known at this point). It is just not implemented in the existing build systems which where not made for handling incorrect input.
(providing an alternative ocamldep shouldn't take long)
This patch to ocamldep should do it https://gist.github.com/def-lkb/9f7ba3b2bfd7cf845408 (untested). If should be possible to get this upstreamed.
@def-lkb if/when we manage to upstream some work on error resilience and reporting for the OCaml compiler, it should be easy to adapt ocamldep to also work on the "correctly parsed" part of a parser state.
(Hadn't seen your patch. Yes, this sounds like a reasonable heuristic. Could you send a GPR or mantis PR about this?)
(yes)
My situation: I have a project containing a src/main.ml, which depends on a src/execute.ml, which depends on a src/value.ml and src/token.ml. (https://bitbucket.org/runhello/emily , if it matters or you want to see my Makefile or .merlin.) I have merlin 2.0.0 installed via opam and vim 7.4 +python installed via MacPorts. When I want to build, a makefile runs ocamlbuild -no-links -use-ocamlfind src/main.native. If there are errors, I check them by opening the file containing the error in vi and typing :w, triggering Merlin.
This is a situation I am seeing right this instant. There is a syntax error in execute.ml. I do these steps:
ocaml freenode tells me this is probably because I am missing cmi files. I look in _build/src, and, yeah:
andis-macbook:emily-ocaml mcc$ ls _build/ _digests _log ocamlc.where src andis-macbook:emily-ocaml mcc$ ls _build/src/ execute.ml execute.ml.depends main.ml main.ml.depends
It appears that since execute.ml failed early with a syntax error, ocamlbuild did not attempt to build execute.ml's dependent cmis; and that merlin/vi then just died because it doesn't build things, it only loads previously made cmis.
I run these two commands by hand:
ocamlbuild -no-links -use-ocamlfind src/token.cmi ocamlbuild -no-links -use-ocamlfind src/value.cmi
I feel like I shouldn't have had to go through this rigamarole of running ocamlbuild twice by hand. Imagine if my project had had six or seven dependencies instead of just two...? And "when there is an error" is a poor time for an error-reporting feature to stop working. Should this be happening? Is it fixable?