Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add record constructor to subtyping (#2007)
* Initial draft without Constant and TailVar * Restrict visibility of RemoveErrorRow to super * Create trait Subsume for UnifType and UnifRecordRows * Fix problem about {a: Type}<: {a:Type;b:Type} that was not accepted * Copy comments (general comment on subsumption and closing a record when there is a record/dictionary subsumption) * Fix problem (it was error reporting...) * Rename trait Co-authored-by: Yann Hamdaoui <[email protected]> * Correct spelling in comments Co-authored-by: Yann Hamdaoui <[email protected]> * Rename trait impl * Rename trait * Update comments * Remove subsumption function from typecheck/mod.rs * Add test * Add documentation * Rename trait (for clippy) * Add tests * Modify snapshot lsp * Update comments core/src/typecheck/subtyping.rs Co-authored-by: Yann Hamdaoui <[email protected]> * Update doc/manual/typing.md Co-authored-by: Yann Hamdaoui <[email protected]> * Modify comment * Modify comment * Revert lsp snapshot * Cosmetic improvements This commit performs minor cosmetic improvements in the code handling subtyping, mostly around comments and function interfaces. * Update snapshot test for LSP The support of subtyping for record types makes some types to be instantiated earlier than before. Given the way terms are visited, when writing something like `let f = std.array.map in ..`, `std.array.map` used to be inferred to be of a polymorphic type `forall a b. ...` and then only was instantiated (because record access is inferred, while the bound expression is checked). With the new implementation, it is instantiated as part of the subsumption rule, meaning that it'll appear differently on the LSP. All in all, both version of the data shown by the LSP (before this change and after) are meaningful, in some sense. The polymorphic type is still shown when it's part of the metadata anyway, in addition to the inferred monomorphic type. This also doesn't change which expressions are accepted or not. It's more of an artifact of when we visit terms, before or after instantiation and how those visits are intertwined with `check` and `infer`. It's not easy to revert to the previous state of affairs, and it's in fact not necessarily a good thing either: in the example above, the LSP would also show a polymorphic type for `f` - the one of `map` - while in fact `f` has a monomorphic type, so you couldn't use it in different contexts (say on an `Array Number` and later on a `Array String`). The current version is showing the real monomorphic nature of `f`. --------- Co-authored-by: Yann Hamdaoui <[email protected]> Co-authored-by: Yann Hamdaoui <[email protected]>
- Loading branch information