Skip to content

v2.27.0

Latest

Choose a tag to compare

@cknitt cknitt released this 06 Nov 20:28
97897d0
  • Require OCaml 4.14 or later (CI covers 4.14 to 5.5). Users of older compilers keep getting 2.26.0 from opam.

  • Remove the support for ReScript's @genType annotations, which kept the annotated value live: reanalyze is for OCaml only (the ReScript version lives in the rescript monorepo). Remove the workarounds for ReScript's JSX (emptyArray) and BuckleScript (unsafe_expr) as well.

  • Fix DCE false positives on case-insensitive file systems (macOS, Windows): a unit's .cmt was found under two spellings and treated as ambiguous, so exceptions raised across modules of a dune wrapped library were reported as never raised.

  • Fix DCE false positives for type re-exports type t = M.t = A | B (OCaml 5.3+): constructors and labels are shared with the original type, also when M is a local module alias.

  • Fix DCE false positives for types declared in a submodule of an interface (module M : sig type t = A end), which were not matched with their implementation.

  • Fix false positive "optional argument is never used" reports on aliases and partial applications of functions with optional parameters (e.g. let assert_equal = OUnit.assert_equal), also when exported through an interface: they stand for the function they apply, and calls through them count for it. A binding stands for the applied function only when its optional parameters are the ones that function leaves (let g = wrap f with wrap : ?x:_ -> 'a -> 'a does not); let g = f always does, also with a constraint that names its type (let g : fn = f), and so does a nested application (let p = 1 |> f ~x:1, typed as (f ~x:1) 1). Each call through a partial application that stands for the function is a call of that function with the optional arguments the application passes (let p = f ~x:1); the application itself counts as a call only when nothing calls through p. A binding that does not stand for the applied function owns no optional parameters; a function among its arguments that has all of them may receive them (in let g = wrap f, calls through g may supply f's).

  • Fix false positive "optional argument is never used" reports for functions passed to a parameter declared as a function with optional parameters (e.g. find (lookup : ?loc:_ -> _) calling lookup ~loc), or as a named type (type lookup = ?loc:int -> int -> int).

  • Limits of the optional-argument rules above: an alias that escapes (ignore p) counts as not called through, so with a chained alias (let q = p ~y:2) the arguments only the chain passes are reported as always supplied; an alias needs the applied function to be an identifier (let q = (fun x -> x) p does not stand for p, though p may receive what calls through q pass); a function passed directly to a callee that is not an identifier ((fun h -> h ~loc:1 2) f) is not credited; and calls through an alias of a functor parameter's value (let g = M.f in a functor body) count for every implementation of the parameter's signature, not only for the one the functor is applied to.

  • Fix "optional argument" reports leaking between functions without optional parameters, which shared one mutable record, and "always supplied" reports for labels a function does not own.

  • Fix optional-argument reports for functions whose type is named with an abbreviation (type fn = ?x:int -> unit -> int): calls through a value of type fn were not recorded, and a val f : fn in an interface hid all reports for the implementation. An alias let g = f is followed whatever its type shows, also when f is itself such a value (let first : fn = plain, let second = first).

  • Support analyzing several build trees of one project together (e.g. two dune profiles): sources found only inside a build tree are read from it, and a unit compiled from the same source in several trees resolves to the copy in the consumer's tree. A source path that names different files in different trees is warned about, since their declarations cannot be told apart; so is a file in the current directory that differs from its copy in a tree, which means the build is out of date.

  • Share parsed .cmt files between lookups instead of parsing them once per lookup directory, which reduces memory use on large projects.

  • Fix false positives for values in functor bodies (and modules) constrained by a module type defined in another file, e.g. module Make (K) : Gen.S with type key = K.t. On OCaml 5.3+ declaration dependencies pointing at other compilation units are now resolved, and references to val items of a named module type are forwarded to the implementations satisfying it.