Commit Graph

63 Commits (master)

Author SHA1 Message Date
Gabriel Scherer bf95a24739 Matching: propagate constructor descriptions in complete_pats_constrs
This simplifies this particular interface boundary between Matching
and Parmatch.

(Suggested by Florian Angeletti)
2020-05-26 15:47:41 +02:00
Gabriel Scherer 9ca2a352c8 make check-typo happy 2020-05-16 12:32:49 +02:00
Gabriel Scherer 68dc87c9e9 matching: use pattern views in Parmatch as well 2020-05-14 10:27:50 +02:00
Gabriel Scherer ffb6caef8b patterns: move Parmatch.Pattern_head into Patterns.Head
The aim is to also move the Simple/Half_simple/General stuff from
matching, but we need to split in those modules the part that are
purely structural (they go in Patterns) and the parts that are
actually compilation logic (Half_simple.of_clause), those stay in
Matching.
2020-05-14 10:11:36 +02:00
Florian Angeletti 3903f9fab5 parmatch: normalize_pat is not used anymore 2020-05-01 21:58:28 +02:00
Gabriel Scherer 3306f4a1e4 parmatch: Pattern_head.arity 2020-04-18 11:08:12 +02:00
Thomas Refis 9504ede328 parmatch: export Pattern_head 2020-03-10 12:08:39 +01:00
Jacques Garrigue da3295c3af Typecore.type_pat: refactor ppat_of_type and Need_backtrack in wildcards
There is a small, desirable change of behavior in this PR:
we do not backtrack on all wildcard pattern explosions,
only on those where ppat_of_type knows there will be GADTs.
As a result, some exhaustivity counter-examples
have been improved with more cases (see testsuite for an example).
2019-11-04 15:20:56 +01:00
Gabriel Scherer 312253ce82 split patterns into "value patterns" and "computation patterns"
Value patterns match on a value (the result of computation), while
computation patterns handle the effects (hint hint) of
a computation. The only forms of computation patterns in OCaml today
are value patterns and exception patterns (exception p).

The sub-pattern `p` of the `lazy p` construction should be
a computation pattern, rather than a value pattern. This pull-request
does not make this change.

Most of the changes in this PR are boilerplate -- it really is a lot
of work now to add a new syntactic category to the typed-tree
syntax. This boilerplate is fairly automatic and should be easy to
review.

