Commit Graph

204 Commits (f6279a64b5f8812fed05e8bfeaa9bffcf7b6933f)

Author SHA1 Message Date
Thomas Refis c7f9c8e559 pat_env: I must not tell lies 2020-10-07 15:54:23 +02:00
Thomas Refis b938cb32c5 add test from PR#9799 2020-10-07 15:54:23 +02:00
Jacques Garrigue a5f63ba65f
Remove propagation from previous branches (#9811) 2020-10-03 10:48:57 +09:00
Jacques Garrigue 302d735ce8
Righteous ambivalence (#9767)
* Fix #9759: Typing without -principal is broken in 4.11 and trunk
* compile stdlib in -principal mode
* never modify generic part of ty_expected_explained
* use generic_instance where possible
* add comment for -no-principal in stdlib__oo.cmi
2020-07-29 09:10:17 +09:00
Gabriel Scherer b1d1c0b77c
Merge pull request #9657 from nojb/warning_mnemonics
Add mnemonics for warnings
2020-07-21 11:47:37 +02:00
Nicolás Ojeda Bär 3407c3b22e Update test reference files 2020-07-21 08:11:03 +02:00
Jeremy Yallop fb2f26a02e Stdlib injectivity: update tests. 2020-07-18 17:42:06 +01:00
Thomas Refis 4edc4b9928
pattern aliases do not ignore type constraints (#1655) 2020-07-09 12:20:37 +02:00
Thomas Refis 167e66e15d
type_cases: rely on levels to enforce principality (#1931)
Instead of the erasure scheme that was used up to now, where we
considered that the type was always principal.

Note: the erasure still happens when polymorphic variants appear in the
patterns, and the type of the scrutinee contains a Reither.
2020-07-08 10:35:40 +02:00
Jacques Garrigue 24d087325c
Fix #7902: Type-checker infers a recursive type, even though -rectype… (#9556) 2020-06-15 10:26:26 +02:00
Jacques Garrigue abb8db459d
Fix #7520: Odd behaviour of refutation cases with polymorphic variants (#9547) 2020-06-03 17:47:12 +02:00
Jacques Garrigue ee20f5e648
Fix the polymorphic recursion problem of #9603 (#9617) 2020-06-02 22:05:30 +02:00
Gabriel Scherer d8acfa92e4 parmatch: ensure specialized submatrices are in source order
We produce exhaustivity counter-example in the order of the
specialized submatrices. Having submatrices in source order gives the
nice behavior that the clause that would naturally been inserted first
in the source is given first as a counter-example.

Consider for example:

    function
    | true, true -> true
    | false, false -> false

The two counter-examples are (true, false) and (false, true).

Before this patch, (false, true) would be shown first.
After this patch, (true, false) is shown first.
This corresponds to the following natural completion order:

    function
    | true, true -> true
    | true, false -> ?
    | false, false -> false
    | false, true -> ?

On the other hand, the ordering of the default submatrix, with respect
to the specialized submatrices, is not preserved -- it is always
ordered last.
One could intuitively expect the default submatrix to appear in the
position of the first omega row in the source. We tried this, and
it is not a good idea:
- the change is much more invasive as the interface of
  `build_specialized_submatrices` has to change
- the behavior of the result is in fact unpleasant; it is not
  intuitive to order counter-examples in this way.

For example, consider:

    function
    | _, None -> false
    | true, Some true -> false

The two exhaustivity counter-examples are (true, Some false)
and (false, Some _). The second comes from the default submatrix:
morally it is (_, Some _), with "some other constructor missing from
the column" instead of the first _. There is no reason to suppose that
the user would want to place this (_, Some _) or (false, Some _)
counter-example first in the completed code; indeed, this intuition
would suggest writing an exhaustive covering of patterns of the
form (_, foo), inserted after the first clause, but then the other
clauses below become unnecessary!

When an omega patterns appears high in the column like this, it is
usually because there is a very specific matching condition to the
rest of its row, that justifies some shortcutting behavior. The
program is typically *not* completed by adding more specific matching
conditions.
2020-05-30 17:11:54 +02:00
Leo White c272447b1e Relax the handling of explicit polymorphic types 2020-01-20 13:48:16 +00:00
Jacques Garrigue a33f80bf00
fix typo in name + improve style in type_pat (#9161) 2019-12-04 15:06:17 +01:00
Jacques Garrigue 27ef14dab9
Fix exhaustivity of GADTs coming from incomplete unification (#9154) 2019-12-02 20:49:51 +01:00
Leo White fb33b74bca Relax the level handling when unifying row fields (#9064) 2019-11-07 09:38:46 +00:00
Nicolás Ojeda Bär 3d7fc7530a Remove ocamltests files 2019-09-28 18:03:59 +02:00
Gabriel Scherer 071bae4c5f typing/oprint: [minor] improve printing of empty signatures 2019-09-03 11:44:21 +02:00
Florian Angeletti a2d15b26d1
Merge pull request #8844 from MekhrubonT/trunk+mekh+1task+change_output
Improved error messages for type mismatches
2019-08-16 20:43:02 +02:00
Thomas Refis f03f510464 subst: don't lose scope 2019-08-13 14:17:46 +01:00
Thomas Refis 27b9aeaecd testsuite: add a test for #8862 2019-08-13 14:15:42 +01:00
Mekhrubon Turaev 407d650f6e Printing additional info about types mismatch during compilation error. 2019-07-30 09:51:02 +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
Florian Angeletti 6582335689
#8702: fix some polymorphic variant error messages (#8777)
improved error messages for fixed row polymorphic variants: keep track of the motivation behind a fixed row (e.g it was bound to an universal or existential type variable, or private) in the types themselves and use this explanation in error messages.
2019-07-12 17:47:25 +02:00
JPR 6dc59549ce Fixing misspellings 2019-05-21 10:23:27 +02: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
Matthew Ryan c33e46d69b Use newtype names as the underlying variable names (#2277)
* Use newtype names as the corresponding name when they are valid
2019-03-26 08:22:21 +09:00
Fourchaux 1946594bd7 Fixing typos in various files (#2246)
Note: Typos found with https://github.com/codespell-project/codespell

Here is the (semi-manual) command used to get (and correct) the typos:

$ codespell -i 3 -w --skip=".png,.gif,./ocaml/boot,./ocaml/.git,./ocaml/manual/styles,./ocaml/manual/manual/htmlman" -L minimise,instal,contructor,"o'caml",cristal,pres,clos,cmo,uint,iff,te,objext,nto,nd,mut,upto,larg,exten,leage,mthod,delte,tim,atleast,langage,hten,iwth,mke,contant,succint,methids,eles,valu,clas,modul,que,classe,missings,froms,defaut,correspondance,differents,configury,reachs,cas,approche,normale,dur,millon,amin,oje,transfert
2019-02-13 14:04:56 +01:00
Thomas Refis e2338820c5
Merge pull request #2110 from trefis/gadt-under-or-pattern
Allow GADT constructors to introduce equations and existential types under or-patterns
2018-11-12 09:30:56 +01:00
alainfrisch 74b24580ca Fix printing of type variables with a quote on 2nd character
Type variables whose name has a single quote as the second character
(such as ' a' or ' a'b) need to be printed with a whitespace after the
initial quote symbol, in order not to be confused with a character
literal.
2018-11-06 13:12:54 +01:00
Thomas Refis 25d1a56da3 allow GADTs under or-patterns 2018-11-05 13:15:35 +00:00
Thomas Refis bbb94be8e3 testsuite: test GADTs under or-patterns 2018-11-05 13:03:17 +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
Thomas Refis d447a94f51 check_scope_escape: also handle type constructors escapes 2018-10-18 10:40:54 +01:00
Florian Angeletti 233d66611c Add context for unification errors 2018-10-17 17:31:31 +02:00
Florian Angeletti 3de40984ba a type for unification traces 2018-10-17 17:27:16 +02:00
Armaël Guéneau c0820e30cb Location: significantly rework the code printing errors and warnings 2018-08-08 17:42:08 +02: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
David Allsopp b5d1929e87 Whitespace and overlong line fixes. 2018-06-14 15:15:34 +01:00
octachron 32f3cc3fc7 remove "unnamed" in error messages 2018-04-25 17:57:14 +02:00
octachron b4a4ca2872 GPR#1753: existential restriction for "let ... in" 2018-04-25 17:57:14 +02:00
octachron 1ecf7ea486 change unexpected existentials error message 2018-04-25 17:57:14 +02:00
Thomas Refis 15e8f62b85 straightforward GADT disambiguation
Also: bootstrap + Changes
2018-03-12 14:55:42 +00:00
Thomas Refis afcab61fbd only add a dummy method when typechecking a class/class type 2018-03-06 10:01:51 +00:00
Thomas Refis e27616f9be add more tests related to the behavior of the self type escape check 2018-03-06 10:00:37 +00:00
Jacques Garrigue 7c8576d57d add pr7747.ml to typing-gadts/ocamltests 2018-03-01 17:03:20 +09:00
Jacques Garrigue a84c11e293
Fix MPR#7747 (#1641)
Use try_expand_once_opt rather than try_expand_once in Ctype.local_non_recursive_abbrev like in Typedecl.check_well_founded.
2018-03-01 16:08:39 +09:00
Thomas Refis acf4d56e76 check that no ambiguous pattern type escapes its scope earlier on.
This gives more stable error messages.
2018-02-27 14:52:25 +00:00