Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Semantic diffings for functor types and applications #9331

Merged
merged 92 commits into from
Apr 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
b60bb45
Add module to compute edit distance generically.
Drup Feb 24, 2020
5790a79
Expose printers for module exprs.
Drup Feb 24, 2020
2fed5ec
Add tag for direct styled output.
Drup Feb 24, 2020
986f64e
Fix format boxes in Includecode.
Drup Feb 24, 2020
190102e
Add printers for functor parameters without a returned signature.
Drup Feb 24, 2020
cc46c93
Improve error messages for functor signatures and applications.
Drup Feb 24, 2020
d2bb124
Add tests for functor signature and parameter errors.
Drup Feb 24, 2020
685525a
add an example of variadic functor
Octachron Feb 24, 2020
ef0aa4f
Changes for functor errors.
Drup Feb 24, 2020
d2c6163
update dune file
Octachron Mar 13, 2020
7d63058
Compute list elements earlier with Includemod.dlist
Octachron Mar 26, 2020
a5c886e
Split the application and inclusion update
Octachron Mar 13, 2020
35ab293
Edit_distance with dynamical resizing
Octachron Mar 24, 2020
a11943b
Pretty error message for variadic functors
Octachron Mar 24, 2020
c3a3871
More test for exotic functors
Octachron Mar 25, 2020
f67af41
Pretty error message for variadic functor inclusion
Octachron Apr 1, 2020
38ff391
Fix missing cmi case
Octachron Aug 28, 2020
2e8a228
Improved functor errors with extra arguments
Octachron Aug 27, 2020
e4ba09e
Make the code a bit cleaner in Includemod.
Drup Nov 10, 2020
dabfafa
Use $name as generate name in diffing errors.
Drup Nov 10, 2020
8e31ace
Capitalize error messages when appropriate.
Drup Nov 10, 2020
2c52ed0
Rename Compilerlibs_edit_distance into Diffing.
Drup Nov 10, 2020
b3d07bc
Formalize the internal API for Diffing.Matrix.
Drup Nov 10, 2020
c270561
Simplifies the external API for Diffing.
Drup Nov 10, 2020
2bb0ee1
First shot at documenting Diffing.
Drup Nov 10, 2020
ab2557a
Put more constraints on expansions during variadic diff.
Drup Nov 10, 2020
c659209
Fix a bug in the rewrite of select_best_proposition.
Drup Nov 10, 2020
f52d5fb
Code simplification and debugging help in Diffing.
Drup Nov 12, 2020
3e8a605
Fix selection of final state in the diff matrix.
Drup Nov 12, 2020
c87f4e9
Prefer diagonales when diffing.
Drup Nov 12, 2020
42eef42
Add Leo's example.
Drup Nov 12, 2020
ba32911
More code simplification.
Drup Nov 12, 2020
a1360f1
Use more labels in Env.
Drup Nov 13, 2020
f0224af
Lookup all arguments of a functor prior to application in Env.
Drup Nov 13, 2020
d0ade10
Fix some english.
Drup Nov 13, 2020
cfc6748
Check typo.
Drup Nov 13, 2020
f2eb609
Attempt at a clearer description.
Drup Nov 13, 2020
45ef5b0
Some internal comments.
Drup Nov 13, 2020
b247b01
Shorter messages for one argument diff
Octachron Nov 17, 2020
04cc60f
Fix empty line in error messages
Octachron Nov 17, 2020
178c19f
Control alignment with tboxes
Octachron Nov 18, 2020
9284705
Fix misaligned conflict explanation
Octachron Nov 18, 2020
67b83b8
Suberrors in signature require an expansion token
Octachron Nov 18, 2020
7a4cab4
Check typo
Octachron Nov 26, 2020
310f038
diffing: avoid copy in the non-extension case
Octachron Nov 26, 2020
805536a
diffing: more explict name for update kind
Octachron Nov 26, 2020
6576d02
diffing: more descriptions and some renaming
Octachron Nov 26, 2020
152c434
Make the selection of final cell more principled.
Drup Nov 26, 2020
9ece0bd
Fix comment.
Drup Nov 26, 2020
2ac73a9
diffing: update printing env for functor params
Octachron Nov 26, 2020
fb6b24a
copyright headers
Octachron Dec 1, 2020
ab4c5ff
diffing: update documentation
Octachron Dec 1, 2020
36f0463
diffing: coherent functor argument printing
Octachron Dec 3, 2020
43924ef
diffing: add parentheses in functor (sig end)
Octachron Dec 10, 2020
4f461f6
ci: update .depend
Octachron Dec 16, 2020
c8434c5
review: add an application summary type
Octachron Mar 5, 2021
d8ac5f8
review: remode metadata type
Octachron Mar 5, 2021
f602016
review: white spaces
Octachron Mar 5, 2021
4b7d5f2
review: unused parameters
Octachron Mar 5, 2021
d161f96
review: use symptom uniformly
Octachron Mar 5, 2021
1e9339e
review: remove dont_match
Octachron Mar 9, 2021
ef622b6
review: simplification after dont_match_removal
Octachron Mar 9, 2021
f9e6014
review: module types are not path
Octachron Mar 9, 2021
6c19093
review: style
Octachron Mar 9, 2021
48937c5
review: rename need_expansion
Octachron Mar 9, 2021
0cd4799
review: Option.map formatting
Octachron Mar 9, 2021
5baced3
review: Pp.{got,expected}
Octachron Mar 9, 2021
7c4cd46
review: split includemod module
Octachron Mar 10, 2021
1bb74bb
review: split module with header files
Octachron Mar 10, 2021
62e2179
review: only one new module
Octachron Mar 10, 2021
c1c7bfc
review: split functor diff modules
Octachron Mar 10, 2021
f219302
review: remove unused argument in functor diffs
Octachron Mar 10, 2021
e263430
review: rename arg' and move in the right branch
Octachron Mar 10, 2021
7d1d25d
review: less adhoc printing for functor param errors
Octachron Mar 10, 2021
605b72f
review: small tweaks
Octachron Mar 11, 2021
c7aeda4
review: no more sub messages
Octachron Mar 11, 2021
b951b72
review: fix previous commit
Octachron Mar 11, 2021
1d360f9
review: includemod_errorprinter small simplifications
Octachron Mar 11, 2021
d8e092d
review: the great reorganization
Octachron Mar 11, 2021
3d1d908
review: specialized error message for single argument and change
Octachron Mar 12, 2021
c16f158
includemod_errorprinter: remove unused field
Octachron Mar 12, 2021
39a4300
includemod_errorprinter: simplify functor arg description
Octachron Mar 12, 2021
217f93f
review: remove polymorphic variant
Octachron Mar 12, 2021
2649f01
includemod_errorprinter: simplify Functor_suberror
Octachron Mar 12, 2021
5a35a74
review: Short_name ⇒ With_shorthand
Octachron Mar 12, 2021
29f17d4
includemod_errorprinter: more explicit names
Octachron Mar 12, 2021
4fad788
probable fix: remove Btype.snapshot
Octachron Mar 12, 2021
efc9146
includemod_errorprinter: duclicate Inclusion.insert
Octachron Mar 12, 2021
98a2375
includemod_errorprinter: better name
Octachron Mar 12, 2021
25eb73c
please depend CI
Octachron Mar 12, 2021
8e512f1
review: use find_modtype_expansion
Octachron Apr 6, 2021
2074959
review: use id$n for ident names and not p$n
Octachron Apr 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
51 changes: 47 additions & 4 deletions .depend
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ utils/consistbl.cmx : \
utils/consistbl.cmi
utils/consistbl.cmi : \
utils/misc.cmi
utils/diffing.cmo : \
utils/diffing.cmi
utils/diffing.cmx : \
utils/diffing.cmi
utils/diffing.cmi :
utils/domainstate.cmo : \
utils/domainstate.cmi
utils/domainstate.cmx : \
Expand Down Expand Up @@ -703,17 +708,17 @@ typing/includemod.cmo : \
typing/primitive.cmi \
typing/predef.cmi \
typing/path.cmi \
typing/oprint.cmi \
typing/mtype.cmi \
utils/misc.cmi \
parsing/longident.cmi \
parsing/location.cmi \
typing/includecore.cmi \
typing/includeclass.cmi \
typing/ident.cmi \
typing/env.cmi \
utils/diffing.cmi \
typing/ctype.cmi \
file_formats/cmt_format.cmi \
utils/clflags.cmi \
parsing/builtin_attributes.cmi \
typing/btype.cmi \
typing/includemod.cmi
Expand All @@ -725,29 +730,65 @@ typing/includemod.cmx : \
typing/primitive.cmx \
typing/predef.cmx \
typing/path.cmx \
typing/oprint.cmx \
typing/mtype.cmx \
utils/misc.cmx \
parsing/longident.cmx \
parsing/location.cmx \
typing/includecore.cmx \
typing/includeclass.cmx \
typing/ident.cmx \
typing/env.cmx \
utils/diffing.cmx \
typing/ctype.cmx \
file_formats/cmt_format.cmx \
utils/clflags.cmx \
parsing/builtin_attributes.cmx \
typing/btype.cmx \
typing/includemod.cmi
typing/includemod.cmi : \
typing/types.cmi \
typing/typedtree.cmi \
typing/path.cmi \
parsing/longident.cmi \
parsing/location.cmi \
typing/includecore.cmi \
typing/ident.cmi \
typing/env.cmi \
utils/diffing.cmi \
typing/ctype.cmi
typing/includemod_errorprinter.cmo : \
typing/types.cmi \
typing/typedtree.cmi \
typing/printtyp.cmi \
typing/path.cmi \
typing/oprint.cmi \
utils/misc.cmi \
parsing/location.cmi \
typing/includemod.cmi \
typing/includecore.cmi \
typing/includeclass.cmi \
typing/ident.cmi \
typing/env.cmi \
utils/diffing.cmi \
utils/clflags.cmi \
typing/includemod_errorprinter.cmi
typing/includemod_errorprinter.cmx : \
typing/types.cmx \
typing/typedtree.cmx \
typing/printtyp.cmx \
typing/path.cmx \
typing/oprint.cmx \
utils/misc.cmx \
parsing/location.cmx \
typing/includemod.cmx \
typing/includecore.cmx \
typing/includeclass.cmx \
typing/ident.cmx \
typing/env.cmx \
utils/diffing.cmx \
utils/clflags.cmx \
typing/includemod_errorprinter.cmi
typing/includemod_errorprinter.cmi : \
typing/includemod.cmi
typing/mtype.cmo : \
typing/types.cmi \
typing/subst.cmi \
Expand Down Expand Up @@ -1531,6 +1572,7 @@ typing/typemod.cmo : \
parsing/longident.cmi \
parsing/location.cmi \
utils/load_path.cmi \
typing/includemod_errorprinter.cmi \
typing/includemod.cmi \
typing/ident.cmi \
typing/env.cmi \
Expand Down Expand Up @@ -1563,6 +1605,7 @@ typing/typemod.cmx : \
parsing/longident.cmx \
parsing/location.cmx \
utils/load_path.cmx \
typing/includemod_errorprinter.cmx \
typing/includemod.cmx \
typing/ident.cmx \
typing/env.cmx \
Expand Down
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Working version

