vim-ocaml
vim-ocaml copied to clipboard
OCaml syntax highlighting with struct surround with parentheses
Here is a piece of syntax which is not properly handled:
module type X_int = sig val x : int end
module Four: X_int = struct
let x = 4
end
Four.x
module Three = (struct
let x = 3
end: X_int)
Three.x
Which looks like:

I confirm this bug. Here is a minimal example:
module M0 : sig end = struct let x = 0 end
(* => linting of struct is correct *)
module M1 : sig end = (struct let x = 0 end : sig end)
(* => linting of struct is correct
(but linting of last sig is buggy because of the type linter of PR#76) *)
module M2 = (struct let x = 0 end : sig end)
(* => ^^^^^^^^^^^^^^^^^^^^
the whole struct is linted with a wrong, uniform style
(but linting of last sig is correct) *)
A related discrepancy:
module IM = Stdlib.Map.Make(Int)
(* ^^^^^^^^^^^^^^^^^^^^
shown as a module/functor, with a uniform style *)
module IM : sig end = Stdlib.Map.Make(Int)
(* ^^^^^^^^^^^^^^^^^^^^
shown as as an expression (a datatype constructor `Make`
prefixed with a module path, and a constructor `Int`) *)
It’s just the fact that = does not follow module IM immediately.