Skip to content

Commit db27059

Browse files
committed
Pass through the is_exception everywhere it's needed
1 parent bf82c06 commit db27059

11 files changed

+32
-28
lines changed

jscomp/ml/ctype.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3674,7 +3674,7 @@ let rec subtype_rec env trace t1 t2 cstrs =
36743674
true (* handled in the fields checks *)
36753675
| Record_unboxed b1, Record_unboxed b2 -> b1 = b2
36763676
| Record_inlined _, Record_inlined _ -> repr1 = repr2
3677-
| Record_extension, Record_extension -> true
3677+
| Record_extension b1, Record_extension b2 -> b1.is_exception = b2.is_exception
36783678
| _ -> false in
36793679
if same_repr then
36803680
let violation, tl1, tl2 = Record_coercion.check_record_fields ~repr1 ~repr2 fields1 fields2 in

jscomp/ml/datarepr.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ let extension_descr path_ext ext =
194194
in
195195
let existentials, cstr_args, cstr_inlined =
196196
constructor_args ext.ext_private ext.ext_args ext.ext_ret_type
197-
path_ext Record_extension
197+
path_ext (Record_extension { is_exception = ext.ext_is_exception })
198198
in
199199
{ cstr_name = Path.last path_ext;
200200
cstr_res = ty_res;

jscomp/ml/lambda.ml

+6-7
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,13 @@ type tag_info =
4848
| Blk_module of string list
4949
| Blk_module_export of Ident.t list
5050
| Blk_extension of {
51-
is_exception: bool;
52-
}
51+
is_exception: bool; }
5352
| Blk_some
5453
| Blk_some_not_nested (* ['a option] where ['a] can not inhabit a non-like value *)
5554
| Blk_record_ext of {
56-
fields: string array;
57-
mutable_flag: Asttypes.mutable_flag;
58-
}
55+
fields: string array;
56+
mutable_flag: Asttypes.mutable_flag;
57+
is_exception: bool; }
5958
| Blk_lazy_general
6059

6160
let tag_of_tag_info (tag : tag_info ) =
@@ -114,14 +113,14 @@ let blk_record (fields : (label * _) array) mut record_repr =
114113
{ fields = all_labels_info; mutable_flag = mut; record_repr }
115114

116115

117-
let blk_record_ext fields mutable_flag =
116+
let blk_record_ext fields mutable_flag is_exception =
118117
let all_labels_info =
119118
Array.map
120119
(fun ((lbl : label), _) ->
121120
Ext_list.find_def lbl.Types.lbl_attributes find_name lbl.lbl_name)
122121
fields
123122
in
124-
Blk_record_ext {fields = all_labels_info; mutable_flag }
123+
Blk_record_ext {fields = all_labels_info; mutable_flag; is_exception }
125124

126125
let blk_record_inlined fields name num_nonconst optional_labels ~tag ~attrs mutable_flag =
127126
let fields =

jscomp/ml/lambda.mli