### Language features:

- #9331: Improve error messages for functor application and functor types.
(Florian Angeletti and Gabriel Radanne, review by Leo White)

- #10013: Let-punning
Allow 'let* x in ...' and 'let%ext x in ...' as shorthand for
'let* x = x in ...' and 'let%ext x = x in ...' respectively.
Expand Down
6 changes: 4 additions & 2 deletions compilerlibs/Makefile.compilerlibs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ UTILS=utils/config.cmo utils/build_path_prefix_map.cmo utils/misc.cmo \
utils/terminfo.cmo utils/ccomp.cmo utils/warnings.cmo \
utils/consistbl.cmo utils/strongly_connected_components.cmo \
utils/targetint.cmo utils/int_replace_polymorphic_compare.cmo \
utils/domainstate.cmo utils/binutils.cmo utils/lazy_backtrack.cmo
utils/domainstate.cmo utils/binutils.cmo utils/lazy_backtrack.cmo \
utils/diffing.cmo
UTILS_CMI=

PARSING=parsing/location.cmo parsing/longident.cmo \
Expand All @@ -57,7 +58,8 @@ TYPING=typing/ident.cmo typing/path.cmo \
typing/mtype.cmo typing/envaux.cmo typing/includecore.cmo \
typing/tast_iterator.cmo typing/tast_mapper.cmo typing/stypes.cmo \
file_formats/cmt_format.cmo typing/cmt2annot.cmo typing/untypeast.cmo \
typing/includemod.cmo typing/typetexp.cmo typing/printpat.cmo \
typing/includemod.cmo typing/includemod_errorprinter.cmo \
typing/typetexp.cmo typing/printpat.cmo \
typing/patterns.cmo typing/parmatch.cmo \
typing/typedecl_properties.cmo typing/typedecl_variance.cmo \
typing/typedecl_unboxed.cmo typing/typedecl_immediacy.cmo \
Expand Down
5 changes: 3 additions & 2 deletions dune
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
config build_path_prefix_map misc identifiable numbers arg_helper clflags
profile terminfo ccomp warnings consistbl strongly_connected_components
targetint load_path int_replace_polymorphic_compare binutils local_store
lazy_backtrack
lazy_backtrack diffing

