Commit Graph

740 Commits (8e928caea7c47e6ba8508cf2caaaa1ba9f8dca85)

Author SHA1 Message Date
Thomas Refis b134588f28 ident: split Local into Local and Scoped
Also rename [create] into [create_scoped] and [create_var] into
[create_local].
2018-09-21 11:47:44 -04:00
Thomas Refis 67f29d1a18 ident: add an explicit scope field
- Ident.create now takes a scope as argument
- added Ident.create_var to use when the scope doesn't matter
- the current_time and the current_level are unrelated as of this
  commit. But one has to remember to bump the level when creating new
  scopes.
2018-09-21 11:47:42 -04:00
Thomas Refis 12ede87f16 call repr before checking level to know if a disambiguation is principal 2018-09-19 11:41:17 -04:00
Thomas Refis 8c75b5f1d6 Unused rec: take local warning scope into account (#2050)
* unused rec: add test showing brokeness

* unused rec: allow turning the warning on locally
2018-09-18 18:14:52 +02:00
Hugo Heuzard 0814a7261f The parser keeps previous location when relocating ast node 2018-09-06 16:12:00 +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
Armaël Guéneau c0820e30cb Location: significantly rework the code printing errors and warnings 2018-08-08 17:42:08 +02:00
Hugo Heuzard 8043144494 Add locations to attributes
Changes

fix typo
2018-08-06 13:19:28 +01:00
Gabriel Scherer 021fd710a8
Merge pull request #1950 from Octachron/empty_polyvar_error
test suite: empty polymorphic variants in pattern
2018-08-01 15:10:42 +02:00
octachron 740b40d7f8 test suite: empty polymorphic variant in pattern 2018-07-31 22:16:24 +02:00
Thomas Refis 54b99858a6 typecore: only 1k existential per match, not a 100k
Bootstrap required because:

    File "asmcomp/mach.ml", line 1:
    Error: The files asmcomp/arch.cmi and asmcomp/mach.cmi
           make inconsistent assumptions over interface Arch

which happens because:
- Arch is compiled twice, once with the bootstrapped ocamlc, once with a
  freshly compiled ocamlopt
- Arch doesn't have an .mli
- the stamp on idents won't be the same for .ml files as a result of
  this change
2018-07-31 10:31:14 +01:00
Thomas Refis 9c53eaed9a
Merge pull request #1909 from trefis/unsharing-pattern-types
Unsharing pattern types
2018-07-26 10:01:05 +01:00
Nicolás Ojeda Bär 40bab2d768 Implement reviewer suggestions 2018-07-25 17:58:32 +02:00
François Bobot da3f9f34f5 Use reraise_raw_backtrace in Misc.try_finally
And add labels ~always for previous cleanup function and
    ~exceptionally for new cleanup function in exceptional case
2018-07-25 17:58:32 +02:00
Thomas Refis 892dc1de32 take an instance from type_pat, not from its caller 2018-07-25 16:39:15 +01:00
Thomas Refis 445b53182a ctype: remove instance_def which is redundant 2018-07-25 11:12:10 +01:00
Armaël Guéneau 213d1dbffa Clean-up dead code in typecore.ml
Eliminate some "let separate = true in ..." and the dead code associated
2018-07-17 12:50:54 +01:00
Thomas Refis 369ea5f432 allow exceptions under or-patterns 2018-07-16 10:41:55 +01:00
Florian Angeletti 5251865214 warning 40: fix missing wrap_printing_env
and amend lookup options in typing/printtyp.ml
2018-07-11 14:00:00 +02:00
Florian Angeletti 84872f9971 typecore Pexp_letmodule: remove redundant try with 2018-07-06 10:21:14 +02:00
Florian Angeletti 3a032d5c0e Pexp_coerce: redundant try ... with 2018-07-06 10:21:14 +02:00
Armaël Guéneau 3724057b8c Add an explanation for the expected type of when-clauses 2018-07-04 17:09:31 +02:00
Gabriel Scherer 159bc75d3b
Merge pull request #1872 from Octachron/restore_mixed_record_labels_pattern_error
restore the specialized error path for record patterns
2018-07-01 11:20:29 +02:00
Florian Angeletti 61168a4f56 restore the specialized record pattern error 2018-06-30 15:41:10 +02:00
Florian Angeletti 18bba745f3 typing: remove an unused error 2018-06-29 17:38:38 +02:00
Florian Angeletti 349db3d869
PR#6416 et al.: injective mapping between identifiers and printed names (#1120) 2018-06-26 22:03:45 +02:00
David Allsopp b5d1929e87 Whitespace and overlong line fixes. 2018-06-14 15:15:34 +01:00
Nicolás Ojeda Bär 9ef3d3fd8c Merge pattern matching cases 2018-06-07 16:19:48 +02:00
Nicolás Ojeda Bär 0d6569fa1e Remove pv_name field 2018-06-07 16:11:47 +02:00
Nicolás Ojeda Bär 3ba6d35501 Keep track of attributes in pattern variables 2018-06-07 16:11:47 +02:00
Nicolás Ojeda Bär f3d19a4413 Use record type for Typecore.pattern_variable 2018-06-07 13:54:39 +02:00
Thomas Refis f572baccd5 typedtree: export pat_bound_idents_with_loc 2018-06-05 11:59:22 +01:00
ygrek 97fca08b2d Printf: alternative int format %#d 1_234_567 2018-05-28 10:53:37 -07:00
Thomas Refis d867bc5a0d do not error when instantiating polymorphic fields in patterns 2018-05-24 11:48:05 +01:00
Thomas Refis 670542bc0c rec_check: cleanup interface 2018-05-23 10:59:08 +01:00
Thomas Refis e63e8421a1 move Rec_check out of typecore 2018-05-23 10:53:53 +01:00
Thomas Refis e360e8b613 typecore: remove pattern_variables
It was a duplicate of Typedtree.pat_bound_variables
2018-05-23 10:53:53 +01:00
Leo White f4fbdaba71
Merge pull request #1778 from lpw25/fix-pr7414-for-local-modules
Fix PR#7414 for local modules
2018-05-17 09:52:21 -04:00
Leo White 7c63ec8e98 Fix PR#7414 for local modules 2018-05-09 14:14:49 +01:00
Thomas Refis 81bd3e0f86 minor style clean up 2018-05-07 17:30:46 -04:00
Armaël Guéneau 8f936fedb0 Only display the "missing rec" hint for non-ghost code 2018-05-06 10:08:09 +02:00
Armaël Guéneau dbe2e4c352 Only add ghost bindings when the definition is a syntactic function 2018-05-06 10:08:09 +02:00
Armaël Guéneau 7f42ee9276 Allow spellchecking in case of missing rec hint 2018-05-06 10:08:09 +02:00
Armaël Guéneau 41d5658983 Re-implement the hint indicating missing "rec" keywords
This reverts commit 90fbe53ee5 except for the
Changes entry.
2018-05-06 10:08:09 +02:00
Thomas Refis 3d32ac7a8c
do not generalize the type of every sub-pattern, only of variables (#1745) 2018-05-04 08:33:00 -04:00
Thomas Refis 503c494acd type_cases: always propagate 2018-05-04 08:04:04 -04:00
Thomas Refis e6d34ba994 type_cases: pass arguments to unify_var in the right order 2018-05-04 08:04:04 -04:00
Thomas Refis dcf11ea4ca
Merge pull request #1705 from hhugo/exn
keep @@ attributes on exceptions
2018-04-27 11:16:41 +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 ac1ced70c5 Env.{make_copy_of_types,do_copy_types}: add some abstraction and explicit some invariants
Also, write a faster version: [do_copy_types (make_copy_of_types l env) env]
should have the same performance as the original [copy_types l env].
2018-04-25 10:08:05 +01:00
Thomas Refis ff091c2a7e do gadt things when there really are gadts 2018-04-25 10:08:04 +01:00
Thomas Refis c03581c932 use a record instead of tuples to represent partially typed cases 2018-04-25 10:08:04 +01:00
Thomas Refis 90e01856f3 duplicate type once, update in every branch containing a GADT 2018-04-25 10:08:04 +01:00
Thomas Refis 945066bd7b split copy_types in two 2018-04-25 10:08:04 +01:00
Thomas Refis 075b596817 delay adding pattern variables in the environment 2018-04-25 10:08:04 +01:00
Thomas Refis e22d9fce6b simplify add_pattern_variables: it just adds the given pattern variables to the
environment, and doesn't go and fetch anything from any random list ref.
2018-04-25 10:08:04 +01:00
Thomas Refis 4851e32d75 noop 2018-04-25 10:08:04 +01:00
Jeremy Yallop 78d00e83cb Fix Mantis PR#7767: interaction between labels and let rec check 2018-04-10 21:49:01 +01:00
Hugo Heuzard 002815c4bb allow to attach @@ attributes on exceptions 2018-04-09 22:29:46 +01:00
Gabriel Scherer 1115d6af82 tentative fix for letrec check error (MPR#7706)
The typechecker-level check for recursive value depends on whether
recursive values use a memory size that is statically known or depends
on their dynamic evaluation. An error in this check results in
a potential segfault.

The error is that the check currently considers all
variables/identifiers to have a statically-known size. This is
certainly wrong for locally-defined identifiers, that may be bound to
dynamically-sized expressions. We rule this case out by carrying an
environment during size-checking, that remembers the size
(static or dynamic) of local bindings.

The implementation is incomplete in certain ways, but safely defaults
to Dynamic as the size of bindings that it does not track through the
environment.
2018-04-09 16:51:47 +02:00
Gabriel Scherer 9eea16952f Typecore.classify_expression: minor reordering and indentation changes 2018-04-09 16:51:47 +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
Jacques Garrigue 3d33bd4ef5
Fix MPR#7751 (#1657)
Fix the toplevel printer, to have it properly load needed cmi's.
2018-03-27 09:25:28 +09:00
Thomas Refis 79d3f77433 typecore: remove trivially dead code 2018-03-21 15:07:46 +00:00
Thomas Refis b7101be913 do not spuriously warn 2018-03-15 13:05:26 +00:00
Leo White bce9d4b659 Fix usage warnings with no mli file (#1358) 2018-03-14 17:57:31 +01:00
Thomas Refis 15e8f62b85 straightforward GADT disambiguation
Also: bootstrap + Changes
2018-03-12 14:55:42 +00:00
Leo White 3340fb5ba6 Reraise and raise_notrace are also nonexpansive 2018-03-06 12:27:53 -05:00
objmagic 0993cd9ba9 Support empty variants (#1546)
* Allow empty variants.
* Update manual and ocamldoc.
2018-03-06 10:48:16 +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
Thomas Refis f509125318 slight representation change 2018-02-27 14:52:24 +00:00
Thomas Refis d43ccfc5d4 type_cases: decrease the sharing between the type of the scrutiny and that of each pattern
See discussion on MPR#7618 .
We also add a late check of ambiguous type escape.
2018-02-27 14:52:24 +00:00
Thomas Refis 7f0e819bde we don't need an env to take instances anymore 2018-02-27 14:52:24 +00:00
Thomas Refis f3a41038be use scope instead of gadt_instances 2018-02-27 14:52:24 +00:00
Thomas Refis 39b864f160 revert 88e8bec and 7b1140f : there should be no incoherent manifests anymore 2018-02-08 10:23:04 +00:00
Jeremy Yallop 72409876fc Fix PR7717 (Don't treat unboxed constructors as statically sized) 2018-02-01 21:58:56 +01:00
Thomas Refis 1b670fb2f1 type_cases: use a more precise ty_arg for parmatch checks 2018-01-31 11:26:30 +00:00
Thomas Refis f00544f5ea type_cases: also take an instance of ty_arg when checking exhaustiveness 2018-01-31 11:26:29 +00:00
Thomas Refis 8cf1cc4e7d type_cases: be more regular 2018-01-31 11:26:29 +00: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 582b7f803c add comment in code 2018-01-08 18:30:19 +09:00
Jacques Garrigue f7fabd7b7e add GPR number and check argument is None 2018-01-05 14:50:50 +09:00
Jacques Garrigue 1b5c76fabf Fix MPR#7704 2018-01-05 14:39:50 +09:00
Jacques Garrigue 839fe875f1 Fix MPR#7695 (#1541)
Some typing errors were not properly caught and reported, causing a compiler error
("Fatal error: exception Ctype.Unify(_)").

Test added.
2017-12-28 19:36:56 +01: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
Jeremy Yallop 0ed73814a6 let rec: allow float array construction if configured with -no-flat-float-array 2017-12-06 15:19:01 +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
Armaël Guéneau 935cb11e6e Rephrase a suggestion in a typing error message related to coercions 2017-11-30 18:31:56 +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
Armaël Guéneau 11eb5bbf16 Generalize add_pattern_variables to also return pattern variables 2017-11-13 20:48:44 +01:00
Armaël Guéneau 9704f790be Generalize Val_unbound with a reason 2017-11-11 15:43:31 +01:00
Alain Frisch 3d5e3a7640 Ensures CBV semantics when eta-expanding function to eliminates optional arguments (#1424)
Fix MPR7657: ensure CBV semantics when eta-expanding function to eliminate optional arguments.
2017-10-18 17:23:40 +02:00
Jeremy Yallop 776387b47c let-rec check: use Map, not Ident.tbl, for the "type" that tracks variable use.
The extra semantics of Ident aren't needed, and add significant extra cost.
2017-10-09 19:22:36 +02: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
Leo White 2798245738 Merge pull request #1314 from xclerc/ocaml-bool-padding
Padding for boolean formatting
2017-09-14 13:26:00 +01:00
Xavier Clerc 94b7ab801e Tentative fix for MPR#7624 (#1327)
* Tentative fix for MPR#7624.

* Move the warning scope to the computation of pat_slot_list (because of delayed checks).

* Fix computation of `warn_unused` (using binding attributes) and add tests.

* Test enabling binding-level warning when they are globally disabled.

* Rename `warn_unused` to `warn_about_unused_bindings` for better readablity.
2017-09-13 23:50:42 +02:00