Skip to content

Commit

Permalink
Merge pull request ocaml#10599 from stedolan/lazysigs
Browse files Browse the repository at this point in the history
Evaluate signature substitutions lazily
  • Loading branch information
stedolan committed Sep 7, 2021
2 parents cd105d9 + c35fc2c commit fa43873
Show file tree
Hide file tree
Showing 16 changed files with 637 additions and 283 deletions.
3 changes: 3 additions & 0 deletions .depend
Expand Up @@ -1195,6 +1195,7 @@ typing/subst.cmo : \
utils/misc.cmi \
parsing/location.cmi \
utils/local_store.cmi \
utils/lazy_backtrack.cmi \
typing/ident.cmi \
utils/clflags.cmi \
typing/btype.cmi \
Expand All @@ -1207,6 +1208,7 @@ typing/subst.cmx : \
utils/misc.cmx \
parsing/location.cmx \
utils/local_store.cmx \
utils/lazy_backtrack.cmx \
typing/ident.cmx \
utils/clflags.cmx \
typing/btype.cmx \
Expand All @@ -1215,6 +1217,7 @@ typing/subst.cmx : \
typing/subst.cmi : \
typing/types.cmi \
typing/path.cmi \
parsing/parsetree.cmi \
parsing/location.cmi \
typing/ident.cmi
typing/tast_iterator.cmo : \
Expand Down
3 changes: 3 additions & 0 deletions Changes
Expand Up @@ -130,6 +130,9 @@ Working version
- #10555: Do not use ghost locations for type constraints
(Nicolás Ojeda Bär, report by Anton Bachin, review by Thomas Refis)

- #10559: Evaluate signature substitutions lazily
(Stephen Dolan, review by Leo White)

### Build system:

### Bug fixes:
Expand Down
Binary file modified boot/ocamlc
Binary file not shown.
Binary file modified boot/ocamllex
Binary file not shown.
18 changes: 9 additions & 9 deletions testsuite/tests/shadow_include/shadow_all.ml
Expand Up @@ -304,7 +304,7 @@ module NN :
val unit : unit
external e : unit -> unit = "%identity"
module M = N.M
module type T = sig end
module type T = N.T
exception E
type ext = N.ext = ..
type ext += C
Expand All @@ -329,7 +329,7 @@ module Type :
val unit : unit
external e : unit -> unit = "%identity"
module M = N.M
module type T = sig end
module type T = N.T
exception E
type ext = N.ext = ..
type ext += C
Expand All @@ -352,7 +352,7 @@ module Module :
val unit : unit
external e : unit -> unit = "%identity"
module M = N.M
module type T = sig end
module type T = N.T
exception E
type ext = N.ext = ..
type ext += C
Expand All @@ -370,12 +370,12 @@ end
[%%expect{|
module Module_type :
sig
module type U = sig end
module type U = N.T
type t = N.t
val unit : unit
external e : unit -> unit = "%identity"
module M = N.M
module type T = sig end
module type T = N.T
exception E
type ext = N.ext = ..
type ext += C
Expand All @@ -398,7 +398,7 @@ module Exception :
val unit : unit
external e : unit -> unit = "%identity"
module M = N.M
module type T = sig end
module type T = N.T
exception E
type ext = N.ext = ..
type ext += C
Expand All @@ -421,7 +421,7 @@ module Extension :
val unit : unit
external e : unit -> unit = "%identity"
module M = N.M
module type T = sig end
module type T = N.T
exception E
type ext = N.ext = ..
type ext += C
Expand All @@ -444,7 +444,7 @@ module Class :
val unit : unit
external e : unit -> unit = "%identity"
module M = N.M
module type T = sig end
module type T = N.T
exception E
type ext = N.ext = ..
type ext += C
Expand All @@ -467,7 +467,7 @@ module Class_type :
val unit : unit
external e : unit -> unit = "%identity"
module M = N.M
module type T = sig end
module type T = N.T
exception E
type ext = N.ext = ..
type ext += C
Expand Down
24 changes: 5 additions & 19 deletions testsuite/tests/typing-modules/functors.ml
Expand Up @@ -1310,22 +1310,14 @@ module Add_one' :
module type t = arg -> sig type arg = A.arg end
end
module Add_one :
sig
type witness
module M = Add_one'.M
module type t = arg -> sig type arg = A.arg end
end
sig type witness module M = Add_one'.M module type t = Add_one'.t end
module Add_three' :
sig
module M : arg -> arg -> arg -> sig type arg = A.arg end
module type t = arg -> arg -> arg -> sig type arg = A.arg end
end
module Add_three :
sig
module M = Add_three'.M
module type t = arg -> arg -> arg -> sig type arg = A.arg end
type witness
end
sig module M = Add_three'.M module type t = Add_three'.t type witness end
Line 22, characters 21-43:
22 | module Wrong_intro = F(Add_three')(A)(A)(A)
^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -1336,10 +1328,7 @@ Error: The functor application is ill-typed.
functor (X : $T1) arg arg arg -> ...
1. Modules do not match:
Add_three' :
sig
module M = Add_three'.M
module type t = arg -> arg -> arg -> sig type arg = A.arg end
end
sig module M = Add_three'.M module type t = Add_three'.t end
is not included in
$T1 = sig type witness module type t module M : t end
The type `witness' is required but not provided
Expand All @@ -1360,10 +1349,7 @@ Error: The functor application is ill-typed.
functor (X : ...) arg arg arg -> ...
1. The following extra argument is provided
Add_one' :
sig
module M = Add_one'.M
module type t = arg -> sig type arg = A.arg end
end
sig module M = Add_one'.M module type t = Add_one'.t end
2. Module Add_three matches the expected module type
3. Module A matches the expected module type arg
4. Module A matches the expected module type arg
Expand All @@ -1388,7 +1374,7 @@ Error: The functor application is ill-typed.
sig
type witness = Add_one.witness
module M = Add_one'.M
module type t = arg -> sig type arg = A.arg end
module type t = Add_one.t
end
2. Module Add_three matches the expected module type
3. Module A matches the expected module type arg
Expand Down

0 comments on commit fa43873

Please sign in to comment.