Skip to content

Commit e97538a

Browse files
committed
split obj_label
1 parent 959def7 commit e97538a

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

jscomp/core/lam_compile_external_obj.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ let assemble_obj_args (labels : External_arg_spec.obj_params) (args : J.express
4646
: (Js_op.property_name * E.t ) list * J.expression list * _ =
4747
match labels, args with
4848
| [] , [] -> [], [], []
49-
| {obj_arg_label = Obj_label {name = label; cst = Some cst }} :: labels , args ->
49+
| {obj_arg_label = Obj_labelCst {name = label; cst }} :: labels , args ->
5050
let accs, eff, assign = aux labels args in
5151
(label, Lam_compile_const.translate_arg_cst cst )::accs, eff, assign
5252
(* | {obj_arg_label = EmptyCst _ } :: rest , args -> assert false *)
@@ -55,7 +55,7 @@ let assemble_obj_args (labels : External_arg_spec.obj_params) (args : J.express
5555
let (accs, eff, assign) as r = aux labels args in
5656
if Js_analyzer.no_side_effect_expression arg then r
5757
else (accs, arg::eff, assign)
58-
| ({obj_arg_label = Obj_label {name = label; cst = None} } as arg_kind)::labels, arg::args
58+
| ({obj_arg_label = Obj_label {name = label;} } as arg_kind)::labels, arg::args
5959
->
6060
let accs, eff, assign = aux labels args in
6161
let acc, new_eff = Lam_compile_external_call.ocaml_to_js_eff ~arg_label:Arg_label ~arg_type:arg_kind.obj_arg_type arg in
@@ -80,7 +80,7 @@ let assemble_obj_args (labels : External_arg_spec.obj_params) (args : J.express
8080
(label, x) :: accs , Ext_list.append new_eff eff , assign
8181
end )
8282
~not_sure:(fun _ -> accs, eff , (arg_kind,arg)::assign )
83-
| {obj_arg_label = Obj_empty | Obj_label {cst = None;_} | Obj_optional _ } :: _ , [] -> assert false
83+
| {obj_arg_label = Obj_empty | Obj_label _ | Obj_optional _ } :: _ , [] -> assert false
8484
| [], _ :: _ -> assert false
8585
in
8686
let map, eff, assignment = aux labels args in

jscomp/syntax/external_arg_spec.ml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ type label_noname =
3939
| Arg_optional
4040

4141
type label =
42-
| Obj_label of {name : string ; cst : cst option }
42+
| Obj_label of {name : string }
43+
| Obj_labelCst of {name : string ; cst : cst}
4344
| Obj_empty
4445
| Obj_optional of {name : string }
4546
(* it will be ignored , side effect will be recorded *)
@@ -106,7 +107,13 @@ let cst_int i = Arg_int_lit i
106107
let cst_string s = Arg_string_lit s
107108
let empty_label = Obj_empty
108109

109-
let label name cst = Obj_label {name ; cst}
110+
let label name cst =
111+
match cst with
112+
| None ->
113+
Obj_label {name }
114+
| Some cst ->
115+
Obj_labelCst {name ; cst}
116+
110117
let optional name = Obj_optional {name}
111118

112119
let empty_kind obj_arg_type = { obj_arg_label = empty_label ; obj_arg_type }

jscomp/syntax/external_arg_spec.mli

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ type cst = private
3232

3333

3434
type label = private
35-
| Obj_label of {name : string ; cst : cst option }
35+
| Obj_label of {name : string}
36+
| Obj_labelCst of {name : string ; cst : cst}
3637
| Obj_empty
3738

3839
| Obj_optional of {name : string}

0 commit comments

Comments
 (0)