Skip to content

Commit b350b4c

Browse files
committed
snapshot
1 parent 3ecf863 commit b350b4c

File tree

7 files changed

+366
-275
lines changed

7 files changed

+366
-275
lines changed

jscomp/main/builtin_cmi_datasets.ml

Lines changed: 14 additions & 14 deletions
Large diffs are not rendered by default.

jscomp/test/gpr_2503_test.js

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,15 @@ function b(loc, b$1) {
2222
function makeWrapper(foo, param) {
2323
var tmp = {};
2424
if (foo !== undefined) {
25-
tmp.foo = (function () {
26-
switch (Caml_option.valFromOption(foo)) {
27-
case "a" :
28-
return "a";
29-
case "b" :
30-
return "b";
31-
32-
}
33-
})();
25+
tmp.foo = Caml_option.valFromOption(foo).NAME;
3426
}
3527
console.log(tmp);
3628

3729
}
3830

3931
function makeWrapper2(foo, param) {
4032
console.log({
41-
foo: (function () {
42-
switch (foo) {
43-
case "a" :
44-
return "a";
45-
case "b" :
46-
return "b";
47-
48-
}
49-
})()
33+
foo: foo.NAME
5034
});
5135

5236
}
@@ -57,15 +41,7 @@ function makeWrapper3(foo, param) {
5741
console.log(2);
5842
var tmp = {};
5943
if (foo !== undefined) {
60-
tmp.foo = (function () {
61-
switch (Caml_option.valFromOption(foo)) {
62-
case "a" :
63-
return "a";
64-
case "b" :
65-
return "b";
66-
67-
}
68-
})();
44+
tmp.foo = Caml_option.valFromOption(foo).NAME;
6945
}
7046
return tmp;
7147
}
@@ -77,15 +53,7 @@ function makeWrapper4(foo, param) {
7753
foo > 10 ? "b" : "a"
7854
);
7955
if (tmp$1 !== undefined) {
80-
tmp.foo = (function () {
81-
switch (Caml_option.valFromOption(tmp$1)) {
82-
case "a" :
83-
return "a";
84-
case "b" :
85-
return "b";
86-
87-
}
88-
})();
56+
tmp.foo = Caml_option.valFromOption(tmp$1).NAME;
8957
}
9058
return tmp;
9159
}

jscomp/test/gpr_2633_test.js

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,12 @@
33
var Curry = require("../../lib/js/curry.js");
44

55
function on1(foo, $$event) {
6-
foo.on((function () {
7-
switch ($$event.NAME) {
8-
case "bar" :
9-
return "bar";
10-
case "foo" :
11-
return "foo";
12-
13-
}
14-
})(), $$event.VAL);
6+
foo.on($$event.NAME, $$event.VAL);
157

168
}
179

1810
function on2(foo, h, $$event) {
19-
foo.on((function () {
20-
switch (Curry._1(h, $$event).NAME) {
21-
case "bar" :
22-
return "bar";
23-
case "foo" :
24-
return "foo";
25-
26-
}
27-
})(), Curry._1(h, $$event).VAL);
11+
foo.on(Curry._1(h, $$event).NAME, Curry._1(h, $$event).VAL);
2812

2913
}
3014

lib/4.06.1/unstable/js_compiler.ml

Lines changed: 103 additions & 61 deletions
Large diffs are not rendered by default.

lib/4.06.1/unstable/js_refmt_compiler.ml

Lines changed: 103 additions & 61 deletions
Large diffs are not rendered by default.

lib/4.06.1/unstable/native_ppx.ml

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17266,15 +17266,20 @@ type cst = private
1726617266

1726717267
type label = private
1726817268
| Obj_label of {name : string}
17269-
(* | Obj_labelCst of {name : string ; cst : cst} *)
1727017269
| Obj_empty
1727117270

1727217271
| Obj_optional of {name : string}
1727317272
(* it will be ignored , side effect will be recorded *)
1727417273

17274+
17275+
1727517276
type attr =
17276-
| NullString of (Ast_compatible.hash_label * string) list (* `a does not have any value*)
17277-
| NonNullString of (Ast_compatible.hash_label * string) list (* `a of int *)
17277+
| Poly_var of {
17278+
has_payload : bool ;
17279+
descr :
17280+
(Ast_compatible.hash_label * string)
17281+
list option
17282+
}
1727817283
| Int of (Ast_compatible.hash_label * int ) list (* ([`a | `b ] [@bs.int])*)
1727917284
| Arg_cst of cst
1728017285
| Fn_uncurry_arity of int (* annotated with [@bs.uncurry ] or [@bs.uncurry 2]*)
@@ -17363,9 +17368,16 @@ type label =
1736317368
| Obj_optional of {name : string }
1736417369
(* it will be ignored , side effect will be recorded *)
1736517370

