Opinionated OCaml linter with Merlin integration for code quality, naming conventions, and style checks
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ocaml-merlin: E351 only flags top-level mutable values, not function types

E351 ("Exposed Global Mutable State") was firing on any [val] whose typed
signature contained [Stdlib.array] or [Stdlib.ref] anywhere — including as
a function argument or return type. The rule's intent is "no top-level
mutable singleton in the interface", which only applies to non-function
[val x : <mutable>] declarations; functions that take or return mutable
values are fine because the caller controls the cell, not the module.

Fix: [find_outer_type_constr] in ocaml-merlin's [Dump] now returns [None]
when it sees [Ttyp_arrow] / [Ptyp_arrow] before any [Type_constr],
matching its docstring ("Returns [None] if the next interesting token
isn't a [Type_constr]"). Add three regression cases to good.mli covering
[arr -> int], [int -> arr], and [int ref -> unit].

Also rename [Collision.tca] (the type) to [closest_approach] so it no
longer shadows the function name [Collision.tca]. Public API unchanged
beyond the type name; downstream callers refer only to the function.

+11 -1
+11 -1
test/cram/e351.t/good.mli
··· 18 18 must not be flagged. *) 19 19 type 'a array = Nil | Cons of 'a 20 20 21 - val users : int array 21 + val users : int array 22 + 23 + (** Functions that take or return [Stdlib.array] / [Stdlib.ref] are NOT 24 + exposed mutable state — the array/ref is a transient parameter or 25 + return value, not a module-level singleton. Only top-level non-function 26 + [val] declarations of array/ref type are flagged. *) 27 + val process : float Stdlib.array -> int Stdlib.array -> int 28 + 29 + val build : int -> float Stdlib.array 30 + 31 + val update_counter : int Stdlib.ref -> unit