;; PARSING
location longident docstrings syntaxerr ast_helper camlinternalMenhirLib
Expand All @@ -59,7 +59,8 @@
ident path primitive types btype oprint subst predef datarepr
cmi_format persistent_env env type_immediacy
typedtree printtyped ctype printtyp includeclass mtype envaux includecore
tast_iterator tast_mapper cmt_format untypeast includemod
tast_iterator tast_mapper cmt_format untypeast
includemod includemod_errorprinter
typetexp patterns printpat parmatch stypes typedecl typeopt rec_check
typecore
typeclass typemod typedecl_variance typedecl_properties typedecl_immediacy
Expand Down
10 changes: 8 additions & 2 deletions parsing/location.ml
Original file line number Diff line number Diff line change
Expand Up @@ -721,13 +721,19 @@ let batch_mode_printer : report_printer =
let pp_txt ppf txt = Format.fprintf ppf "@[%t@]" txt in
let pp self ppf report =
setup_colors ();
(* Make sure we keep [num_loc_lines] updated. *)
(* Make sure we keep [num_loc_lines] updated.
The tabulation box is here to give submessage the option
to be aligned with the main message box
*)
print_updating_num_loc_lines ppf (fun ppf () ->
Format.fprintf ppf "@[<v>%a%a: %a%a@]@."
Format.fprintf ppf "@[<v>%a%a%a: %a%a%a%a@]@."
Format.pp_open_tbox ()
(self.pp_main_loc self report) report.main.loc
(self.pp_report_kind self report) report.kind
Format.pp_set_tab ()
(self.pp_main_txt self report) report.main.txt
(self.pp_submsgs self report) report.sub
Format.pp_close_tbox ()
) ()
in
let pp_report_kind _self _ ppf = function
Expand Down
1 change: 1 addition & 0 deletions parsing/pprintast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1692,3 +1692,4 @@ let core_type = core_type reset_ctxt
let pattern = pattern reset_ctxt
let signature = signature reset_ctxt
let structure = structure reset_ctxt
let module_expr = module_expr reset_ctxt
2 changes: 2 additions & 0 deletions parsing/pprintast.mli
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ val signature: Format.formatter -> Parsetree.signature -> unit
val structure: Format.formatter -> Parsetree.structure -> unit
val string_of_structure: Parsetree.structure -> string

