summaryrefslogtreecommitdiff
path: root/testsuite/tests/typing-modules/inclusion_errors.ml
Commit message (Collapse)AuthorAgeFilesLines
* New script language for ocamltest (#12185)Damien Doligez2023-04-251-1/+1
| | | | New test script language, all tests translated automatically (see `tools/translate-all-tests`).
* error messages: use de bruijn indices to disambiguate namesFlorian Angeletti2023-01-021-4/+4
|
* Printtyp: avoid stack overflow when printing constructors or recordsFlorian Angeletti2022-10-171-0/+93
| | | | | | | | | Toplevel functions exported by the Printtyp should in general prepare all types involved in the printing. The toplevel `constructor`, `label` and `extension_only_constructor` functions didn't prepare their arguments and return types making the printer loops on such types.
* Include kinds in "Their kinds differ" errorcuriousleo2022-09-021-2/+2
| | | | | | | | | | | | | | | | | | | | | Changes the error message for code like the following: module M : sig type t end = struct type t = { i : int } end type t = M.t = { i : int };; Before: 2 | type t = M.t = { i : int };; ^^^^^^^^^^^^^^^^^^^^^^^^^^ Error: This variant or record definition does not match that of type M.t Their kinds differ. After: 2 | type t = M.t = { i : int };; ^^^^^^^^^^^^^^^^^^^^^^^^^^ Error: This variant or record definition does not match that of type M.t The original is abstract, but this is a record.
* Support clever expansion of gadt equations in presence of local module (#10348)Jacques Garrigue2022-07-041-3/+2
|
* Improve type variable name generation and recursive type detection when ↵Antal Spector-Zabusky2021-10-151-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | printing type errors (#10488) * Separate type variable naming and loop marking when printing errors Improve type variable name generation and recursive type detection when printing type errors by 1. Iterating over the whole trace and reserving type variable names once, to ensure that type variable names aren't reused in confusing ways between types. 2. Detecting recursive types (i.e., marking loops) for each type individually during printing, ensuring that spurious `as 'a` clauses aren't generated and that `as`-bound names can't be referred to across different types. This involved updating the `Printtyp` module: first refactoring `mark_loops_rec` into a general case analysis `iter_type_expr_for_printing`, and then implementing both `reserve_names` and `mark_loops` in terms of it (via `Names.add_named_vars` and a new `mark_loops_rec` that only handles marking loops and not generating names). As a result, the API for printing types also changed: * `type_expr` still does what it always did. * To handle multiple types simultaneously, use `prepare_for_printing` and `prepared_type_expr` (replacing `marked_type_expr` and the associated marking facilities). * Within `Printtyp`, we use `named_type_expr`, which is in-between the other formatters and assumes names have been generated but does its own loop marking.
* Add some extra periods to some new error messages for consistencyAntal Spector-Zabusky2021-06-211-13/+13
|
* Respond to review for the new structured error messages (#10407)Antal Spector-Zabusky2021-06-211-23/+26
| | | | | | | | | | | | | | | | | | | | | | | | In addition to the smaller fixes, there were two major changes: 1. `Errortrace` has its type completely refactored, removing `desc` and exposing both `'variant trace` and `'variant error`. The former is for traces that are being built up, and contains `type_expr`s; the lattern is for complete traces, and contains `expanded_type`s (a record containing two `type_expr`s). This dramatically affected a number of call sites, but is much cleaner. 2. We now detect weakly polymorphic types much better during printing. This involved fixing a bug in moregeneral, which was not restoring enough information in the error case; it also involved exposing the flag that differentiated between printing a type (no weakly polymorphic type detection) and a scheme (yes weakly polymorphic type detection) in more places, and giving it its own custom variant type, `Printtyp.type_or_scheme`. Among the minor changes, the updates to `Includecore` to more carefully detect privacy violation errors and differentiate between the various kinds thereof (recorded in the `privacy_mismatch` type) is the most visible in the code.
* Use the new structured errors (#10170) for better error messagesAntal Spector-Zabusky2021-06-211-4/+128
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We now produce more detailed error messages during various kinds of module inclusion, taking advantage of the new structured error trace generation from #10170. Previously, these errors were "shallow", ending as soon as there was an incompatibility; this patch makes them "deep", reporting the *reasons* for those problems. For example, consider the following module: module M : sig val x : bool * int end = struct let x = false , "not an int" end This now produces the following error: Error: Signature mismatch: Modules do not match: sig val x : bool * string end is not included in sig val x : bool * int end Values do not match: val x : bool * string is not included in val x : bool * int The type bool * string is not compatible with the type bool * int Type string is not compatible with type int The last two lines are new in this patch. Previously, the error message stopped two lines earlier, omitting the key detail that the reason there is an error is specifically that `string` is not equal to `int`.
* Add more new test cases for module inclusion errorsAntal Spector-Zabusky2021-06-211-0/+352
| | | | | | These test cases will also have improved error messages in the next non-test commit. They come from the work done to address reviewer comments for #10407.
* Add new test cases for module inclusion errorsAntal Spector-Zabusky2021-06-211-0/+64
| | | | | These test cases will have improved error messages in the next non-test commit.
* Add tests before improving the internal type error representationMekhrubon Turaev2021-05-061-0/+1174
Some of these tests point at behavior we're about to change; some of them point to behavior we're confirming that we don't change. * `constraints.ml`, `unbound_type_variables.ml`: Existing code whose behavior we won't change; however, we do fix the indentation in some of the type errors. * `poly.ml`: Add one test whose behavior will change (more detail) and reword one test to use clearer variable names. * `inclusion_errors.ml`: New tests that will confirm our internal changes did not (yet) have externally-visible changes to the type errors. This commit includes existing work by Mekhrubon Tuarev, who did all the early development. I (Antal Spector-Zabusky) came and built the layer of types on top.