1
(**************************************************************)
2
(* This suite tests the pattern-matching compiler *)
3
(* it should just compile and run. *)
4
(* While compiling the following messages are normal: *)
5
(**************************************************************)
8
File "morematch.ml", line 38, characters 10-93:
9
Warning: this pattern-matching is not exhaustive.
10
Here is an example of a value that is not matched:
12
File "morematch.ml", line 376, characters 2-15:
13
Warning: this match case is unused.
14
File "morematch.ml", line 443, characters 2-7:
15
Warning: this match case is unused.
18
let test msg f arg r =
19
if f arg <> r then begin
25
type t = A | B | C | D | E | F
28
let f x = match x with
38
let g x = match x with
51
test "deux" g 9 7 ; ()
55
let g x = match x with
79
test "quatre" g 7 100 ; ()
83
File "morematch.ml", line 73, characters 2-5:
84
Warning U: this sub-pattern is unused.
85
File "morematch.ml", line 74, characters 2-3:
86
Warning U: this sub-pattern is unused.
98
test "cinq" h (2,2) 3 ;
99
test "cinq" h (2,1) 2 ;
100
test "cinq" h (2,4) 100 ; ()
105
let hh x = match x with
108
| (2|3),(1|2|3|4) -> 3
114
let hhh x = match x with
130
let h x = match x with
139
let f x = match x with
140
| ((1|2),(3|4))|((3|4),(1|2)) -> 1
145
test "six" f (1,3) 1 ;
146
test "six" f (3,2) 1 ;
147
test "six" f (3,5) 2 ;
148
test "six" f (3,7) 3 ; ()
151
type tt = {a : bool list ; b : bool}
154
| {a=([]|[true])} -> 1
155
| {a=false::_}|{b=(true|false)} -> 2
158
test "sept" f {a=[] ; b = true} 1 ;
159
test "sept" f {a=[true] ; b = false} 1 ;
160
test "sept" f {a=[false ; true] ; b = true} 2 ;
161
test "sept" f {a=[false] ; b = false} 2 ; ()
165
| (([]|[true]),_) -> 1
166
| (false::_,_)|(_,(true|false)) -> 2
169
test "huit" f ([],true) 1 ;
170
test "huit" f ([true],false) 1 ;
171
test "huit" f ([false ; true], true) 2 ;
172
test "huit" f ([false], false) 2 ; ()
176
let split_cases = function
177
| `Nil | `Cons _ as x -> `A x
178
| `Snoc _ as x -> `B x
181
test "oubli" split_cases `Nil (`A `Nil);
182
test "oubli" split_cases (`Cons 1) (`A (`Cons 1));
183
test "oubli" split_cases (`Snoc 1) (`B (`Snoc 1)) ; ()
186
type t1 = A of int | B of int
191
test "neuf" f1 (A 1) 1 ;
192
test "neuf" f1 (B 1) 1 ;
195
type coucou = A of int | B of int * int | C
200
| (A x | B (_,x)) -> x
205
test "dix" g (A 1) 1 ;
206
test "dix" g (B (1,2)) 2 ;
212
| ([x]|[1 ; x ]|[1 ; 2 ; x]) -> x
216
test "encore" h [1] 1 ;
217
test "encore" h [1;2] 2 ;
218
test "encore" h [1;2;3] 3 ;
219
test "encore" h [0 ; 0] 0 ; ()
223
| (x,(0 as y)) | (y,x) -> y-x
226
test "foo1" f (1,0) (-1);
227
test "foo1" f (1,2) (-1)
231
let f = function (([]|[_]) as x)|(_::([] as x))|(_::_::x) -> x
235
test "zob" f [1] [1] ;
236
test "zob" f [1;2;3] [3]
240
type zob = A | B | C | D of zob * int | E of zob * zob
244
| D (x,i) -> D (f x,i)
245
| E (x,_) -> D (f x,0)
250
test "fin" f (D (C,1)) (D (A,1)) ;
251
test "fin" f (E (C,A)) (D (A,0)) ; ()
255
Char of int | Pixel of int | Percent of int | No of string | Default
257
let length = function
258
| Char n -> n | Pixel n -> n
262
test "length" length (Char 10) 10 ;
263
test "length" length (Pixel 20) 20 ;
264
test "length" length Default 0 ;
265
test "length" length (Percent 100) 0 ; ()
268
let length2 = function
269
| Char n -> n | Percent n -> n
273
test "length2" length2 (Char 10) 10 ;
274
test "length2" length2 (Pixel 20) 0 ;
275
test "length2" length2 Default 0 ;
276
test "length2" length2(Percent 100) 100 ; ()
279
let length3 = function
280
| Char _ | No _ -> true
284
test "length3" length3 (Char 10) true ;
285
test "length3" length3 (No "") true ;
286
test "length3" length3 (Pixel 20) false ;
287
test "length3" length3 Default false ;
288
test "length3" length3(Percent 100) false ; ()
291
type hevea = A | B | C
293
let h x = match x with
300
test "hevea" h B 2 ; ()
305
| Lapply of lambda * lambda list
306
| Lfunction of bool * int list * lambda
307
| Llet of bool * int * lambda * lambda
308
| Lletrec of (int * lambda) list * lambda
309
| Lprim of string * lambda list
310
| Lswitch of lambda * lambda_switch
312
| Lcatch of lambda * lambda
313
| Lstaticraise of int * lambda list
314
| Lstaticcatch of lambda * (int * int list) * lambda
315
| Ltrywith of lambda * int * lambda
316
| Lifthenelse of lambda * lambda * lambda
317
| Lsequence of lambda * lambda
318
| Lwhile of lambda * lambda
319
| Lfor of int * lambda * lambda * bool * lambda
320
| Lassign of int * lambda
321
| Lsend of lambda * lambda * lambda list
322
| Levent of lambda * lambda_event
323
| Lifused of int * lambda
325
{ sw_numconsts: int; (* Number of integer cases *)
326
sw_consts: (int * lambda) list; (* Integer cases *)
327
sw_numblocks: int; (* Number of tag block cases *)
328
sw_blocks: (int * lambda) list; (* Tag block cases *)
329
sw_checked: bool ; (* True if bound checks needed *)
330
sw_nofail: bool} (* True if should not fail *)
334
lev_repr: int ref option;
337
let rec approx_present v l = true
339
let rec lower_bind v arg lam = match lam with
340
| Lifthenelse (cond, ifso, ifnot) -> 1
341
| Lswitch (ls,({sw_consts=[i,act] ; sw_blocks = []} as _sw))
342
when not (approx_present v ls) -> 2
343
| Lswitch (ls,({sw_consts=[] ; sw_blocks = [i,act]} as _sw))
344
when not (approx_present v ls) -> 3
345
| Llet (true , vv, lv, l) -> 4
349
test "lower_bind" (lower_bind 0 0) (Llet (true,0, Lvar 1, Lvar 2)) 4 ;
350
test "lower_bind" (lower_bind 0 0) (Lvar 0) 5 ;
351
test "lower_bind" (lower_bind 0 0) (Lifthenelse (Lvar 0, Lvar 1, Lvar 2)) 1
356
Fvar of field_kind option ref
360
let unify_kind (k1, k2) = match k1, k2 with
361
(Fvar r, (Fvar _ | Fpresent)) -> 1
362
| (Fpresent, Fvar r) -> 2
363
| (Fpresent, Fpresent) -> 3
367
let r = ref (Some Fpresent)
370
test "unify" unify_kind (Fvar r, Fpresent) 1 ;
371
test "unify" unify_kind (Fvar r, Fvar r) 1 ;
372
test "unify" unify_kind (Fvar r, Fabsent) 4 ;
373
test "unify" unify_kind (Fpresent, Fvar r) 2 ;
374
test "unify" unify_kind (Fpresent, Fpresent) 3 ;
375
test "unify" unify_kind (Fabsent, Fpresent) 4 ; ()
379
type youyou = A | B | C | D of youyou
381
let foo (k1, k2) = match k1,k2 with
388
test "foo2" foo (D A,A) 1 ;
389
test "foo2" foo (D A,B) 4 ;
390
test "foo2" foo (A,A) 4 ; ()
403
test "yaya" yaya (A,A,0) 1 ;
404
test "yaya" yaya (B,A,0) 2 ;
405
test "yaya" yaya (B,B,100) 3 ; ()
413
| [],_,(100|103|104) -> 5
414
| [],_,(100|103) -> 6
415
| [],_,(1000|1001|1002|20000) -> 7
418
test "yoyo" yoyo ([],[],0) 1 ;
419
test "yoyo" yoyo ([1],[],0) 2 ;
420
test "yoyo" yoyo ([1],[1],100) 3 ; ()
423
let youyou = function
426
| (1000|1001|1002|20000) -> 3
430
test "youyou" youyou 100 1 ;
431
test "youyou" youyou 101 2 ;
432
test "youyou" youyou 1000 3
436
| C | D | E of autre | F of autre * autre | H of autre | I | J | K of string
438
let rec autre = function
442
| (D|F (_,_)|H _|K _),_,_ -> 4
443
| (_, (D|I|E _|F (_, _)|H _|K _), _) -> 8
444
| (J,J,((C|D) as x |E x|F (_,x))) | (J,_,((C|J) as x)) -> autre (x,x,x)
445
| (J, J, (I|H _|K _)) -> 9
450
File "morematch.ml", line 437, characters 43-44:
451
Warning U: this sub-pattern is unused.
453
test "autre" autre (J,J,F (D,D)) 3 ;
454
test "autre" autre (J,J,D) 3 ;
455
test "autre" autre (J,J,I) 9 ;
456
test "autre" autre (H I,I,I) 4 ;
457
test "autre" autre (J,J,H I) 9 ; ()
461
type youpi = YA | YB | YC
462
and hola = X | Y | Z | T of hola | U of hola | V of hola
468
| ((YB|YC), (YB|YC), (X|Y|Z|V _|T _)) -> 6
473
File "morematch.ml", line 459, characters 7-8:
474
Warning U: this sub-pattern is unused.
475
File "morematch.ml", line 460, characters 2-7:
476
Warning U: this match case is unused.
478
test "xyz" xyz (YC,YC,X) 6 ;
479
test "xyz" xyz (YC,YB,U X) 8 ;
480
test "xyz" xyz (YB,YC,X) 6 ; ()
484
(* Ce test est pour le compilo lui-meme *)
488
test "eq" eq ("coucou", "coucou") true ; ()
491
(* Test des gardes, non trivial *)
493
let is_none = function
497
let garde x = match x with
498
| (Some _, _) when is_none (snd x) -> 1
499
| (Some (pc, _), Some pc') when pc = pc' -> 2
503
test "garde" garde (Some (1,1),None) 1 ;
504
test "garde" garde (Some (1,1),Some 1) 2 ;
505
test "garde" garde (Some (2,1),Some 1) 3 ; ()
508
let orstring = function
514
test "orstring" orstring "A" 2 ;
515
test "orstring" orstring "B" 2 ;
516
test "orstring" orstring "C" 2 ;
517
test "orstring" orstring "D" 3 ;
518
test "orstring" orstring "E" 4 ; ()
521
type var_t = [`Variant of [ `Some of string | `None | `Foo] ]
523
let crash (pat:var_t) =
525
| `Variant (`Some tag) -> tag
526
| `Variant (`None) -> "none"
531
test "crash" crash (`Variant `None) "none" ;
532
test "crash" crash (`Variant (`Some "coucou")) "coucou" ;
533
test "crash" crash (`Variant (`Foo)) "foo" ; ()
539
| (1,2)|(2,3) when y=2 -> 1
544
test "flatgarde" flatgarde (1,2) 1 ;
545
test "flatgarde" flatgarde (1,3) 2 ;
546
test "flatgarde" flatgarde (2,3) 2 ;
547
test "flatgarde" flatgarde (2,4) 3 ; ()
551
(* Les bugs de jerome *)
565
let replicaContent2shortString rc =
566
let (typ, status) = rc in
567
match typ, status with
569
| ABSENT, Deleted -> "deleted "
570
| FILE, Created -> "new file"
571
| FILE, Modified -> "changed "
572
| FILE, PropsChanged -> "props "
573
| SYMLINK, Created -> "new link"
574
| SYMLINK, Modified -> "chgd lnk"
575
| DIRECTORY, Created -> "new dir "
576
| DIRECTORY, Modified -> "chgd dir"
577
| DIRECTORY, PropsChanged -> "props "
578
(* Cases that can't happen... *)
580
| ABSENT, (Created | Modified | PropsChanged)
581
| SYMLINK, PropsChanged
582
| (FILE|SYMLINK|DIRECTORY), Deleted
588
replicaContent2shortString (ABSENT, Unchanged) " " ;
590
replicaContent2shortString (ABSENT, Deleted) "deleted " ;
592
replicaContent2shortString (FILE, Modified) "changed " ;
594
replicaContent2shortString (DIRECTORY, PropsChanged) "props " ;
596
replicaContent2shortString (FILE, Deleted) "assert false" ;
598
replicaContent2shortString (SYMLINK, Deleted) "assert false" ;
600
replicaContent2shortString (SYMLINK, PropsChanged) "assert false" ;
602
replicaContent2shortString (DIRECTORY, Deleted) "assert false" ;
604
replicaContent2shortString (ABSENT, Created) "assert false" ;
606
replicaContent2shortString (ABSENT, Modified) "assert false" ;
608
replicaContent2shortString (ABSENT, PropsChanged) "assert false" ;
612
let replicaContent2shortString rc =
613
let (typ, status) = rc in
614
match typ, status with
616
| `ABSENT, `Deleted -> "deleted "
617
| `FILE, `Created -> "new file"
618
| `FILE, `Modified -> "changed "
619
| `FILE, `PropsChanged -> "props "
620
| `SYMLINK, `Created -> "new link"
621
| `SYMLINK, `Modified -> "chgd lnk"
622
| `DIRECTORY, `Created -> "new dir "
623
| `DIRECTORY, `Modified -> "chgd dir"
624
| `DIRECTORY, `PropsChanged -> "props "
625
(* Cases that can't happen... *)
627
| `ABSENT, (`Created | `Modified | `PropsChanged)
628
| `SYMLINK, `PropsChanged
629
| (`FILE|`SYMLINK|`DIRECTORY), `Deleted
634
test "jerome_variant"
635
replicaContent2shortString (`ABSENT, `Unchanged) " " ;
636
test "jerome_variant"
637
replicaContent2shortString (`ABSENT, `Deleted) "deleted " ;
638
test "jerome_variant"
639
replicaContent2shortString (`FILE, `Modified) "changed " ;
640
test "jerome_variant"
641
replicaContent2shortString (`DIRECTORY, `PropsChanged) "props " ;
642
test "jerome_variant"
643
replicaContent2shortString (`FILE, `Deleted) "assert false" ;
644
test "jerome_variant"
645
replicaContent2shortString (`SYMLINK, `Deleted) "assert false" ;
646
test "jerome_variant"
647
replicaContent2shortString (`SYMLINK, `PropsChanged) "assert false" ;
648
test "jerome_variant"
649
replicaContent2shortString (`DIRECTORY, `Deleted) "assert false" ;
650
test "jerome_variant"
651
replicaContent2shortString (`ABSENT, `Created) "assert false" ;
652
test "jerome_variant"
653
replicaContent2shortString (`ABSENT, `Modified) "assert false" ;
654
test "jerome_variant"
655
replicaContent2shortString (`ABSENT, `PropsChanged) "assert false" ;
660
type ab = A of int | B of int
664
| (A (p) | B (p)), C -> p
665
| (A (p) | B (p)), D -> p
668
test "ohl" ohl (A 0,C) 0 ;
669
test "ohl" ohl (B 0,D) 0 ; ()
680
| (( (A, 1) | (B, 2)),A) -> false
684
test "pottier" pottier ((B,2),A) false ;
685
test "pottier" pottier ((B,2),B) true ;
686
test "pottier" pottier ((A,2),A) true ; ()
689
(* bug 325 in bytecode compiler *)
690
let coquery q = match q with
691
| y,0,([modu;defs]| [defs;modu;_]) -> y+defs-modu
695
test "coquery" coquery (1,0,[1 ; 2 ; 3]) 0 ;
696
test "coquery" coquery (1,0,[1 ; 2]) 2 ; ()
700
Two other variable in or-pat tests
702
type vars = A of int | B of (int * int) | C
707
| (A x | B (_,x)) -> x
711
test "vars1" vars1 (A 1) 1 ;
712
test "vars1" vars1 (B (1,2)) 2 ; ()
716
| ([x]|[1 ; x ]|[1 ; 2 ; x]) -> x
720
test"vars2" vars2 [1] 1 ;
721
test"vars2" vars2 [1;2] 2 ;
722
test"vars2" vars2 [1;2;3] 3 ;
723
test"vars2" vars2 [0 ; 0] 0 ; ()
727
type eber = {x:int; y: int; z:bool}
731
| {y=a; z=false} -> a
734
test "eber" eber {x=0 ; y=1 ; z=true} 0 ;
735
test "eber" eber {x=1 ; y=0 ; z=false} 0 ; ()
739
(* Enchainement des test d'intervalle *)
741
let escaped = function
742
| '"' | '\\' | '\n' | '\t' -> 2
746
test "escaped" escaped '"' 2 ;
747
test "escaped" escaped '\\' 2 ;
748
test "escaped" escaped '\n' 2 ;
749
test "escaped" escaped '\t' 2 ;
750
test "escaped" escaped '\000' 1 ;
751
test "escaped" escaped ' ' 1 ;
752
test "escaped" escaped '\000' 1 ;
753
test "escaped" escaped '[' 1 ;
754
test "escaped" escaped ']' 1 ;
755
test "escaped" escaped '!' 1 ;
756
test "escaped" escaped '#' 1 ;
760
(* For compilation speed (due to J. Garigue) *)
761
exception Unknown_Reply of int
811
| RPL_TRACECONNECTING
866
let get_command_reply n =
869
| 319 -> RPL_WHOISCHANNELS
870
| 318 -> RPL_ENDOFWHOIS
871
| 317 -> RPL_WHOISIDLE
872
| 316 -> RPL_WHOISCHANOP
873
| 369 -> RPL_ENDOFWHOWAS
874
| 314 -> RPL_WHOWASUSER
875
| 313 -> RPL_WHOISOPERATOR
876
| 312 -> RPL_WHOISSERVER
877
| 311 -> RPL_WHOISUSER
878
| 262 -> RPL_TRACEEND
879
| 261 -> RPL_TRACELOG
880
| 259 -> RPL_ADMINEMAIL
881
| 258 -> RPL_ADMINLOC2
882
| 257 -> RPL_ADMINLOC1
885
| 254 -> RPL_LUSERCHANNELS
886
| 253 -> RPL_LUSERUNKNOWN
888
| 251 -> RPL_LUSERCLIENT
889
| 250 -> RPL_STATSDLINE
890
| 249 -> RPL_STATSDEBUG
891
| 248 -> RPL_STATSDEFINE
892
| 247 -> RPL_STATSBLINE
893
| 246 -> RPL_STATSPING
894
| 245 -> RPL_STATSSLINE
895
| 244 -> RPL_STATSHLINE
896
| 243 -> RPL_STATSOLINE
897
| 242 -> RPL_STATSUPTIME
898
| 241 -> RPL_STATSLLINE
899
| 240 -> RPL_STATSVLINE
900
| 235 -> RPL_SERVLISTEND
901
| 234 -> RPL_SERVLIST
903
| 232 -> RPL_ENDOFSERVICES
904
| 231 -> RPL_SERVICEINFO
906
| 219 -> RPL_ENDOFSTATS
907
| 218 -> RPL_STATSYLINE
908
| 217 -> RPL_STATSQLINE
909
| 216 -> RPL_STATSKLINE
910
| 215 -> RPL_STATSILINE
911
| 214 -> RPL_STATSNLINE
912
| 213 -> RPL_STATSCLINE
913
| 212 -> RPL_STATSCOMMANDS
914
| 211 -> RPL_STATSLINKINFO
915
| 210 -> RPL_TRACERECONNECT
916
| 209 -> RPL_TRACECLASS
917
| 208 -> RPL_TRACENEWTYPE
918
| 207 -> RPL_TRACESERVICE
919
| 206 -> RPL_TRACESERVER
920
| 205 -> RPL_TRACEUSER
921
| 204 -> RPL_TRACEOPERATOR
922
| 203 -> RPL_TRACEUNKNOWN
923
| 202 -> RPL_TRACEHANDSHAKE
924
| 201 -> RPL_TRACECONNECTING
925
| 200 -> RPL_TRACELINK
927
| 394 -> RPL_ENDOFUSERS
929
| 392 -> RPL_USERSSTART
931
| 385 -> RPL_NOTOPERANYMORE
932
| 384 -> RPL_MYPORTIS
933
| 383 -> RPL_YOURESERVICE
934
| 382 -> RPL_REHASHING
935
| 381 -> RPL_YOUREOPER
936
| 376 -> RPL_ENDOFMOTD
937
| 375 -> RPL_MOTDSTART
938
| 374 -> RPL_ENDOFINFO
939
| 373 -> RPL_INFOSTART
942
| 368 -> RPL_ENDOFBANLIST
944
| 365 -> RPL_ENDOFLINKS
946
| 363 -> RPL_CLOSEEND
948
| 361 -> RPL_KILLDONE
949
| 366 -> RPL_ENDOFNAMES
950
| 353 -> RPL_NAMREPLY
951
| 315 -> RPL_ENDOFWHO
952
| 352 -> RPL_WHOREPLY
954
| 342 -> RPL_SUMMONING
955
| 341 -> RPL_INVITING
958
| 324 -> RPL_CHANNELMODEIS
961
| 321 -> RPL_LISTSTART
966
| 302 -> RPL_USERHOST
969
| _ -> raise (Unknown_Reply n)
976
and habert_c= {lvar:int; lassoc: habert_c;lnb:int}
980
| (A {lnb=i}|B {lnb=i}) when i=0 -> 1
981
| A {lassoc=({lnb=j});lnb=i} -> 2
985
let rec ex0 = {lvar=0 ; lnb=0 ; lassoc=ex1}
986
and ex1 = {lvar=1 ; lnb=1 ; lassoc=ex0} in
988
test "habert" habert (A ex0) 1 ;
989
test "habert" habert (B ex0) 1 ;
990
test "habert" habert (A ex1) 2 ;
991
test "habert" habert (B ex1) 3 ;
993
(* Problems with interval test in arithmetic mod 2^31, bug #359 *)
994
(* From manuel Fahndrich *)
997
| `TTuple of type_expr list
998
| `TConstr of type_expr list
1000
| `TVariant of string list
1002
| `TCopy of type_expr
1005
and recurs_type_expr = [
1006
| `TTuple of type_expr list
1007
| `TConstr of type_expr list
1008
| `TVariant of string list
1017
| #recurs_type_expr as desc ->
1025
| `TVariant (row) ->
1033
let base = `TBlock 0
1036
test "maf" maf (`TCopy base) 1 ;
1037
test "maf" maf (`TVar "test") 2 ;
1038
test "maf" maf (`TBlock 0) 2 ;
1039
test "maf" maf (`TTuple []) 4 ;
1040
test "maf" maf (`TConstr []) 5 ;
1041
test "maf" maf (`TVariant []) 6
1045
Using ``get_args'' in place or an ad-hoc ``matcher'' function for tuples.
1046
Has made the compiler [3.05] to fail.
1048
type t_seb = Uin | Uout
1051
let rec seb = function
1052
| ((i, Uin) | (i, Uout)), Uout -> 1
1053
| ((j, Uin) | (j, Uout)), Uin -> 2
1056
test "seb" seb ((0,Uin),Uout) 1 ;
1057
test "seb" seb ((0,Uout),Uin) 2 ;
1061
(* Talk with Jacques
1062
- type 'b is still open ??
1063
- better case generation, accept intervals of size 1 when ok_inter is
1068
File "morematch.ml", line 1060, characters 8-65:
1069
Warning: this pattern-matching is not exhaustive.
1070
Here is an example of a value that is not matched:
1073
type ('a, 'b) t_j = A of 'a | B of 'b * 'a | C
1080
let g x = try f x with Match_failure _ -> 3
1083
test "jacques" g (A `A) 0 ;
1084
test "jacques" g (A `C) 0 ;
1085
test "jacques" g (B (`B,`D)) 1 ;
1086
test "jacaues" g C 2 ;
1087
(* test "jacques" g (B (`A,`D)) 3 ; (* type incorrect expected behavior ? *)*)
1091
Compilation bug, segfault, because of incorrect compilation
1092
of unused match case .. -> "11"
1098
| _, _, _, _, _, _, _, _, _, _, _, _, _, B, _, _ -> "0"
1099
| _, _, _, B, A, _, _, _, _, _, _, _, _, _, _, _ -> "1"
1100
| _, _, _, B, _, A, _, _, A, _, _, _, _, _, _, _ -> "2"
1101
| _, _, _, _, _, _, _, _, _, _, B, A, _, A, _, _ -> "3"
1102
| _, _, _, _, _, _, _, B, _, _, _, _, B, _, A, A -> "4"
1103
| A, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ -> "5"
1104
| _, _, _, _, _, _, _, B, _, B, _, _, _, _, _, _ -> "6"
1105
| _, B, _, _, _, _, _, _, _, _, _, _, _, _, _, _ -> "7"
1106
| _, A, A, _, A, _, B, _, _, _, _, _, _, _, _, B -> "8"
1107
| _, _, _, _, B, _, _, _, _, _, _, _, _, _, B, _ -> "9"
1108
| _, _, _, _, _, _, _, _, _, _, _, B, _, _, _, _ -> "10"
1109
| _, _, _, _, _, A, _, _, _, _, B, _, _, _, _, _ -> "11"
1110
| B, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ -> "12"
1111
| _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ -> "13"
1114
File "morematch.ml", line 1094, characters 5-51:
1115
Warning: this match case is unused.
1116
File "morematch.ml", line 1096, characters 5-51:
1117
Warning: this match case is unused.
1120
test "luc" f (B, A, A, A, A, A, A, A, A, A, A, B, A, A, A, A) "10" ;
1121
test "luc" f (B, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A) "12" ;
1125
By Gilles Peskine, compilation raised some assert false i make_failactionneg
1147
let rec gilles o = match o with
1148
| {v = (`U data | `V data); x = `False} when predg o -> 1
1149
| {v = (`A|`B) ; x = `False}
1150
| {v = (`U _ | `V _); x = `False}
1151
| {v = _ ; x = `True}
1155
Match in trywith should always have a default case
1158
exception Found of string * int
1159
exception Error of string
1164
try raise e with Error msg -> msg
1165
with Found (s,r) -> s^string_of_int r
1168
test "lucexn1" lucexn (Error "coucou") "coucou" ;
1169
test "lucexn2" lucexn (Found ("int: ",0)) "int: 0" ;