Commit Graph

171 Commits (master)

Author SHA1 Message Date
Thomas Refis f6a5b755f8
Env.folds (#9922) 2020-09-17 09:54:21 +02:00
Leo White b4361282c1 Fix PR#7897 2020-06-26 12:35:35 +01:00
Florian Angeletti 7d3a3f8c24
Merge pull request #9416 from lpw25/fix-warning-58-flambda-ocamlnat
Avoid warning 58 in flambda ocamlnat
2020-06-26 09:37:41 +02:00
Leo White 9e61a063c3 Avoid warning 58 in flambda ocamlnat 2020-06-25 14:45:45 +01:00
Jacques Garrigue 95a8fbfd5b change API for Env.open_signature to clarify errors 2020-06-23 16:36:55 +02:00
octachron 4f9f41e73a disambiguation for extension constructors
This commit exposes all extension constructors when looking up for
a construction with a given type in the environment.

This makes constructor disambiguation work for extension constructors.

Going one step further, when the name of an extension constructors
is misspelled, we cannot rely on the type to find all possible
names. However, since we are in an error path, we have some
path at hand.
Thus, this commit alters the "lookup_from_type" function in the
Constructor module to make it scan the whole environment for
extension constructors with the right type.

This commit should not change anything for labels and standard constructors.
2020-04-03 16:05:23 +02:00
Thomas Refis e4de6c19b1 use uid for usage warnings 2020-03-05 13:35:12 +01:00
Leo White ecfaffe9de Short circuit simple inclusion checks 2020-03-04 15:20:32 +00:00
Thomas Refis eb3b13d8cd Env.enter_module_declaration: create the ident 2019-08-28 11:58:49 +01:00
Leo White c19e8b2350 Refactor environment lookup functions 2019-08-15 15:56:50 +01:00
Alain Frisch 5ccf3c52dc New implementation of Env.make_copy_of_types (#8774) 2019-07-18 10:11:41 +09:00
Mark Shinwell d47ba6ec18
Functorize Consistbl (with some background info on Compilation_unit.t) (#2286) 2019-03-07 16:19:51 +00:00
Gabriel Scherer 93f0ce31bb env refactoring: separate the cmi/crc handling into a persistent_env module
Persistent_env is a new module that handles the relation between the
type-checking state and the "persistent" typing information laying in
.cmi files on the filesystem. In particular, it handles the collection
and production of CRC information for the .cmi files being read and
written to the filesystem; the using modules (in our case, only Env)
are in charge of turning the cmi files into higher-level information
(components and signatures).

Persistent_env exposes a type `'a t` of a persistent environment,
which acts as a mutable store of `'a` values. There is no global state
in the module itself: while Env (and thus the OCaml type-checker) uses
a single global persistent environment, it should be possible to
create several independent environments to represent, for example,
several independent type-checking sessions.
2019-02-18 17:02:47 +01:00
Gabriel Scherer b33c4b46d4 env refactoring: remove the current unit name from some exceptions
This small change of behavior simplifies the internal plumbing of env
by avoiding the need to passes the 'current_unit_name' state to
cmi-checking exceptions -- it allows to separate the cmi/crc logic to
a separate module in a future commit.

We believe that the change does not actually reduce error message
clarity, as the name of the offending unit appears in the location
filename anyway (see how these exceptions are handled by
Location.error_of_printer_file in the error printer).

Before:

    File "a.mli", line 1:
    Error: Unit A imports from B, which uses recursive types.
           The compilation flag -rectypes is required

After:

    File "a.mli", line 1:
    Error: Invalid import of B, which uses recursive types.
           The compilation flag -rectypes is required
2019-02-16 11:40:28 +01:00
Gabriel Scherer a6f0caa8de env refactoring: avoid external uses of {add_import,crc_units}
There is a small change of behavior in this patch due to a different
handling of weak dependencies (those with crco=None); in
Env.check_consistency, only non-weak dependencies would get
[Env.add_import] called, while the `toplevel/` implementations would
also call [Env.add_import] on weak dependencies. After this patch, we
systematically call [add_import] only on non-weak dependencies, even
in `toplevel/`.

([Gabriel:] As far as I can see, the use of [add_import] in the
toplevel never leads to a use of [Env.imports()] for producing
a dependency list, as the toplevel does not produce cmi/cmo files; are
they just no-ops?)
2019-02-15 10:24:49 +01:00
Gabriel Scherer 1d75048d5e refactoring: use some Misc type aliases in typing/env 2019-01-30 22:59:03 +01:00
Jeremie Dimino 7e0862a212 Refactor load path management and initial environment
- Add a Load_path module which caches files lookup

- Instead of falling back to the external environment, allow to
  declare in the environment that a module comes from the external
  world. This allows persistent structures to shadows non-persistent
  ones
2019-01-30 16:36:38 +00: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 111d4e1827 Remove positions from paths 2018-11-21 03:39:34 -05:00
Alain Frisch 2e5b9d1ef1
"Alerts" as a generalization of "deprecated" (#1804) 2018-11-15 09:51:35 +01:00
Thomas Refis 2ccad26bd0 always associate a scope to a type (previously it was optional)
Previously, not having a scope meant the type was used in every context,
now we set the scope to "Btype.lowest_level" to mean the same thing.
The equivalence was made obvious by the recent changes to identifiers
scoping.
2018-10-05 10:51:26 +01:00
Thomas Refis 4d4fd525c9 move refresh_signature out of Subst, add Env.enter_signature 2018-09-21 11:48:47 -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
Gabriel Radanne 1be47bf7ab Just some tbl things. (#1699) 2018-07-23 13:19:41 +01: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
David Allsopp b5d1929e87 Whitespace and overlong line fixes. 2018-06-14 15:15:34 +01: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 945066bd7b split copy_types in two 2018-04-25 10:08:04 +01:00
Leo White bce9d4b659 Fix usage warnings with no mli file (#1358) 2018-03-14 17:57:31 +01:00
Thomas Refis f3a41038be use scope instead of gadt_instances 2018-02-27 14:52:24 +00:00
Thomas Refis 9f2133786e remove Env.add_local_constraint, always use Env.add_local_type 2018-02-27 14:44:58 +00:00
Jérémie Dimino 49f6dd5d20
Allow compilation units to shadow sub-modules of Pervasives (#1513) 2018-02-02 10:44:23 +00:00
Armaël Guéneau 3b77d915b5 Generalize Env.lookup_* functions to allow disabling marking 2017-11-13 20:51:52 +01: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
alainfrisch f6d53cc38f Deprecation warning when checking signature inclusion
Deprecation warning (3) is currently only reported when directly
accessing a component marked with the deprecated attribute; but it is
missed when we coerce the signature contaning the deprecated component
to a signature without the attribute.

This commit adds the required machinery to detect such cases
and report the same warning. (An alternative design could be
to introduce a new warning for that purpose.)

Some of the new machinery could be used for other purposes:

  - During the inclusion check, keep the location that would used in
    the error message if the check fails.

  - Warnings can now hold extra "sub-locations" (and associated
    messages).
2017-04-05 19:13:59 +02:00
alainfrisch d8b413f17f Expose a more explicit 'copy types' operation in Env (with a representation in summary), instead of a more generic 'update_value'. 2017-03-24 14:24:36 +01:00
alainfrisch 1cad974131 Restore proper error message when opening a functor. 2017-03-24 14:24:36 +01:00
alainfrisch 3d037367a2 Implement type-checking of open by copying 'components' instead of recreating them from the signature. 2017-03-24 14:24:36 +01:00
Jacques Garrigue b276a078cd Fix PR#7134, following a suggestion of sliquister 2016-12-14 13:14:21 +00:00
Alain Frisch 227bdc6217 Avoid rebuilding cmi_info record when creating .cmti files (#781)
Instead of rebuilding cmi_info in Cmt_format.save_cmt, the record
created in Env.save_signature is kept and passed to that function.  In
addition to simplifying the code, this avoids possible mismatch between
the two records, including:

  - Duplicated entry in cmi_crcs for the current unit as noted in #744.

  - Missing flags (Unsafe_string/Deprecated were not properly set in
    Cmt_format).

The interface is also stronger, since the signature passed to save_cmt
was supposed to be already mapped by Subst.for_saving but this was not
reflected in the API.
2016-08-30 13:11:01 +02:00
Damien Doligez 0b4fbc2b30 fix whitespace, long lines, headers 2016-08-01 16:06:59 +02:00
Leo White 55a21ff051 Add label to bool parameter 2016-07-28 10:13:32 +01:00
Leo White caadb9de8a Allow more module aliases in strengthening 2016-07-28 10:13:32 +01:00
Jeremie Dimino 31417fb5ad add Env.Persistent_signature.load
Which is a hook to lookup for a cmi and load it. This can be used to
create self-contained toplevels that embed cmi files.
2016-07-21 13:20:46 +01:00
alainfrisch 30c796713c Record the safe/unsafe_string mode in .cmi files.
This is used to prevent depending on a unit compiled with -unsafe-string
when the compiler has been *configured* with -safe-string.  This is not
100% bullet-proof, since the unsafe_string marker is not propagated
transitively, so it is possible to "hide" it by going through an
intermediate compilation unit compiled with -safe-string (with a
compiled configure without -safe-string).  But this should catch most
cases of old files staying around produced by a compiler not configured
with -safe-string.
2016-07-19 14:28:52 +02:00
alainfrisch 32f0e2120c Detect unused module declarations. 2016-07-18 10:35:19 +02:00
Jacques Garrigue 3cb6d6c702 PR#7233: GADT equations for non-local abstract types 2016-06-13 09:25:31 +09:00
Jacques Garrigue 5331b57010 keep local constraints in Env.summary 2016-05-11 08:38:34 +09:00
Jacques Garrigue d2c6be000a add locally created types to Env.local_constraints 2016-05-09 09:38:07 -04:00
Jacques Garrigue deb1535f42 separate local constraints from types in Env.t, and use it for local open in patterns 2016-05-09 09:38:07 -04:00