Skip to content

Commit fa43873

Browse files
authored
Merge pull request #10599 from stedolan/lazysigs
Evaluate signature substitutions lazily
2 parents cd105d9 + c35fc2c commit fa43873

File tree

16 files changed

+637
-283
lines changed

16 files changed

+637
-283
lines changed

.depend

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,6 +1195,7 @@ typing/subst.cmo : \
11951195
utils/misc.cmi \
11961196
parsing/location.cmi \
11971197
utils/local_store.cmi \
1198+
utils/lazy_backtrack.cmi \
11981199
typing/ident.cmi \
11991200
utils/clflags.cmi \
12001201
typing/btype.cmi \
@@ -1207,6 +1208,7 @@ typing/subst.cmx : \
12071208
utils/misc.cmx \
12081209
parsing/location.cmx \
12091210
utils/local_store.cmx \
1211+
utils/lazy_backtrack.cmx \
12101212
typing/ident.cmx \
12111213
utils/clflags.cmx \
12121214
typing/btype.cmx \
@@ -1215,6 +1217,7 @@ typing/subst.cmx : \
12151217
typing/subst.cmi : \
12161218
typing/types.cmi \
12171219
typing/path.cmi \
1220+
parsing/parsetree.cmi \
12181221
parsing/location.cmi \
12191222
typing/ident.cmi
12201223
typing/tast_iterator.cmo : \

Changes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ Working version
130130
- #10555: Do not use ghost locations for type constraints
131131
(Nicolás Ojeda Bär, report by Anton Bachin, review by Thomas Refis)
132132

133+
- #10559: Evaluate signature substitutions lazily
134+
(Stephen Dolan, review by Leo White)
135+
133136
### Build system:
134137

135138
### Bug fixes:

boot/ocamlc

6.78 KB
Binary file not shown.

boot/ocamllex

-360 Bytes
Binary file not shown.

testsuite/tests/shadow_include/shadow_all.ml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ module NN :
304304
val unit : unit
305305
external e : unit -> unit = "%identity"
306306
module M = N.M
307-
module type T = sig end
307+
module type T = N.T
308308
exception E
309309
type ext = N.ext = ..
310310
type ext += C
@@ -329,7 +329,7 @@ module Type :
329329
val unit : unit
330330
external e : unit -> unit = "%identity"
331331
module M = N.M
332-
module type T = sig end
332+
module type T = N.T
333333
exception E
334334
type ext = N.ext = ..
335335
type ext += C
@@ -352,7 +352,7 @@ module Module :
352352
val unit : unit
353353
external e : unit -> unit = "%identity"
354354
module M = N.M
355-
module type T = sig end
355+
module type T = N.T
356356
exception E
357357
type ext = N.ext = ..
358358
type ext += C
@@ -370,12 +370,12 @@ end
370370
[%%expect{|
371371
module Module_type :
372372
sig
373-
module type U = sig end
373+
module type U = N.T
374374
type t = N.t
375375
val unit : unit
376376
external e : unit -> unit = "%identity"
377377
module M = N.M
378-
module type T = sig end
378+
module type T = N.T
379379
exception E
380380
type ext = N.ext = ..
381381
type ext += C
@@ -398,7 +398,7 @@ module Exception :
398398
val unit : unit
399399
external e : unit -> unit = "%identity"
400400
module M = N.M
401-
module type T = sig end
401+
module type T = N.T
402402
exception E
403403
type ext = N.ext = ..
404404
type ext += C
@@ -421,7 +421,7 @@ module Extension :
421421
val unit : unit
422422
external e : unit -> unit = "%identity"
423423
module M = N.M
424-
module type T = sig end
424+
module type T = N.T
425425
exception E
426426
type ext = N.ext = ..
427427
type ext += C
@@ -444,7 +444,7 @@ module Class :
444444
val unit : unit
445445
external e : unit -> unit = "%identity"
446446
module M = N.M
447-
module type T = sig end
447+
module type T = N.T
448448
exception E
449449
type ext = N.ext = ..
450450
type ext += C
@@ -467,7 +467,7 @@ module Class_type :
467467
val unit : unit
468468
external e : unit -> unit = "%identity"
469469
module M = N.M
470-
module type T = sig end
470+
module type T = N.T
471471
exception E
472472
type ext = N.ext = ..
473473
type ext += C

testsuite/tests/typing-modules/functors.ml

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,22 +1310,14 @@ module Add_one' :
13101310
module type t = arg -> sig type arg = A.arg end
13111311
end
13121312
module Add_one :
1313-
sig
1314-
type witness
1315-
module M = Add_one'.M
1316-
module type t = arg -> sig type arg = A.arg end
1317-
end
1313+
sig type witness module M = Add_one'.M module type t = Add_one'.t end
13181314
module Add_three' :
13191315
sig
13201316
module M : arg -> arg -> arg -> sig type arg = A.arg end
13211317
module type t = arg -> arg -> arg -> sig type arg = A.arg end
13221318
end
13231319
module Add_three :
1324-
sig
1325-
module M = Add_three'.M
1326-
module type t = arg -> arg -> arg -> sig type arg = A.arg end
1327-
type witness
1328-
end
1320+
sig module M = Add_three'.M module type t = Add_three'.t type witness end
13291321
Line 22, characters 21-43:
13301322
22 | module Wrong_intro = F(Add_three')(A)(A)(A)
13311323
^^^^^^^^^^^^^^^^^^^^^^
@@ -1336,10 +1328,7 @@ Error: The functor application is ill-typed.
13361328
functor (X : $T1) arg arg arg -> ...
13371329
1. Modules do not match:
13381330
Add_three' :
1339-
sig
1340-
module M = Add_three'.M
1341-
module type t = arg -> arg -> arg -> sig type arg = A.arg end
1342-
end
1331+
sig module M = Add_three'.M module type t = Add_three'.t end
13431332
is not included in
13441333
$T1 = sig type witness module type t module M : t end
13451334
The type `witness' is required but not provided
@@ -1360,10 +1349,7 @@ Error: The functor application is ill-typed.
13601349
functor (X : ...) arg arg arg -> ...
13611350
1. The following extra argument is provided
13621351
Add_one' :
1363-
sig
1364-
module M = Add_one'.M
1365-
module type t = arg -> sig type arg = A.arg end
1366-
end
1352+
sig module M = Add_one'.M module type t = Add_one'.t end
13671353
2. Module Add_three matches the expected module type
13681354
3. Module A matches the expected module type arg
13691355
4. Module A matches the expected module type arg
@@ -1388,7 +1374,7 @@ Error: The functor application is ill-typed.
13881374
sig
13891375
type witness = Add_one.witness
13901376
module M = Add_one'.M
1391-
module type t = arg -> sig type arg = A.arg end
1377+
module type t = Add_one.t
13921378
end
13931379
2. Module Add_three matches the expected module type
13941380
3. Module A matches the expected module type arg

0 commit comments

Comments
 (0)