Commit Graph

143 Commits (master)

Author SHA1 Message Date
Nicolás Ojeda Bär 246564e8db
Remove dead code (#9974) 2020-10-13 09:48:16 +02:00
Thomas Refis e01966a8b1 illegal commutation: more information in error message 2020-04-18 11:09:32 +02:00
Florian Angeletti 27cbba6cd7 add an Empty_branch exception 2020-02-19 10:37:06 +01:00
Gabriel Scherer 0ada2a79e0 name disambiguation: redesign Name_kind into Datatype_kind 2019-12-14 13:49:28 +01:00
Gabriel Scherer 1e19b1f3f7 name disambiguation: rename Label into Name 2019-12-13 18:47:47 +01:00
Gabriel Scherer 6c3bae052f name disambiguation: refactorize errors
(suggestion from Florian Angeletti)
2019-12-12 21:04:33 +01:00
Gabriel Scherer 7623001b88 name disambiguation: more structure for type kinds
(joint work with Thomas Refis)
2019-12-12 21:04:33 +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
Gabriel Scherer 7b10a26bc8 refactor the generic pattern traversal functions 2019-09-24 21:20:10 +02:00
Florian Angeletti c56ed411f8 Merge pull request #8827 from gasche/revert-numeric-operators-hint
Revert #2307 ( Hint on type error on numeric operators )

(cherry picked from commit 1fadc49604a791a7e9fa41c90fedad9304267f19)
2019-09-19 15:00:24 +02:00
Leo White c19e8b2350 Refactor environment lookup functions 2019-08-15 15:56:50 +01:00
Guillaume Bury aec35c5f44 Better error message for private constructors of extensible types (#8579) 2019-04-04 13:03:26 +01:00
Jules Aguillon d926fdb9f8 Add hint on numeric operator type clash 2019-03-11 01:58:52 +01:00
Jules Aguillon e1ca14da22 Refactor report_error to return a Location.error 2019-03-10 23:48:17 +01:00
Jules Aguillon 6794943b32 Implements on patterns 2019-03-08 16:37:49 +01:00
Jules Aguillon 9ab5efc1ec Add hint on int literals where expecting int32 or int64 literal 2019-03-08 16:37:49 +01:00
Leo White 403003cad5 Add support for "let" operators 2018-11-27 13:30:55 +00:00
Runhang Li 97329f30ed Extend `open` to arbritrary module expressions in structures and to
applicative module paths in signatures
2018-11-26 16:20:37 +00:00
Florian Angeletti 3de40984ba a type for unification traces 2018-10-17 17:27:16 +02:00
Armael 960c49d852 Fix references to Location.report_error in docstrings (#1978) 2018-08-14 14:48:55 +02:00
Thomas Refis 369ea5f432 allow exceptions under or-patterns 2018-07-16 10:41:55 +01:00
Armaël Guéneau 3724057b8c Add an explanation for the expected type of when-clauses 2018-07-04 17:09:31 +02:00
Florian Angeletti 18bba745f3 typing: remove an unused error 2018-06-29 17:38:38 +02:00
David Allsopp b5d1929e87 Whitespace and overlong line fixes. 2018-06-14 15:15:34 +01:00
Nicolás Ojeda Bär 0d6569fa1e Remove pv_name field 2018-06-07 16:11:47 +02:00
Thomas Refis d867bc5a0d do not error when instantiating polymorphic fields in patterns 2018-05-24 11:48:05 +01: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
Damien Doligez 90fbe53ee5 Revert "Merge pull request #1472 from Armael/improved-error-letrec"
This reverts commit c224184471, reversing
changes made to 2fc77a2d58.

As an exception, commit 3b77d915b5 (Generalize Env.lookup_* functions to allow disabling marking) is NOT reverted, because it was used by subsequent commits.
2018-04-09 15:56:00 +02:00
Thomas Refis 15e8f62b85 straightforward GADT disambiguation
Also: bootstrap + Changes
2018-03-12 14:55:42 +00:00
objmagic 0993cd9ba9 Support empty variants (#1546)
* Allow empty variants.
* Update manual and ocamldoc.
2018-03-06 10:48:16 +09:00
Armaël Guéneau ea00ce020f Add specific error messages in case of type propagated from a keyword 2017-12-21 11:50:54 +01:00
Armaël Guéneau 9f75022603 Add specific error messages for missing 'rec' in let bindings
Original design and idea by Arthur Charguéraud
2017-11-17 18:42:16 +01:00
Jacques Garrigue 70b02405e0 Merge pull request #1365 from yallop/let-rec-patch-406
GPR#556, PR#7215, PR#7231, PR#6738: Add a new check that 'let rec' bindings are well formed.
2017-09-22 15:37:10 +09:00
Alain Frisch fd47ba9649 Support 'let open' in class and class type expressions (#1249)
* Support 'let open' in class and class type expressions.

* Adapt ocamlprof.

* Adapt ocamldoc.

* Add tests.

* Changelog.

* Manual.
2017-07-20 08:17:30 +02:00
Mark Shinwell 2da2fcdb66 Annotate Texp_function with an Ident.t for the parameter (#831) 2016-10-14 09:34:50 +01:00
alainfrisch 166ba71479 Merge branch '4.03' into trunk 2016-03-21 23:29:54 +01:00
alainfrisch 5edc0e38bd MPR#7190: improve error message for inline records. 2016-03-21 22:41:25 +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
Gabriel Scherer d071da2880 Revert GPR#305 (exception patterns under or-patterns) from trunk
This week we merged several changes from Thomas Refis, to allow the
use of exception patterns under or-patterns, to write code such as

  match foo x with
    | None | exception Not_found -> ...
    | Some -> ...

Unfortunately, I failed to properly assess the impact of this change,
and in particular to make sure that Luc Maranget had properly reviewed
this code -- any change to the pattern-matching machinery should be
reviewed by Luc.

The problem that I had not foreseen and that he would have immediately
realized is that, while adapting the pattern-matching *compiler* is
relatively easy (Thomas inserted a transformation at the right place
to separate exception patterns from the others and handle them
separately, using the staticraise construct used by the
pattern-matching compiler to avoid duplicating the
right-hand-side branch), adapting the pattern-matching warnings
machinery is both more subtle and easier to overlook (it may fail
silently and nobody notices, unlike wrong code production). This part
of the compiler is subtle and best understood by Luc, but he does not
have the time to do a proper review of those changes in the timeframe
for the 4.03 feature freeze (mid-December).

I believe the right move in this case, implemented in the present
commit, is to revert the change from trunk (this is not a feature that
we must *imperatively* have in 4.03), do a proper job of understanding
the changes, and integrate the change when we are confident it is
ready. I hope to do this in 2016, together with Luc Maranget and
Thomas Refis -- hopefully this would allow Thomas and I to be more
confident when changing the pattern-matching machinery in the future.

Revert "Merge pull request #343 from trefis/pr7083"
This reverts commit 22681b8d2a, reversing
changes made to a24e4edf0a.

Revert "Merge pull request #341 from trefis/or-exception"
This reverts commit f8f68bd329, reversing
changes made to 1534fe8082.

Revert "Merge pull request #305 from trefis/or-exception"
This reverts commit cfeda89396, reversing
changes made to 77cf36cf82.
2015-12-12 11:20:21 +01:00
Thomas Refis 4b28c6ca99 PR#6422: Allow exceptions under or-patterns in match statements. 2015-12-09 11:19:59 +00:00
Hugo Heuzard 9eca3e4519 Parse arbitrary precision integers ..
.. and allow any letter in [g-zG-Z] as modifier (previously 'l','L','n')
Also allow modifier for floats
This give more freedom to ppx rewritters (what about a ppx for zarith)

Checks are performed when translating from Parsetree to Typedtree.
Invalid_literal is raised if the modifier is not recognized ([lLn]?)
Integer_overflow is raised as before.

Lexer: use g-zG-Z for integer literal modifier

Lexer: Allow modifier on float

Clean wrt previous commits

Lexer: use named substring

Cleanup

typo

doc

fix after rebase

rebase on  trunk

Update typecore.ml

Fix printast.ml
2015-12-03 17:20:48 +01:00
Jeremie Dimino ebd830b85b Add support for [%ocaml.extension_constructor <path>]
Translate [%ocaml.extension_constructor <path>] to the
runtime-representation of the extension constructor denoted by
<path>. This allows one to get the extension constructor without
having to create a dummy value.
2015-11-27 18:17:14 +00:00
Jacques Garrigue a335b18a45 merge branches/gadt-warnings
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16532 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-10-23 08:33:44 +00: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
Damien Doligez b860d63145 whitespace cleanup, cut long lines, add some missing headers
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16415 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-09-11 11:58:31 +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
Jacques Garrigue 158480371a exhauce PR#6367: introduce Asttypes.arg_label to encode labelled arguments
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15737 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-12-22 08:45:55 +00:00