Skip to content
Success

Changes

Summary

  1. usage warnings for private constructors: document our intentions in the testsuite (commit: ea0dc27) (details)
  2. typing: allow private constructors without usage warnings (commit: c648c5f) (details)
  3. Changes (commit: 6eba569) (details)
Commit ea0dc273d094c6b9cefbaafaf340d59207b53725 by gabriel.scherer
usage warnings for private constructors: document our intentions in the testsuite
(commit: ea0dc27)
The file was modifiedtestsuite/tests/typing-warnings/unused_types.ml (diff)
Commit c648c5fb2b16ce1d1ec571db9fb021ac3e148c15 by gabriel.scherer
typing: allow private constructors without usage warnings

We would like to allow the use of private variant constructors to
build 'phantom' types used for GADT indices:

    type zero = private Zero
    type 'a succ = private Succ

    type ('a, _) sized_list =
    | Nil : ('a, zero) sized_list
    | Cons : 'a * ('a, 'n) sized_list -> ('a, 'n succ) sized_list

Before the present commit, this example would fail with "unused
constructors" warning on Zero and Succ.

(We still warn on type constructors that are defined as public, and
then exported as private in a signature. But on types that are defined
as private in the implementation, warning that they are not used is
not that useful anyway, because it is impossible to construct them
except through the FFI.)

Note: we could reasonably warn on constructors that are defined as
private in the implementation, and then used in pattern-matching (but
never constructed, as constructing them is a type error). But this is
arguably warning about something different, and there is a risk of
negatively affecting existing projects by raising unused-constructor
warnings more often.

Reviewed-by: Florian Angeletti <florian.angeletti@inria.fr>
Reviewed-by: Nicolás Ojeda Bär <n.oje.bar@gmail.com>
(commit: c648c5f)
The file was modifiedtyping/env.ml (diff)
The file was modifiedtestsuite/tests/typing-warnings/unused_types.ml (diff)
The file was modifiedChanges (diff)