+5-5
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ type tag_info =
4747
| Blk_module of string list
4848
| Blk_module_export of Ident.t list
4949
| Blk_extension of {
50-
is_exception: bool;
51-
}
50+
is_exception: bool; }
5251
(* underlying is the same as tuple, immutable block
5352
{[
5453
exception A of int * int
@@ -63,9 +62,9 @@ type tag_info =
6362
| Blk_some
6463
| Blk_some_not_nested (* ['a option] where ['a] can not inhabit a non-like value *)
6564
| Blk_record_ext of {
66-
fields: string array;
67-
mutable_flag: mutable_flag;
68-
}
65+
fields: string array;
66+
mutable_flag: mutable_flag;
67+
is_exception: bool; }
6968
| Blk_lazy_general
7069

7170
val find_name :
@@ -83,6 +82,7 @@ val blk_record :
8382
val blk_record_ext :
8483
(Types.label_description* Typedtree.record_label_definition) array ->
8584
mutable_flag ->
85+
bool ->
8686
tag_info
8787

8888

jscomp/ml/matching.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1602,7 +1602,7 @@ let make_record_matching loc all_labels def = function
16021602
| Record_inlined _ ->
16031603
Lprim (Pfield (lbl.lbl_pos, Lambda.fld_record_inline lbl), [arg], loc)
16041604
| Record_unboxed _ -> arg
1605-
| Record_extension -> Lprim (Pfield (lbl.lbl_pos + 1, Lambda.fld_record_extension lbl), [arg], loc)
1605+
| Record_extension _ -> Lprim (Pfield (lbl.lbl_pos + 1, Lambda.fld_record_extension lbl), [arg], loc)
16061606
in
16071607
let str =
16081608
match lbl.lbl_mut with

jscomp/ml/printtyped.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ let record_representation i ppf = let open Types in function
150150
line i ppf "Record_optional_labels %s\n" (lbls |> String.concat ", ")
151151
| Record_unboxed b -> line i ppf "Record_unboxed %b\n" b
152152
| Record_inlined {tag = i} -> line i ppf "Record_inlined %d\n" i
153-
| Record_extension -> line i ppf "Record_extension\n"
153+
| Record_extension _ -> line i ppf "Record_extension\n"
154154

155155
let attributes i ppf l =
156156
let i = i + 1 in

jscomp/ml/rec_check.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ let rec expression : Env.env -> Typedtree.expression -> Use.t =
256256
match rep with
257257
| Record_unboxed _ -> fun x -> x
258258
| Record_float_unused -> assert false
259-
| Record_optional_labels _ | Record_regular | Record_inlined _ | Record_extension
259+
| Record_optional_labels _ | Record_regular | Record_inlined _ | Record_extension _
260260
->
261261
Use.guard
262262
in

jscomp/ml/translcore.ml

+7-7
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda =
943943
[ targ ],
944944
e.exp_loc )
945945
| Record_unboxed _ -> targ
946-
| Record_extension ->
946+
| Record_extension _ ->
947947
Lprim
948948
( Pfield
949949
(lbl.lbl_pos + 1, Lambda.fld_record_extension lbl),
@@ -958,7 +958,7 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda =
958958
| Record_inlined _ ->
959959
Psetfield (lbl.lbl_pos, Lambda.fld_record_inline_set lbl)
960960
| Record_unboxed _ -> assert false
961-
| Record_extension ->
961+
| Record_extension _ ->
962962
Psetfield (lbl.lbl_pos + 1, Lambda.fld_record_extension_set lbl)
963963
in
964964
Lprim (access, [ transl_exp arg; transl_exp newval ], e.exp_loc)
@@ -1212,7 +1212,7 @@ and transl_record loc env fields repres opt_init_expr =
12121212
| Record_inlined _ ->
12131213
Pfield (i, Lambda.fld_record_inline lbl)
12141214
| Record_unboxed _ -> assert false
1215-
| Record_extension ->
1215+
| Record_extension _ ->
12161216
Pfield
12171217
(i + 1, Lambda.fld_record_extension lbl)
12181218
in
@@ -1246,7 +1246,7 @@ and transl_record loc env fields repres opt_init_expr =
12461246
cl ))
12471247
| Record_unboxed _ ->
12481248
Lconst (match cl with [ v ] -> v | _ -> assert false)
1249-
| Record_extension -> raise Not_constant
1249+
| Record_extension _ -> raise Not_constant
12501250
with Not_constant -> (
12511251
match repres with
12521252
| Record_regular ->
@@ -1269,7 +1269,7 @@ and transl_record loc env fields repres opt_init_expr =
12691269
loc )
12701270
| Record_unboxed _ -> (
12711271
match ll with [ v ] -> v | _ -> assert false)
1272-
| Record_extension ->
1272+
| Record_extension { is_exception } ->
12731273
let path =
12741274
let label, _ = fields.(0) in
12751275
match label.lbl_res.desc with
@@ -1278,7 +1278,7 @@ and transl_record loc env fields repres opt_init_expr =
12781278
in
12791279
let slot = transl_extension_path env path in
12801280
Lprim
1281-
( Pmakeblock (Lambda.blk_record_ext fields mut),
1281+
( Pmakeblock (Lambda.blk_record_ext fields mut is_exception),
12821282
slot :: ll,
12831283
loc ))
12841284
in
@@ -1302,7 +1302,7 @@ and transl_record loc env fields repres opt_init_expr =
13021302
| Record_inlined _ ->
13031303
Psetfield (lbl.lbl_pos, Lambda.fld_record_inline_set lbl)
13041304
| Record_unboxed _ -> assert false
1305-
| Record_extension ->
1305+
| Record_extension _ ->
13061306
Psetfield
13071307
(lbl.lbl_pos + 1, Lambda.fld_record_extension_set lbl)
13081308
in

jscomp/ml/typedecl.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1549,7 +1549,7 @@ let transl_extension_constructor env type_path type_params
15491549
List.iter2 (Ctype.unify env) decl.type_params tl;
15501550
let lbls =
15511551
match decl.type_kind with
1552-
| Type_record (lbls, Record_extension) -> lbls
1552+
| Type_record (lbls, Record_extension _) -> lbls
15531553
| _ -> assert false
15541554
in
15551555
Types.Cstr_record lbls

jscomp/ml/types.ml

+6-2
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ and record_representation =
155155
| Record_unboxed of bool (* Unboxed single-field record, inlined or not *)
156156
| Record_inlined of (* Inlined record *)
157157
{ tag : int ; name : string; num_nonconsts : int; optional_labels : string list; attrs: Parsetree.attributes}
158-
| Record_extension (* Inlined record under extension *)
158+
| Record_extension of (* Inlined record under extension *)
159+
{ is_exception : bool }
159160
| Record_optional_labels of string list (* List of optional labels *)
160161

161162
and label_declaration =
@@ -322,5 +323,8 @@ let same_record_representation x y =
322323
| Record_inlined y ->
323324
tag = y.tag && name = y.name && num_nonconsts = y.num_nonconsts && optional_labels = y.optional_labels
324325
| _ -> false)
325-
| Record_extension -> y = Record_extension
326+
| Record_extension {is_exception} -> (
327+
match y with
328+
| Record_extension y -> is_exception = y.is_exception
329+
| _ -> false)
326330
| Record_unboxed x -> ( match y with Record_unboxed y -> x = y | _ -> false)

jscomp/ml/types.mli

+2-1
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,8 @@ and record_representation =
302302
| Record_unboxed of bool (* Unboxed single-field record, inlined or not *)
303303
| Record_inlined of (* Inlined record *)
304304
{ tag : int ; name : string; num_nonconsts : int; optional_labels : string list; attrs: Parsetree.attributes }
305-
| Record_extension (* Inlined record under extension *)
305+
| Record_extension of (* Inlined record under extension *)
306+
{ is_exception : bool }
306307
| Record_optional_labels of string list (* List of optional labels *)
307308

308309
and label_declaration =

0 commit comments

Comments
 (0)