Commit Graph

113 Commits (1cd6e4451f04af4871675d0eecd48b3bac262b67)

Author SHA1 Message Date
Gabriel Scherer 1cd6e4451f Map.filter_map and Set.filter_map 2020-03-31 15:01:41 +02:00
Gabriel Scherer 6465616fd9 improved error messages for exceptions in signature errors
Example:

    module Test : sig
      exception Foo
    end = struct
    end

Before this PR:

    Modules do not match: sig end is not included in sig exception Foo end
    The extension constructor `Foo' is required but not provided

After this PR (second line changed):

    Modules do not match: sig end is not included in sig exception Foo end
    The exception `Foo' is required but not provided
2019-11-12 14:16:39 +01:00
Thomas Refis 8e928caea7
a better representation for modules with no name (#8908) 2019-10-09 14:15:37 +01:00
Nicolás Ojeda Bär 3d7fc7530a Remove ocamltests files 2019-09-28 18:03:59 +02:00
Gabriel Scherer 1ba9dce47f typing/oprint: improve printing of functor arguments
This commit improves the printing of mixed anonymous/non-anonymous
functor signatures from (before)

    module type LongFunctor =
      functor (X : A) -> B -> functor (Z : C) -> D -> E -> sig end

to (with this commit)

    module type LongFunctor =
      functor (X : A) (_ : B) (Z : C) -> D -> E -> sig end
2019-09-04 21:18:16 +02:00
Gabriel Scherer 331b322ab5 typing/oprint: rework printing of functor arguments
The new implementation is closer to the grammar rules, and I find it
easier about.

For example, I was able to implement the long-form-or-short-form
heuristic easily, improving the printing from (before)

    module type LongFunctor =
      functor (X : A) -> B -> functor (Z : C) -> D -> E -> sig end

to (with this commit)

    module type LongFunctor =
      functor (X : A) (_ : B) (Z : C) -> D -> E -> sig end

The printing should be exactly the same as with the previous
implementation -- thanks to the help of Florian Angeletti.
2019-09-03 17:48:13 +02:00
Gabriel Scherer 071bae4c5f typing/oprint: [minor] improve printing of empty signatures 2019-09-03 11:44:21 +02:00
Florian Angeletti 2bd33ee515
Merge pull request #8906 from Octachron/functor_arrow_associativity
Print parentheses in (A->B)->C
2019-09-02 17:51:17 +02:00
Florian Angeletti 740baf0317 Print parentheses in (A->B)->C 2019-09-02 15:16:47 +02:00
Florian Angeletti 6032e9cf49 oprint: add break hint after functor args 2019-08-29 14:48:46 +02:00
Mekhrubon Turaev 38c3710eea Rollbacking changes of Constructor_names and Label_names errors message 2019-08-08 12:04:03 +01:00
Mekhrubon Turaev 77b876a117 reseting context in constructors and labels methods before printing 2019-07-30 16:20:30 +01:00
Mekhrubon Turaev 4725a9726d added tests for printing type Tvars 2019-07-30 16:17:02 +01:00
Mekhrubon Turaev 407d650f6e Printing additional info about types mismatch during compilation error. 2019-07-30 09:51:02 +01:00
Mekhrubon Turaev 0569b396ec Added new tests for type mismatch errors 2019-07-30 09:50:17 +01:00
Mekhrubon Turaev 6cb5905c27 Improved type hierarchy for type mismatches (#8828)
Added special types for variants, records, constructors or labels type mismatch.
Printing additional info about types mismatch during compilation error.
2019-07-30 08:56:28 +01:00
Thomas Refis ddb4cd93cb
Env.lookup_module: don't allow creating loops (#8810) 2019-07-18 15:40:48 +01:00
Jacques Garrigue 4fe08b25d6
Fix #7851 by checking type declaration coherence for recursive modules (#8570) 2019-04-19 10:57:55 +09:00
Louis Roché 4fee301280 Print end line and valid end character for multi-lines locations
When a location is related to multiple lines of code, it is printed
incorrectly. More specifically, the end character is actually an
offset between the beginning and the end of the location.

This commit changes the format of the locations when they cover
multiple lines. It adds the end line and the end character is now a
proper column rather than an offset. It doesn't affect locations
related to a single line.

The old format was:

```
Line STARTLINE, characters STARTCHAR-OFFSET
```

The new format is:

```
Lines STARTLINE-ENDLINE, characters STARTCHAR-ENDCHAR
```
2019-04-08 00:51:09 +00:00
Florian Angeletti 8e5e3c0ed4
Improved error message for illegal permutations (#8546)
* illegal permutation: more explanations and tests
2019-03-27 19:04:24 +01:00
David Allsopp 1626a018d8 Remove unnecessary executable bit from sources (#2270)
Various files which seem to have acquired Git executable bits.
File contents are unchanged; only permissions are changed.
2019-02-28 16:29:26 +01:00
Alain Frisch 4c130cae87
Fix wrong calls to Env.normalize_path on non-module paths (#2131) 2018-11-22 16:07:15 +01:00
Leo White f7fd84f877 Add tests 2018-11-21 03:39:34 -05:00
Thomas Refis 4bc69008a9 typemod: fix uncaught Nondep_cannot_erase exception 2018-10-29 15:14:58 +00:00
Thomas Refis 09112aca7e test nondep 2018-10-29 15:14:33 +00:00
Armaël Guéneau 9edbda8f70 Update the tests 2018-10-19 23:38:25 +02:00
Armaël Guéneau 48f806a662 Update tests 2018-10-19 23:38:25 +02:00
Gabriel Scherer 5c0024fe67 rework the relation between .gitattributes and ./tools/check-typo
Before this patch, check-typo is directed by a single git attribute,
ocaml-typo, which is used as a key to set a value:

    ocaml-typo=long-line,missing-header

(the value here is `long-line,missing-header`, and the code splits the
comma later)

This model is very fragile because .gitattributes does not allow to
give attribute keys a collecting/aggregating semantic: each new
setting of the key removes the previous setting, instead of adding to
them. For example,

    testsuite/tests/**                      ocaml-typo=missing-header
    testsuite/tests/win-unicode/*.ml        ocaml-typo=utf8

and

    testsuite/tests/win-unicode/*.ml        ocaml-typo=utf8
    testsuite/tests/**                      ocaml-typo=missing-header

are not equivalent, and instead of using either one we would introduce
redundancy for robustness:

    testsuite/tests/**                      ocaml-typo=missing-header
    testsuite/tests/win-unicode/*.ml        ocaml-typo=missing-header,utf8

With this patch, we switch to a model where each ocaml-typo setting is
its own attribute, of the form `typo.<<attribute>>`. The lines above
would be written, in either order:

    testsuite/tests/**                      typo.missing-header
    testsuite/tests/win-unicode/*.ml        typo.utf8

Not only does this approach make our .gitattributes more robust, it
allows for a more fine-grained treatment of the "unused-prop"
marker. This was used as an attribute to say: don't make it in an
error if the given typo-rule is in fact respected (by default, opting
out of a typo-rule gives an error if the typo-rule is respected). But
because of the single-key nature of ocaml-typo, unused-prop would
range over all settings, not just one of them. For example

    emacs/caml.el ocaml-typo=long-line,unused-prop,missing-header

seems to suggest that 'unused-prop' only qualifies the 'long-line'
rule, but in fact it also ranges over 'missing-header'. In contrast,
with this patch, we write the following:

    emacs/caml.el typo.long-line=may typo.missing-header

the `=may` value setting is used to make an exception to a typo-rule
optional.
Interestingly, most .gitattributes lines worked without extra error
when I turned each unused-prop in a =may setting over the rule just
before, instead of all rules: our checking is now more precise than
before, better capturing the intent of the .gitattributes author.

As I had to rewrite parts of the check-typo code for this, I took the
opportunity to rename a couple variables speaking about SVN (now long
defunct) into more meaningful names:

- `$is_svn` => `$path_in_index`
- `$svnrules` => `$attr_rules`
2018-10-18 13:44:48 +02:00
Jacques Garrigue f4274ed89b update output for pr7818.ml 2018-09-21 15:17:58 +09:00
Jacques Garrigue e8bb50e421 Fix MPR#7818 by removing local aliases in functor argument types (#2051) 2018-09-21 15:09:27 +09:00
Nicolás Ojeda Bär b7cb63bc34 Fix typing-modules/aliases test 2018-08-13 10:18:51 +02:00
Thomas Refis c00a46e2cf more precise extension mismatch error messages 2018-08-09 10:18:54 +01:00
Thomas Refis 2452b86cae add more tests 2018-08-09 10:18:54 +01:00
Thomas Refis 2403ffb1b5 typemod: allow items coming from includes to be shadowed 2018-07-25 13:06:38 +01:00
Armaël Guéneau 0ccb589798 Refactor [Location.print_loc]; use it in [highlight_dumb] and expect_test.ml 2018-07-25 11:52:23 +02:00
Jacques Garrigue 7aa377a630
New attempt at fixing MPR#7726 (#1676)
* Fix MPR#7726 by re-checking recursive modules in signatures after substitution
* Check module applications when translating types in Typetexp
* Check all results of functor applications lazily
* Reduce the overhead of checking module types by building the environment lazily
2018-07-13 05:29:59 +09:00
Thomas Refis 555f8387c1 stop calling Ctype.unroll_abbrev 2018-07-10 10:04:34 +01:00
Thomas Refis c49de95841 unroll_abbrev: add test showing brokeness 2018-07-10 10:04:34 +01:00
David Allsopp b5d1929e87 Whitespace and overlong line fixes. 2018-06-14 15:15:34 +01:00
Thomas Refis 01ac5677b2 nondep_type_rec: only call expand_abbrev_opt at the toplevel 2018-06-13 10:49:16 +01:00
Thomas Refis 224767ee76 nondep_type_rec: add broken test suggested by jacques 2018-06-13 10:49:16 +01:00
Thomas Refis 17fc8d0e4c nondep_type_decl: add tests ensuring we don't unroll abbrevs in private case 2018-06-13 10:49:16 +01:00
Thomas Refis cfa05e8e5e nondep_type_rec: allow expanding to private abbrev 2018-06-13 10:49:16 +01:00
Thomas Refis f4e76a6934 nondep_type_decl: add a test showing private abbrevs are ignored 2018-06-13 10:49:16 +01:00
Leo White dd01cab508
Merge pull request #1750 from lpw25/make-aliases-absent-in-module-type-of
Make aliases absent in module type of
2018-05-04 09:10:51 -04:00
Leo White 3c5d6120a3 Make all aliases absent in module type of 2018-05-01 11:38:22 +01:00
Leo White fd7d455cd8 Add test showing problem with module type of 2018-05-01 11:07:28 +01:00
Thomas Refis 9ba6f3b875 PR#7787: fix module type of and recursive modules interaction
Mta_absent and Mta_present aliases should be compiled differently.
2018-04-30 18:05:07 +01:00
Leo White 896bcd10c7 Don't remove aliases in module type of 2018-03-22 15:46:32 +00:00
Simon Cruanes df80f34a92 Stdlib functional iterators (#1002)
* add `Seq` module, expose iterator conversions in most containers

* small typo

* typo

* change order of arguments for `{Map,Set}.add_seq`

* watch for max string length in `Bytes.of_seq`

* wip: make it build again

* Fix dependency

Sys needs to be linked before Bytes in stdlib.

* Update threads/stdlib.ml

* Update stdlib_no_prefixed/.depend

* fix inconsistencies with label modules

* update testsuite to work with seq

* update change file

* small change in `Hashtbl.to_seq`, capturing only the underlying array

* add some documentation to seq.mli

* revert to good ol' module type names for hashtables

* fix test

* change style of comments in seq.mli

* follow some demands in review of GPR #1002

* some fixes for #1002

* add Seq-related functions to Ephemeron

* add some comments on `Hashtbl.of_seq`

* add more tests for `Hashtbl.{to,of}_seq`

* fix bug in `Ephemeron.to_seq`

* Update Changes
2018-03-16 18:25:10 +01:00