17371+
17372+
1736617373
type attr =
17367-
| NullString of (Ast_compatible.hash_label * string) list (* `a does not have any value*)
17368-
| NonNullString of (Ast_compatible.hash_label * string) list (* `a of int *)
17374+
| Poly_var of {
17375+
has_payload : bool ;
17376+
descr :
17377+
(Ast_compatible.hash_label * string) list
17378+
option
17379+
}
17380+
(* `a does not have any value*)
1736917381
| Int of (Ast_compatible.hash_label * int ) list (* ([`a | `b ] [@bs.int])*)
1737017382
| Arg_cst of cst
1737117383
| Fn_uncurry_arity of int (* annotated with [@bs.uncurry ] or [@bs.uncurry 2]*)
@@ -17575,35 +17587,36 @@ let map_constructor_declarations_into_ints
1757517587
*)
1757617588
let map_row_fields_into_strings ptyp_loc
1757717589
(row_fields : Parsetree.row_field list) : External_arg_spec.attr =
17590+
let has_bs_as = ref false in
1757817591
let case, result =
1757917592
Ext_list.fold_right row_fields (`Nothing, []) (fun tag (nullary, acc) ->
1758017593
match nullary, tag with
1758117594
| (`Nothing | `Null),
1758217595
Rtag (label, attrs, true, [])
1758317596
->
17584-
begin match Ast_attributes.iter_process_bs_string_as attrs with
17597+
let name =
17598+
match Ast_attributes.iter_process_bs_string_as attrs with
1758517599
| Some name ->
17586-
`Null, ((Ast_compatible.hash_label label, name) :: acc )
17587-
17588-
| None ->
17589-
`Null, ((Ast_compatible.hash_label label, Ast_compatible.label_of_name label) :: acc )
17590-
end
17600+
has_bs_as := true; name
17601+
| None -> label.txt
17602+
in `Null, (label.txt, name) :: acc
1759117603
| (`Nothing | `NonNull), Rtag(label, attrs, false, ([ _ ]))
1759217604
->
17593-
begin match Ast_attributes.iter_process_bs_string_as attrs with
17605+
let name =
17606+
match Ast_attributes.iter_process_bs_string_as attrs with
1759417607
| Some name ->
17595-
`NonNull, ((Ast_compatible.hash_label label, name) :: acc)
17596-
| None ->
17597-
`NonNull, ((Ast_compatible.hash_label label, Ast_compatible.label_of_name label) :: acc)
17598-
end
17608+
has_bs_as := true; name
17609+
| None -> label.txt
17610+
in `NonNull, (label.txt, name) :: acc
1759917611
| _ -> Bs_syntaxerr.err ptyp_loc Invalid_bs_string_type
1760017612

1760117613
) in
1760217614
match case with
1760317615
| `Nothing -> Bs_syntaxerr.err ptyp_loc Invalid_bs_string_type
17604-
| `Null -> External_arg_spec.NullString result
17605-
| `NonNull -> NonNullString result
17606-
17616+
| `Null
17617+
| `NonNull ->
17618+
External_arg_spec.Poly_var {has_payload = case = `NonNull ;
17619+
descr = if !has_bs_as then Some result else None }
1760717620

1760817621
let is_enum row_fields =
1760917622
List.for_all (fun (x : Parsetree.row_field) ->
@@ -19700,7 +19713,7 @@ let process_obj
1970019713
{obj_arg_label = External_arg_spec.obj_label s; obj_arg_type},
1970119714
{param_type with ty = new_ty}::arg_types,
1970219715
(({Asttypes.txt = name; loc}, [], Ast_literal.type_int ~loc ()) :: result_types)
19703-
| NullString _ ->
19716+
| Poly_var { has_payload = false ; _} ->
1970419717
let s = Lam_methname.translate name in
1970519718
{obj_arg_label = External_arg_spec.obj_label s; obj_arg_type},
1970619719
{param_type with ty = new_ty }::arg_types,
@@ -19709,7 +19722,7 @@ let process_obj
1970919722
Location.raise_errorf ~loc
1971019723
"The combination of [@@bs.obj], [@@bs.uncurry] is not supported yet"
1971119724
| Extern_unit -> assert false
19712-
| NonNullString _
19725+
| Poly_var { has_payload = true ; _}
1971319726
->
1971419727
Location.raise_errorf ~loc
1971519728
"bs.obj label %s does not support such arg type" name
@@ -19733,7 +19746,7 @@ let process_obj
1973319746
{obj_arg_label = External_arg_spec.optional s ; obj_arg_type },
1973419747
param_type :: arg_types,
1973519748
(({Asttypes.txt = name; loc}, [], Ast_comb.to_undefined_type loc @@ Ast_literal.type_int ~loc ()) :: result_types)
19736-
| NullString _ ->
19749+
| Poly_var {has_payload = false ; _} ->
1973719750
let s = Lam_methname.translate name in
1973819751
{obj_arg_label = External_arg_spec.optional s ; obj_arg_type },
1973919752
param_type::arg_types,
@@ -19745,7 +19758,7 @@ let process_obj
1974519758
Location.raise_errorf ~loc
1974619759
"The combination of [@@bs.obj], [@@bs.uncurry] is not supported yet"
1974719760
| Extern_unit -> assert false
19748-
| NonNullString _
19761+
| Poly_var {has_payload = true; _}
1974919762
->
1975019763
Location.raise_errorf ~loc
1975119764
"bs.obj label %s does not support such arg type" name
@@ -20159,7 +20172,7 @@ let handle_attributes
2015920172
| Optional s ->
2016020173
let arg_type = get_opt_arg_type ~nolabel:false ty in
2016120174
begin match arg_type with
20162-
| NonNullString _ ->
20175+
| Poly_var {has_payload = true; _} ->
2016320176
(* ?x:([`x of int ] [@bs.string]) does not make sense *)
2016420177
Location.raise_errorf
2016520178
~loc

lib/4.06.1/whole_compiler.ml

Lines changed: 103 additions & 61 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)