File tree Expand file tree Collapse file tree 4 files changed +159
-0
lines changed
testsuite/tests/comprehensions Expand file tree Collapse file tree 4 files changed +159
-0
lines changed Original file line number Diff line number Diff line change @@ -311,6 +311,58 @@ Error: This expression has type float but an expression was expected of type
311
311
because it is in a range- based for iterator start index in a comprehension
312
312
| }];;
313
313
314
+ (* Using first-class module patterns isn't supported yet *)
315
+
316
+ module type S = sig
317
+ type t
318
+ val x : t
319
+ end ;;
320
+
321
+ let t = (module struct
322
+ type t = int
323
+ let x = 3
324
+ end : S );;
325
+ [%% expect {|
326
+ module type S = sig type t val x : t end
327
+ val t : (module S ) = < module >
328
+ | }];;
329
+
330
+ [| M. x for (module M : S ) in [| t |] | ];;
331
+ [%% expect {|
332
+ Line 1 , characters 19-20 :
333
+ 1 | [| M. x for (module M : S ) in [| t |] | ];;
334
+ ^
335
+ Error : Modules are not allowed in this pattern.
336
+ | }];;
337
+
338
+ [| M. x
339
+ for (module M : S ) in
340
+ [| (module struct
341
+ type t = int
342
+ let x = 3
343
+ end : S )
344
+ |]
345
+ | ];;
346
+ [%% expect {|
347
+ Line 2 , characters 15-16 :
348
+ 2 | for (module M : S ) in
349
+ ^
350
+ Error : Modules are not allowed in this pattern.
351
+ | }];;
352
+
353
+ [| M. x
354
+ for (module M : S ) in
355
+ [| (let t = t in
356
+ t)
357
+ |]
358
+ | ];;
359
+ [%% expect {|
360
+ Line 2 , characters 15-16 :
361
+ 2 | for (module M : S ) in
362
+ ^
363
+ Error : Modules are not allowed in this pattern.
364
+ | }];;
365
+
314
366
(* No duplicating variables in a for-and clause *)
315
367
316
368
[|i for i = 1 to 3 and i = 3 downto 1 | ];;
Original file line number Diff line number Diff line change @@ -409,6 +409,58 @@ Error: This expression has type float but an expression was expected of type
409
409
because it is in a range- based for iterator start index in a comprehension
410
410
| }];;
411
411
412
+ (* Using first-class module patterns isn't supported yet *)
413
+
414
+ module type S = sig
415
+ type t
416
+ val x : t
417
+ end ;;
418
+
419
+ let t = (module struct
420
+ type t = int
421
+ let x = 3
422
+ end : S );;
423
+ [%% expect {|
424
+ module type S = sig type t val x : t end
425
+ val t : (module S ) = < module >
426
+ | }];;
427
+
428
+ [: M. x for (module M : S ) in [: t :] :];;
429
+ [%% expect {|
430
+ Line 1 , characters 19-20 :
431
+ 1 | [: M. x for (module M : S ) in [: t :] :];;
432
+ ^
433
+ Error : Modules are not allowed in this pattern.
434
+ | }];;
435
+
436
+ [: M. x
437
+ for (module M : S ) in
438
+ [: (module struct
439
+ type t = int
440
+ let x = 3
441
+ end : S )
442
+ :]
443
+ :];;
444
+ [%% expect {|
445
+ Line 2 , characters 15-16 :
446
+ 2 | for (module M : S ) in
447
+ ^
448
+ Error : Modules are not allowed in this pattern.
449
+ | }];;
450
+
451
+ [: M. x
452
+ for (module M : S ) in
453
+ [: (let t = t in
454
+ t)
455
+ :]
456
+ :];;
457
+ [%% expect {|
458
+ Line 2 , characters 15-16 :
459
+ 2 | for (module M : S ) in
460
+ ^
461
+ Error : Modules are not allowed in this pattern.
462
+ | }];;
463
+
412
464
(* No duplicating variables in a for-and clause *)
413
465
414
466
[:i for i = 1 to 3 and i = 3 downto 1 :];;
Original file line number Diff line number Diff line change @@ -303,6 +303,58 @@ Error: This expression has type float but an expression was expected of type
303
303
because it is in a range- based for iterator start index in a comprehension
304
304
| }];;
305
305
306
+ (* Using first-class module patterns isn't supported yet *)
307
+
308
+ module type S = sig
309
+ type t
310
+ val x : t
311
+ end ;;
312
+
313
+ let t = (module struct
314
+ type t = int
315
+ let x = 3
316
+ end : S );;
317
+ [%% expect {|
318
+ module type S = sig type t val x : t end
319
+ val t : (module S ) = < module >
320
+ | }];;
321
+
322
+ [ M. x for (module M : S ) in [ t ] ];;
323
+ [%% expect {|
324
+ Line 1 , characters 18-19 :
325
+ 1 | [ M. x for (module M : S ) in [ t ] ];;
326
+ ^
327
+ Error : Modules are not allowed in this pattern.
328
+ | }];;
329
+
330
+ [ M. x
331
+ for (module M : S ) in
332
+ [ (module struct
333
+ type t = int
334
+ let x = 3
335
+ end : S )
336
+ ]
337
+ ];;
338
+ [%% expect {|
339
+ Line 2 , characters 14-15 :
340
+ 2 | for (module M : S ) in
341
+ ^
342
+ Error : Modules are not allowed in this pattern.
343
+ | }];;
344
+
345
+ [ M. x
346
+ for (module M : S ) in
347
+ [ (let t = t in
348
+ t)
349
+ ]
350
+ ];;
351
+ [%% expect {|
352
+ Line 2 , characters 14-15 :
353
+ 2 | for (module M : S ) in
354
+ ^
355
+ Error : Modules are not allowed in this pattern.
356
+ | }];;
357
+
306
358
(* No duplicating variables in a for-and clause *)
307
359
308
360
[i for i = 1 to 3 and i = 3 downto 1 ];;
Original file line number Diff line number Diff line change @@ -7137,6 +7137,9 @@ and type_comprehension_iterator
7137
7137
~explanation: (Comprehension_in_iterator comprehension_type)
7138
7138
seq_ty)
7139
7139
in
7140
+ (* TODO: fix handling of first-class module patterns so we can remove
7141
+ * this line. *)
7142
+ allow_modules := false ;
7140
7143
let pattern =
7141
7144
(* To understand why we can currently only provide [global] bindings for
7142
7145
the contents of sequences comprehensions iterate over, see "What
You can’t perform that action at this time.
0 commit comments