Commit Graph

304 Commits (master)

Author SHA1 Message Date
Gabriel Scherer f794d799ad typing: fix the scope of extension constructor declarations
fixes #9970
2020-11-23 14:30:59 +01:00
Jacques Garrigue b47c34912c
Mark datatypes as injective in recursive module approximations (#10029) 2020-11-20 16:29:23 +09:00
Fourchaux 44e6cf4e0f
typos (#9806) 2020-07-28 12:22:03 +01:00
Jacques Garrigue 46cec117a4
Fix #9721: Injectivity and recursive modules (#9727) 2020-07-07 09:04:23 +02:00
Leo White b4361282c1 Fix PR#7897 2020-06-26 12:35:35 +01:00
Gabriel Scherer 7068266b32 Typemod.merge_constraint: be careful about the typing environments
This PR fixes an old bug in the interaction between [merge_constraint]
and [Typedecl.transl_with_constraint], where
variance (and now separability) are recomputed in an invalid type
environment. See #9624 and the new tests.
2020-06-03 14:33:50 +02:00
Gabriel Scherer ec74335158 typedecl: prevent the mistake of not updating transl_with_constraint 2020-05-27 22:18:06 +02:00
Gabriel Scherer 9b1bfc3b7c typedecl: correct update separability in transl_with_constraint
fixes #9607
2020-05-27 21:32:36 +02:00
Thomas Refis e4de6c19b1 use uid for usage warnings 2020-03-05 13:35:12 +01:00
Thomas Refis d52dd5c33e Add a unique id to every signature item 2020-03-05 13:34:12 +01:00
Rodolphe Lepigre 15a6ff229d typedecl: use the new Separability implementation, remove old code
Because this changes the separability of standard library types, and
those separabilities are stored in the .cmi files, this commit changes
the .cmi files in the standard libraries in way that appear to require
a bootstrap (it looks like some part of the stdlib is built with
boot/ocamlc and others with ocamlc, and the two should produce/expect
the same .cmi exactly). The bootstrap will come as a separate commit.
2020-01-28 12:09:33 +01:00
Gabriel Scherer 358c7cecd5 add separability signatures in type declarations
(this changes the .cmi format and thus requires a bootstrap,
to follow as a separate commit)

(includes bug fixes by Rodolphe Lepigre)
2020-01-28 11:39:52 +01:00
Rodolphe Lepigre 20b62c8386 Cleaned up [@@unbox] validity check. 2020-01-28 11:39:52 +01:00
Florian Angeletti ee32976da1 reworded errors for non-regular structural types
* explicitly mention that the type definition is non-regular
* avoid implicit permutation in type parameters
* don't try to propose a "fix"
2019-10-30 10:02:31 +01:00
Florian Angeletti 816a5088e0 Avoid duplicated mark_loops 2019-10-17 10:03:58 +02:00
Jeremie Dimino 2d31ebfc8b Add support for [@@immediate64]
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2019-09-24 07:56:15 +01:00
Leo White c19e8b2350 Refactor environment lookup functions 2019-08-15 15:56:50 +01:00
Rian Douglas 1cd94ad072 Changed to using a Variant for the Variance, instead of a bare int 2019-08-09 12:03:28 -07: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
Leo White acd06f1eff Remove Misc.may_map and similar 2019-05-23 16:27:58 +01:00
Jacques Garrigue 4fe08b25d6
Fix #7851 by checking type declaration coherence for recursive modules (#8570) 2019-04-19 10:57:55 +09:00
Rodolphe Lepigre ca227428f4 Typedecl: split immediacy to a separate unit Typedecl_variance
get_unboxed_type_representation is used in several other modules, and
split into its own Typedecl_unboxed unit.

(pair-programming with Gabriel Scherer)
2018-11-23 12:05:33 +01:00
Gabriel Scherer 24ea989c02 Typedecl: split variance to a separate unit Typedecl_variance
(pair-programming with Rodolphe Lepigre)
2018-11-23 12:05:33 +01:00
Gabriel Scherer 0e0b10fd75 Typedecl: split abstract properties to a separate unit Typedecl_properties
(pair-programming with Rodolphe Lepigre)
2018-11-23 12:03:11 +01:00
Leo White 111d4e1827 Remove positions from paths 2018-11-21 03:39:34 -05:00
Gabriel Scherer 7b29c553fd typedecl: refactor variance requirements to present a unified pipable interface 2018-11-18 15:59:34 +01:00
Gabriel Scherer 1128d66c8a typedecl: remove the location from variance requirements
The location can always be reconstructed from `decl.type_loc`. Note
however that variance-computation functions, in particular
`compute_variance_extension` and its callee (`compute_variance_gadt`,
etc.) need to be passed both the requirement and the location, despite
the fact that they also take a `decl` parameter: there are other
use-cases where the location is not the location of the type
declaration -- when processing an extension to an existing type
declaration.
2018-11-18 15:42:14 +01:00
Gabriel Scherer 6a8afa15a6 typedecl: port immediacy computation to the new generic scheme 2018-11-18 14:56:11 +01:00
Gabriel Scherer 0efaac6eec introduce a generic structure for "type-declaration properties"
Also included are a generic combinator, and a port of the variance
computation to the generic scheme -- without both those things, we
wouldn't know we have the right (internal) interface.
2018-11-18 14:56:11 +01:00
Gabriel Scherer 929fe9d09b typedecl: split the fixpoint computations for variance and immediacy
This change makes the code simpler and easier to extend. It also
avoids useless computation: the two fixpoints may take a different
number of iterations to converge, and the previous code would compute
both properties as long as one of them hadn't converged.
2018-11-18 14:56:11 +01:00
Gabriel Scherer 000795890e rename Typedecl.compute_variance_decls into compute_variance_class_decls 2018-11-18 14:53:52 +01:00
Alain Frisch 2e5b9d1ef1
"Alerts" as a generalization of "deprecated" (#1804) 2018-11-15 09:51:35 +01:00
Florian Angeletti 3de40984ba a type for unification traces 2018-10-17 17:27:16 +02:00
Gabriel Scherer 494af09079
Merge pull request #2091 from Armael/redefine_unit
Add a warning on type declarations "type t = ()"
2018-10-06 07:39:47 +02:00
Armaël Guéneau 72f472c860 Add a warning triggered on type declarations "type t = ()"
These are most likely a mistake for "type t = unit", but still valid, and lead
to quite confusing error messages afterwards because now `()` denotes two
different incompatible constructors.
2018-10-05 12:12:26 +02: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 e452ac15ab create a new scope whenever we create new scoped idents 2018-09-21 11:48:46 -04:00
Thomas Refis edf310ec28 properly scope idents
- when including: the elements are rescoped to the current level (as
well as being given a fresh stamp, which was already the case)
- extension constructors idents cannot be local: they can be used as
types when the constructor's argument is an inlined record. They must be
given a scope
- in check_recmod_inclusion: create a new scope at each iteration
- when checking that type declarations inside recursive modules are well
founded, we now take a generic instance of the declaration (this is
reminiscent of what is done in Ctype.moregeneral)
2018-09-21 11:47:44 -04:00
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
Gabriel Scherer 85785b173a parsetree: make sure that all nodes that store attributes also store a location
Florian Angeletti and myself ran into a problem when trying to use attributes
for ellision of parts of manual example. We wanted to be turn any ast-node
marked with the [@ellipsis] attribute into "..." in the rendering of the
corresponding code block, but for this we need the location of the
attributed node, and it turns out that some constructions supported
attributes without carrying a location:
- Rtag in row_field
- Otag in object_field
- type_exception record
- type_extension record

We added locations in all those positions, guaranteeing the invariant
that all nodes to which attributes can be attached have a precise
position.
2018-08-20 19:57:47 +02:00
Nicolás Ojeda Bär f95f8a262c
Merge pull request #1977 from nojb/fix_warning_attributes_type_declarations
Fix handling of warning attribute attached to type declarations
2018-08-09 21:02:25 +02:00
Nicolás Ojeda Bär 2eb0fce682 Fix ppwarning regression 2018-08-09 13:41:49 +02:00
Nicolás Ojeda Bär 1348a3a75f Use auxiliary function 2018-08-09 12:42:48 +02:00
Nicolás Ojeda Bär 28284cdd6c Guard one more instance of Env.add_type 2018-08-09 12:34:56 +02:00
Nicolás Ojeda Bär dc5a38f8b0 Fix handling of warning attribute attached to type declarations 2018-08-09 12:31:56 +02:00
Thomas Refis c00a46e2cf more precise extension mismatch error messages 2018-08-09 10:18:54 +01: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 8cc2f467fa Fix the syntax of a couple format boxes 2018-08-02 16:02:38 +02:00
Stefan Muenzel b075751685 Use format boxes or newlines to line-wrap some errors/warnings. 2018-07-30 16:12:02 +01:00