Context
This is a pattern observed in Opam 2.5.1. A variant type is defined in a compilation unit (Either.t), aliased via a type equation in another one (either), and the alias's constructors are used (here and here) but the original constructors are never built.
This leads the analyzer to report the original constructors as unused, although they are via the alias.
If the original type definition and the type equation appear in the same compilation unit (even in different modules), then the analyzer correctly considers the original constructors as used.
Example and reproduction
(* /tmp/type_eq/original.ml *)
type t = UsedByOriginal | UsedByAlias | Unused
let _ = UsedByOriginal
(* /tmp/type_eq/alias.ml *)
type t = Original.t = UsedByOriginal | UsedByAlias | Unused
let _ = UsedByAlias
$ ocamlopt -bin-annot original.ml alias.ml
$ dead_code_analyzer --nothing -T all .
Scanning files...
[DONE]
.> UNUSED CONSTRUCTORS/RECORD FIELDS:
====================================
/tmp/type_eq/original.ml:2: t.UsedByAlias
/tmp/type_eq/original.ml:2: t.Unused
Nothing else to report in this section
--------------------------------------------------------------------------------
Among the 3 constructors, t.UsedByOriginal is correctly not reported and t.Unused is correctly reported. However, t.UsedByAlias should not be reported.
Context
This is a pattern observed in Opam 2.5.1. A variant type is defined in a compilation unit (
Either.t), aliased via a type equation in another one (either), and the alias's constructors are used (here and here) but the original constructors are never built.This leads the analyzer to report the original constructors as unused, although they are via the alias.
If the original type definition and the type equation appear in the same compilation unit (even in different modules), then the analyzer correctly considers the original constructors as used.
Example and reproduction
Among the 3 constructors,
t.UsedByOriginalis correctly not reported andt.Unusedis correctly reported. However,t.UsedByAliasshould not be reported.