File tree Expand file tree Collapse file tree 6 files changed +38
-6
lines changed Expand file tree Collapse file tree 6 files changed +38
-6
lines changed Original file line number Diff line number Diff line change @@ -1157,7 +1157,12 @@ and type_pat_aux ~constrs ~labels ~no_existentials ~mode ~explode ~env
1157
1157
let exp_optional_attr =
1158
1158
Ext_list. exists pat.ppat_attributes (fun ({txt } ,_ ) -> txt = " optional" )
1159
1159
in
1160
- if label_is_optional ld && not exp_optional_attr then
1160
+ let isFromPamatch = match pat.ppat_desc with
1161
+ | Ppat_construct ({txt = Lident s } , _ ) ->
1162
+ String. length s > = 2 && s.[0 ] = '#' && s.[1 ] = '$'
1163
+ | _ -> false
1164
+ in
1165
+ if label_is_optional ld && not exp_optional_attr && not isFromPamatch then
1161
1166
let lid = mknoloc (Longident. (Ldot (Lident " *predef*" , " Some" ))) in
1162
1167
Ast_helper.Pat. construct ~loc: pat.ppat_loc lid (Some pat)
1163
1168
else pat
Original file line number Diff line number Diff line change @@ -16,7 +16,19 @@ var newrecord = Caml_obj.obj_dup(v0);
16
16
newrecord . x = 3 ;
17
17
18
18
function testMatch ( v ) {
19
- return v . y ;
19
+ var y = v . y ;
20
+ if ( y !== undefined ) {
21
+ return y ;
22
+ }
23
+ throw {
24
+ RE_EXN_ID : "Match_failure" ,
25
+ _1 : [
26
+ "res_debug.res" ,
27
+ 50 ,
28
+ 2
29
+ ] ,
30
+ Error : new Error ( )
31
+ } ;
20
32
}
21
33
22
34
var v2 = newrecord ;
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ let v1 : r = { x : 3
44
44
, z : 3
45
45
}
46
46
47
- // @@warning("-56 ") // Turn off match case unreachable
47
+ @@warning ("-8 " ) // Turn off incomplete pattern match
48
48
49
49
let testMatch = v =>
50
50
switch v {
Original file line number Diff line number Diff line change @@ -40060,7 +40060,12 @@ and type_pat_aux ~constrs ~labels ~no_existentials ~mode ~explode ~env
40060
40060
let exp_optional_attr =
40061
40061
Ext_list.exists pat.ppat_attributes (fun ({txt },_) -> txt = "optional")
40062
40062
in
40063
- if label_is_optional ld && not exp_optional_attr then
40063
+ let isFromPamatch = match pat.ppat_desc with
40064
+ | Ppat_construct ({txt = Lident s}, _) ->
40065
+ String.length s >= 2 && s.[0] = '#' && s.[1] = '$'
40066
+ | _ -> false
40067
+ in
40068
+ if label_is_optional ld && not exp_optional_attr && not isFromPamatch then
40064
40069
let lid = mknoloc (Longident.(Ldot (Lident "*predef*", "Some"))) in
40065
40070
Ast_helper.Pat.construct ~loc:pat.ppat_loc lid (Some pat)
40066
40071
else pat
Original file line number Diff line number Diff line change @@ -40060,7 +40060,12 @@ and type_pat_aux ~constrs ~labels ~no_existentials ~mode ~explode ~env
40060
40060
let exp_optional_attr =
40061
40061
Ext_list.exists pat.ppat_attributes (fun ({txt },_) -> txt = "optional")
40062
40062
in
40063
- if label_is_optional ld && not exp_optional_attr then
40063
+ let isFromPamatch = match pat.ppat_desc with
40064
+ | Ppat_construct ({txt = Lident s}, _) ->
40065
+ String.length s >= 2 && s.[0] = '#' && s.[1] = '$'
40066
+ | _ -> false
40067
+ in
40068
+ if label_is_optional ld && not exp_optional_attr && not isFromPamatch then
40064
40069
let lid = mknoloc (Longident.(Ldot (Lident "*predef*", "Some"))) in
40065
40070
Ast_helper.Pat.construct ~loc:pat.ppat_loc lid (Some pat)
40066
40071
else pat
Original file line number Diff line number Diff line change @@ -214591,7 +214591,12 @@ and type_pat_aux ~constrs ~labels ~no_existentials ~mode ~explode ~env
214591
214591
let exp_optional_attr =
214592
214592
Ext_list.exists pat.ppat_attributes (fun ({txt },_) -> txt = "optional")
214593
214593
in
214594
- if label_is_optional ld && not exp_optional_attr then
214594
+ let isFromPamatch = match pat.ppat_desc with
214595
+ | Ppat_construct ({txt = Lident s}, _) ->
214596
+ String.length s >= 2 && s.[0] = '#' && s.[1] = '$'
214597
+ | _ -> false
214598
+ in
214599
+ if label_is_optional ld && not exp_optional_attr && not isFromPamatch then
214595
214600
let lid = mknoloc (Longident.(Ldot (Lident "*predef*", "Some"))) in
214596
214601
Ast_helper.Pat.construct ~loc:pat.ppat_loc lid (Some pat)
214597
214602
else pat
You can’t perform that action at this time.
0 commit comments