val module_expr: Format.formatter -> Parsetree.module_expr -> unit

val toplevel_phrase : Format.formatter -> Parsetree.toplevel_phrase -> unit
val top_phrase: Format.formatter -> Parsetree.toplevel_phrase -> unit

Expand Down
10 changes: 6 additions & 4 deletions testsuite/tests/typing-misc/pr6416.ml
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@ Error: Signature mismatch:
sig module A : functor (X : s) -> sig end end
In module A:
Modules do not match:
functor (X : s/1) -> sig end
functor (X : s/1) -> ...
is not included in
functor (X : s/2) -> sig end
At position module A(X : <here>) : ...
Modules do not match: s/2 is not included in s/1
functor (X : s/2) -> ...
Module types do not match:
s/1
does not include
s/2
Line 5, characters 6-19:
Definition of module type s/1
Line 2, characters 2-15:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
File "pr7414_2_bad.ml", line 46, characters 28-34:
File "pr7414_2_bad.ml", line 46, characters 22-35:
46 | let module Ignore = Force(Choose) in
^^^^^^
Octachron marked this conversation as resolved.
Show resolved Hide resolved
Error: Signature mismatch:
Modules do not match:
functor () -> sig module Choice : T val r : '_weak1 list ref ref end
is not included in
functor () -> S
At position functor () -> <here>
Modules do not match:
sig module Choice : T val r : '_weak1 list ref ref end
is not included in
S
At position functor () -> <here>
Values do not match:
val r : '_weak1 list ref ref
is not included in
val r : Choice.t list ref ref
File "pr7414_2_bad.ml", line 29, characters 2-31: Expected declaration
File "pr7414_2_bad.ml", line 40, characters 8-9: Actual declaration
^^^^^^^^^^^^^
Error: Modules do not match:
functor () -> sig module Choice : T val r : '_weak1 list ref ref end
is not included in functor () -> S
Modules do not match:
sig module Choice : T val r : '_weak1 list ref ref end
is not included in
S
Values do not match:
val r : '_weak1 list ref ref
is not included in
val r : Choice.t list ref ref
File "pr7414_2_bad.ml", line 29, characters 2-31: Expected declaration
File "pr7414_2_bad.ml", line 40, characters 8-9: Actual declaration
34 changes: 15 additions & 19 deletions testsuite/tests/typing-modules-bugs/pr7414_bad.compilers.reference
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
File "pr7414_bad.ml", line 52, characters 22-28:
File "pr7414_bad.ml", line 52, characters 16-29:
52 | module Ignore = Force(Choose)
^^^^^^
Error: Signature mismatch:
Modules do not match:
functor () -> sig module Choice : T val r : '_weak1 list ref ref end
is not included in
functor () -> S
At position functor () -> <here>
Modules do not match:
sig module Choice : T val r : '_weak1 list ref ref end
is not included in
S
At position functor () -> <here>
Values do not match:
val r : '_weak1 list ref ref
is not included in
val r : Choice.t list ref ref
File "pr7414_bad.ml", line 38, characters 2-31: Expected declaration
File "pr7414_bad.ml", line 33, characters 6-7: Actual declaration
^^^^^^^^^^^^^
Error: Modules do not match:
functor () -> sig module Choice : T val r : '_weak1 list ref ref end
is not included in functor () -> S
Modules do not match:
sig module Choice : T val r : '_weak1 list ref ref end
is not included in
S
Values do not match:
val r : '_weak1 list ref ref
is not included in
val r : Choice.t list ref ref
File "pr7414_bad.ml", line 38, characters 2-31: Expected declaration
File "pr7414_bad.ml", line 33, characters 6-7: Actual declaration
4 changes: 2 additions & 2 deletions testsuite/tests/typing-modules/aliases.ml
Original file line number Diff line number Diff line change
Expand Up @@ -691,9 +691,9 @@ Error: Module type declarations do not match:
does not match
module type A = sig module M = F(List) end
At position module type A = <here>
Modules do not match:
Module types do not match:
sig module M = F(List) end
is not included in
is not equal to
sig module M = F(List) end
At position module type A = sig module M : <here> end
Module F(List) cannot be aliased
Expand Down
28 changes: 12 additions & 16 deletions testsuite/tests/typing-modules/applicative_functor_type.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ type t = Set.Make(M).t
Line 1, characters 9-22:
1 | type t = Set.Make(M).t
^^^^^^^^^^^^^
Error: The type of M does not match Set.Make's parameter
Modules do not match:
sig type t = M.t val equal : 'a -> 'a -> bool end
is not included in
Set.OrderedType
The value `compare' is required but not provided
File "set.mli", line 55, characters 4-31: Expected declaration
Error: Modules do not match:
sig type t = M.t val equal : 'a -> 'a -> bool end
is not included in Set.OrderedType
The value `compare' is required but not provided
File "set.mli", line 55, characters 4-31: Expected declaration
|} ]


Expand All @@ -43,15 +41,13 @@ type t = F(M).t
Line 1, characters 9-15:
1 | type t = F(M).t
^^^^^^
Error: The type of M does not match F's parameter
Modules do not match:
sig type t = M.t val equal : 'a -> 'a -> bool end
is not included in
sig type t = M.t val equal : unit end
Values do not match:
val equal : 'a -> 'a -> bool
is not included in
val equal : unit
Error: Modules do not match:
sig type t = M.t val equal : 'a -> 'a -> bool end
is not included in sig type t = M.t val equal : unit end
Values do not match:
val equal : 'a -> 'a -> bool
is not included in
val equal : unit
|} ]


Expand Down