There is a subtle part to the patch, though: the implementation of the
pattern type-checking. It now has to reconstruct the value/computation
distinction (absent from the parse-tree), and return values from two
different types. Instead of splitting the type-checker in several
functions (which risked code duplications), I choose to use a GADT to
have the same [type_pat] function return two different types depending
on the caller. This is the least invasive way to adapt this part of
the codebase, whose inherent complexity is so large (unfortunately)
that adding a GADT to the mix barely makes a difference.
2019-10-31 13:29:16 +01:00
Florian Angeletti 15d452ac75 typecore: refine documentation for type_pat some more 2019-10-18 11:50:50 +02:00
Jacques Garrigue 4a3f42781b typecore: change documentation of type_pat and add documentation to Parmatch 2019-10-18 11:50:50 +02:00
Thomas Refis 79f1c73462
Warn about unused functor parameters (#8891) 2019-10-14 11:11:01 +01:00
Jérémie Dimino 9124ab82d1
Deprecate Pervasives (#1605)
- inline Pervasives in Stdlib and re-add Pervasives as a deprecated
module that aliases all elements of Stdlib except the stdlib modules.

- remove special case for Stdlib.Pervasives in printtyp.ml
2018-08-27 12:42:14 +01:00
David Allsopp b5d1929e87 Whitespace and overlong line fixes. 2018-06-14 15:15:34 +01:00
objmagic 0993cd9ba9 Support empty variants (#1546)
* Allow empty variants.
* Update manual and ocamldoc.
2018-03-06 10:48:16 +09:00
Jacques Garrigue 55e6d747fd
Follow up to #1559 : have the name of unknown missing tag depend on the row (#1564)
Print `AnyOtherTag (with possible extra apostrophes to avoid conflicts) it there is a row variable,
or `<some private tag> if this is a private row.
2018-01-18 13:01:31 +09:00
Jacques Garrigue f1a52b4556 change name to <some other tag> 2018-01-09 12:51:37 +09:00
Jacques Garrigue 1b5c76fabf Fix MPR#7704 2018-01-05 14:39:50 +09:00
Thomas Refis 01c744dab6 parmatch: add some documentation to the interface 2017-12-04 12:11:21 +00:00
Thomas Refis 7e494cd5d0 parmatch: mv [all_record_args] to [Matching] which is now the only user 2017-12-04 12:11:21 +00:00
Thomas Refis b4323c907f parmatch: remove commented out code, rename *_gadt into * 2017-12-04 12:11:21 +00:00
Thomas Refis 60c5f6fe91 parmatch: split pretty printing out into Printpat 2017-12-04 12:11:21 +00:00
Luc Maranget 7f5f82dc9c
Extensible types in pattern matching. (#1459)
* Handle extensible types

* various typos

* Oups.

* Astract constructor equality that considers potential rebinding into Types.may_equal_constr

* Moved rebinbing aware pattern compatibility functions from parmatch.ml to
matching.ml. Various consequences.

* Change Changes

* change the Changes change
2017-11-21 15:11:37 +01:00
Leo White 41bfd8e8ef Only treat pure patterns as inactive 2017-09-11 15:31:42 +01:00
Leo White afd03f2934 merge-more-functions 2017-06-08 12:27:37 +01:00
alainfrisch 502e4f9336 More warnings when compiling the compiler. 2016-03-15 22:46:35 +01:00
Damien Doligez 5401ce8473 Update headers for the new license.
Remains to be done: remove all headers in testsuite/tests.
2016-02-18 16:59:16 +01:00
Luc Maranget 6a89000b5c PR#7031 ambiguous guarded or-pattern.
- Check proper (in parmatch.ml)
  - Call check just after unused pattern check (in typecore.ml, correct ?)
  - Define and print warning (in warning.ml)
2015-12-14 15:58:02 +01:00
Jacques Garrigue e34f40ad87 switch to 'pat -> .' and add P/Texp_unreachable
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/gadt-warnings@16507 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-10-16 00:13:40 +00:00
Jacques Garrigue a09fb037ac add refuted cases, syntax is 'pat -> _'
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/gadt-warnings@16500 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-10-15 01:55:52 +00:00
Jacques Garrigue 254ab1d1b6 check for unused cases due to GADTs
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/gadt-warnings@16400 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-09-02 08:53:47 +00:00
Jacques Garrigue c88f3d0634 Improved exhaustiveness warnings for GADTs, with non-deterministic in type_pat
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/gadt-warnings@16133 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-05-19 22:52:21 +00:00
Jacques Garrigue 691aabb723 Fix PR#6849 and PR#6862
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16102 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-05-09 02:17:36 +00:00
Alain Frisch 525ef9d703 Synchronize with trunk.
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/extension_points@13897 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2013-07-16 13:34:30 +00:00
Luc Maranget ebfc4e6cff Fix PR #5992
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13611 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2013-04-25 13:32:17 +00:00
Alain Frisch e7736899fb Explicit representation of guards, get rid of Pexp_when.
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/extension_points@13528 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2013-04-15 16:23:22 +00:00
Alain Frisch 0b37b27356 Stop keeping a Path.t to refer to labels and constructors in the Typedtree AST. This is not used internally and it is not a robust way to identify these objects unambiguously anyway
(especially when we will add more powerful disambiguation strategies).  The correct way to identify an item is through the pair (type,name), which can be deduced from the
label_description/constructor_description stored in the Typedtree.



git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13043 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2012-10-24 12:03:00 +00:00
Damien Doligez def31744f9 remove all $Id keywords
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13013 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2012-10-15 17:50:56 +00:00
Luc Maranget 4e6e061882 Checked #PR5758, (also closed bug in Mantis)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12958 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2012-09-27 12:32:54 +00:00
Jacques Garrigue e086aa9a8d Fix PR#5758
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12937 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2012-09-19 06:57:17 +00:00
Jacques Garrigue d8f8f9ee3b keep the text width to 80 columns
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12522 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2012-05-31 08:07:31 +00:00
Fabrice Le Fessant d39d43e55f merge with branch bin-annot
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12516 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2012-05-30 14:52:37 +00:00
Jacques Garrigue 9dc661c3bf merge branches/gadts
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@11160 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2011-07-29 10:32:43 +00:00
Damien Doligez 3b507dd1aa renaming of Objective Caml to OCaml and cleanup of copyright headers
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@11156 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2011-07-27 14:17:02 +00:00
Jacques Le Normand 3ec9bc692b complete_constrs in parmatch.ml now works with gadts. Reverted changes to the syntax tree which are no longer needed.
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/gadts@10805 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2010-11-16 06:01:59 +00:00
Jacques Le Normand 1680403fb9 clean up
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/gadts@10784 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2010-11-10 06:01:27 +00:00
Jacques Le Normand 36734b7536 cleaned up parmatch.ml
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/gadts@10773 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2010-11-08 09:58:09 +00:00
Jacques Le Normand ff78b8ee75 exhaustiveness check has been _completely_ rewritten
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/gadts@10764 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2010-11-08 07:34:09 +00:00
Jacques Le Normand 7120d35ede exhaustiveness check is working. An algorithm te check compatibility has been implemented for use during unification. For example, int is incompatible with bool and (int,bool) is incompatible with (int,int)
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/gadts@10719 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2010-10-16 06:09:25 +00:00
Jacques Le Normand ffc7d7ccec first implementation of gadt friendly pattern exhaustiveness check. It is incomplete and untested. Also, some types are now incompatible
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/gadts@10707 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2010-10-07 07:12:50 +00:00