ocaml / merlin

Context sensitive completion for OCaml in Vim and Emacs
https://ocaml.github.io/merlin/
MIT License
1.58k stars 233 forks source link

Syntax error with nonrec #111

Closed roshanjames closed 10 years ago

roshanjames commented 11 years ago

Merlin seems to flag a syntax error with:

type nonrec t = t with sexp
let-def commented 11 years ago

"nonrec" is an extension (provided through camlp4). We decided to disable extensions that introduce new keywords by default (as they can break existing code).

You can explicitly enable "nonrec" by adding EXT nonrec in the .merlin . As usual, we will document that. Also, I will add emacs binding to enable extension on the fly.

roshanjames commented 11 years ago

Thanks!

yminsky commented 11 years ago

I just tried this and couldn't get it to work properly. What version of merlin supports nonrec? I'm running 1.4.1

let-def commented 11 years ago

Syntax extensions introducing new keywords have to be explicitly enabled. Either M-x merlin-enable-extension nonrec or put 'EXT nonrec' in .merlin file.

Btw, there is a bug (at least an annoying behavior :)) which prevents the file to be reparsed after enabling extensions, so that reported errors will remain until you edit the buffer.

Yaron Minsky notifications@github.com wrote:

I just tried this and couldn't get it to work properly. What version of merlin supports nonrec? I'm running 1.4.1


Reply to this email directly or view it on GitHub: https://github.com/def-lkb/merlin/issues/111#issuecomment-27612397

Sent from my Android device with K-9 Mail. Please excuse my brevity.

let-def commented 11 years ago

OK so now I feel stupid with my answer... I received the issue on my mobile and had no access to backlog.

Though maybe you are running into this refreshing issue, keep me informed.

yminsky commented 11 years ago

I'm running the OPAM version of merlin, and it doesn't appear to respond to the EXT declaration in the .merlin file or to have merlin-enable-extension available in the emacs mode. Is the EXT stuff released to OPAM yet? I wonder if it's time to cut a new release...

roshanjames commented 11 years ago

I am running merlin from their master version and adding "EXT nonrec" to the .merlin file works on my home opam-based OCaml setup.

trefis commented 11 years ago

Hi,

The commands merlin-extension-dis/enable indeed appeared in the emacs mode just after the 1.4.1 release. But if you have EXT nonrec in your .merlin, merlin should pick it up...

I'll try to reproduce tomorrow.

yminsky commented 11 years ago

FWIW: I just double-checked, and adding EXT nonrec to the .merlin file seems to do nothing, despite the fact that I'm running 1.4.1 (as verified by running merlin-version) and that I made sure to restart merlin (and I checked that other changes to the .merlin file were getting picked up.)

On Sat, Nov 2, 2013 at 2:02 PM, Thomas Refis notifications@github.comwrote:

Hi,

The commands merlin-extension-dis/enable indeed appeared in the emacs mode just after the 1.4.1 release. But if you have EXT nonrec in your .merlin, merlin should pick it up...

I'll try to reproduce tomorrow.

— Reply to this email directly or view it on GitHubhttps://github.com/def-lkb/merlin/issues/111#issuecomment-27627391 .

trefis commented 11 years ago

I just checked on a simple case, my .merlin consisted of only EXT nonrec and my ml file was :

type t = int

module A = struct
  type nonrec t = t

  let a : t = 423
end

Could you try this and see if it works? My guess is that it will, and the problem would be in your .merlin at some point before the EXT directive. At the moment when we encounter an error in the .merlin file we stop at that point, and fail more or less silently depending on the error (we plan to improve that for the next release).

In any case, could I see your .merlin?

trefis commented 10 years ago

I'm still convinced that was related to an error in the .merlin, since these are now reported and not silently ignored I'll close the issue.

I'll reopen if someone still experiences the problem.