Skip to content

Merlin can fail to error-check correctly if a build fails before dependent cmi's generated #302

@mcclure

Description

@mcclure

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:

  • I run "make clean", then "make".

  • Make fails saying File "src/execute.ml", line 45, characters 32-42: Error: Syntax error. Okay, fine.

  • I run "vi src/execute.ml". I enter :w. It fails with a bunch of failures. However, line 45 is the least of my problems. On line 2, it claims: "Error: Unbound module Value". On line 8, it claims: "Error: Unbound module Token".

  • 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 look in _build/src. The cmi files I expect to see are there.

  • I open src/execute.ml. I type :w. It does not anymore complain about Token or Value, and the first error is on line 45 where it should be.

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions