From 18fbc87efd580c5e80964eb99ff2202f09c5aa17 Mon Sep 17 00:00:00 2001 From: Hongbo Date: Thu, 20 Dec 2018 08:54:21 +0800 Subject: [PATCH 1/4] Fix typo --- jscomp/others/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jscomp/others/Makefile b/jscomp/others/Makefile index ed32c66b124..fb022e45eb6 100644 --- a/jscomp/others/Makefile +++ b/jscomp/others/Makefile @@ -168,7 +168,7 @@ belt_SortArrayString.ml : sort.cppo.ml cppo -D TYPE_STRING $^ >$@ belt_SortArrayInt.mli : sort.cppo.mli cppo -D TYPE_INT $^ > $@ -belt_gSortArrayString.mli : sort.cppo.mli +belt_SortArrayString.mli : sort.cppo.mli cppo -D TYPE_STRING $^ > $@ endif From 4b99bc3ab8c55859885d4eb8bc455684dd1c73cb Mon Sep 17 00:00:00 2001 From: Hongbo Date: Fri, 21 Dec 2018 17:24:45 +0800 Subject: [PATCH 2/4] Fix map staled file --- jscomp/others/belt_MapString.ml | 8 ++++---- jscomp/others/belt_MapString.mli | 8 +++++++- jscomp/others/belt_SortArrayInt.ml | 2 +- jscomp/others/belt_SortArrayString.mli | 4 ++-- jscomp/others/map.cppo.ml | 3 +++ jscomp/others/map.cppo.mli | 11 +++++++++++ jscomp/test/.depend | 13 +++++-------- 7 files changed, 33 insertions(+), 16 deletions(-) diff --git a/jscomp/others/belt_MapString.ml b/jscomp/others/belt_MapString.ml index cdb646e964f..ea71bdac447 100644 --- a/jscomp/others/belt_MapString.ml +++ b/jscomp/others/belt_MapString.ml @@ -133,16 +133,16 @@ let rec removeMany0 t xs i len = | Some t -> removeMany0 t xs (i + 1) len else N.return t - -let findFirstByU = N.findFirstByU -let findFirstBy = N.findFirstBy - + let removeMany t keys = let len = A.length keys in match N.toOpt t with | None -> N.empty | Some t -> removeMany0 t keys 0 len +let findFirstByU = N.findFirstByU +let findFirstBy = N.findFirstBy + let mergeMany h arr = let len = A.length arr in let v = ref h in diff --git a/jscomp/others/belt_MapString.mli b/jscomp/others/belt_MapString.mli index d75e479d5d8..ca4b3c78543 100644 --- a/jscomp/others/belt_MapString.mli +++ b/jscomp/others/belt_MapString.mli @@ -22,7 +22,13 @@ val eq: 'v t -> 'v t -> ('v -> 'v -> bool) -> bool val findFirstByU : 'v t -> (key -> 'v -> bool [@bs]) -> (key * 'v) option val findFirstBy : 'v t -> (key -> 'v -> bool) -> (key * 'v) option (** [findFirstBy m p] uses funcion [f] to find the first key value pair - to match predicate [p]. *) + to match predicate [p]. + + @example {[ + let s0 = fromArray ~id:(module IntCmp) [|4,"4";1,"1";2,"2,"3""|];; + findFirstBy s0 (fun k v -> k = 4 ) = option (4, "4");; + ]} +*) val forEachU: 'v t -> (key -> 'v -> unit [@bs]) -> unit val forEach: 'v t -> (key -> 'v -> unit) -> unit diff --git a/jscomp/others/belt_SortArrayInt.ml b/jscomp/others/belt_SortArrayInt.ml index c2fe530ae13..6b6c3d682e9 100644 --- a/jscomp/others/belt_SortArrayInt.ml +++ b/jscomp/others/belt_SortArrayInt.ml @@ -1,7 +1,7 @@ # 2 "sort.cppo.ml" type element = int -# 9 +# 9 "sort.cppo.ml" module A = Belt_Array let rec sortedLengthAuxMore (xs : element array) prec acc len = diff --git a/jscomp/others/belt_SortArrayString.mli b/jscomp/others/belt_SortArrayString.mli index a5d156166c2..a2497d750b0 100644 --- a/jscomp/others/belt_SortArrayString.mli +++ b/jscomp/others/belt_SortArrayString.mli @@ -29,10 +29,10 @@ applies here, except the comparator is fixed and inlined *) -# 34 +# 34 "sort.cppo.mli" type element = string -# 39 +# 39 "sort.cppo.mli" val strictlySortedLength: element array -> int (** The same as {!Belt_SortArray.strictlySortedLength } except the comparator is fixed diff --git a/jscomp/others/map.cppo.ml b/jscomp/others/map.cppo.ml index 60e787cf1b2..8983d004a04 100644 --- a/jscomp/others/map.cppo.ml +++ b/jscomp/others/map.cppo.ml @@ -145,6 +145,9 @@ let removeMany t keys = | None -> N.empty | Some t -> removeMany0 t keys 0 len +let findFirstByU = N.findFirstByU +let findFirstBy = N.findFirstBy + let mergeMany h arr = let len = A.length arr in let v = ref h in diff --git a/jscomp/others/map.cppo.mli b/jscomp/others/map.cppo.mli index fbd1ce0f33b..466d982f3e7 100644 --- a/jscomp/others/map.cppo.mli +++ b/jscomp/others/map.cppo.mli @@ -23,6 +23,17 @@ val eq: 'v t -> 'v t -> ('v -> 'v -> bool) -> bool equal, that is, contain equal keys and associate them with equal data. *) +val findFirstByU : 'v t -> (key -> 'v -> bool [@bs]) -> (key * 'v) option +val findFirstBy : 'v t -> (key -> 'v -> bool) -> (key * 'v) option +(** [findFirstBy m p] uses funcion [f] to find the first key value pair + to match predicate [p]. + + @example {[ + let s0 = fromArray ~id:(module IntCmp) [|4,"4";1,"1";2,"2,"3""|];; + findFirstBy s0 (fun k v -> k = 4 ) = option (4, "4");; + ]} +*) + val forEachU: 'v t -> (key -> 'v -> unit [@bs]) -> unit val forEach: 'v t -> (key -> 'v -> unit) -> unit (** [forEach m f] applies [f] to all bindings in map [m]. diff --git a/jscomp/test/.depend b/jscomp/test/.depend index deb86d2321c..580b251df61 100644 --- a/jscomp/test/.depend +++ b/jscomp/test/.depend @@ -337,7 +337,6 @@ int_hashtbl_test.cmj : mt.cmj int_map.cmj : int_overflow_test.cmj : mt.cmj ../runtime/js.cmj int_switch_test.cmj : mt.cmj -int_swtich_test.cmj : io_test.cmj : ../runtime/js.cmj js_array_test.cmj : mt.cmj ../runtime/js.cmj js_bool_test.cmj : mt.cmj @@ -367,7 +366,6 @@ js_typed_array_test.cmj : mt.cmj ../others/js_typed_array.cmj \ js_undefined_test.cmj : mt.cmj ../others/js_undefined.cmj ../runtime/js.cmj js_val.cmj : jsoo_400_test.cmj : mt.cmj -jsoo_485.cmj : jsoo_485_test.cmj : key_word_property.cmj : key_word_property2.cmj : export_keyword.cmj @@ -423,12 +421,12 @@ obj_literal_ppx_test.cmj : ../runtime/js.cmj obj_magic_test.cmj : mt.cmj obj_test.cmj : mt.cmj obj_type_test.cmj : ../runtime/js.cmj -ocaml_parsetree_main.cmj : mt.cmj +ocaml_parsetree_main_bspack.cmj : mt.cmj ocaml_parsetree_test.cmj : ../others/node.cmj ../runtime/js.cmj \ ocaml_parsetree_test.cmi ocaml_proto_test.cmj : mt.cmj ocaml_proto_test.cmi ocaml_re_test.cmj : mt.cmj -ocaml_typed_tree_main.cmj : mt.cmj +ocaml_typed_tree_main_bspack.cmj : mt.cmj ocaml_typedtree_test.cmj : ../others/node.cmj ../runtime/js.cmj \ ocaml_typedtree_test.cmi of_string_test.cmj : mt.cmj @@ -438,7 +436,7 @@ option_repr_test.cmj : mt.cmj ../runtime/js.cmj ../others/belt.cmj optional_ffi_test.cmj : mt.cmj optional_regression_test.cmj : mt.cmj ../runtime/js.cmj parser_api.cmj : -parser_api_main.cmj : +parser_api_main_bspack.cmj : parser_api_test.cmj : parser_api.cmj mt.cmj pipe_send_readline.cmj : ../runtime/js.cmj pipe_syntax.cmj : @@ -487,9 +485,8 @@ sexpm_test.cmj : sexpm.cmj mt.cmj ../runtime/js.cmj shift_test.cmj : side_effect.cmj : ../runtime/js.cmj side_effect_free.cmj : -simple_derive_test.cmj : ../runtime/js.cmj ../others/belt.cmj \ - simple_derive_test.cmi -simple_derive_use.cmj : simple_derive_test.cmj simple_derive_use.cmi +simple_derive_test.cmj : simple_derive_test.cmi +simple_derive_use.cmj : simple_derive_use.cmi simple_lexer_test.cmj : mt.cmj simplify_lambda_632o.cmj : single_module_alias.cmj : From 2fbd7de2de4581ef849d79818290fbf79c23aa88 Mon Sep 17 00:00:00 2001 From: Hongbo Date: Fri, 21 Dec 2018 17:31:23 +0800 Subject: [PATCH 3/4] fix #3214 --- jscomp/bin/all_ounit_tests.ml | 2 +- jscomp/ext/ext_ident.ml | 2 +- jscomp/test/.depend | 1 + jscomp/test/build.ninja | 1 + jscomp/test/promise_test.js | 8 ++++++++ jscomp/test/promise_test.ml | 3 +++ lib/js/js.js | 4 ++-- lib/whole_compiler.ml | 2 +- 8 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 jscomp/test/promise_test.js create mode 100644 jscomp/test/promise_test.ml diff --git a/jscomp/bin/all_ounit_tests.ml b/jscomp/bin/all_ounit_tests.ml index 7af0197fa19..fb4e34d1b2e 100644 --- a/jscomp/bin/all_ounit_tests.ml +++ b/jscomp/bin/all_ounit_tests.ml @@ -7500,7 +7500,7 @@ let reserved_words = "Buffer"; (* Node *) "Map"; (* es6*) "Set"; - + "Promise"; "Infinity"; "isFinite"; diff --git a/jscomp/ext/ext_ident.ml b/jscomp/ext/ext_ident.ml index a39c8ad27c0..e7d9378701c 100644 --- a/jscomp/ext/ext_ident.ml +++ b/jscomp/ext/ext_ident.ml @@ -160,7 +160,7 @@ let reserved_words = "Buffer"; (* Node *) "Map"; (* es6*) "Set"; - + "Promise"; "Infinity"; "isFinite"; diff --git a/jscomp/test/.depend b/jscomp/test/.depend index 580b251df61..4c4dad93134 100644 --- a/jscomp/test/.depend +++ b/jscomp/test/.depend @@ -457,6 +457,7 @@ printf_sim.cmj : printf_test.cmj : mt.cmj promise.cmj : ../runtime/js.cmj promise_catch_test.cmj : mt.cmj ../runtime/js.cmj +promise_test.cmj : promise.cmj qcc.cmj : queue_test.cmj : mt.cmj random_test.cmj : mt_global.cmj mt.cmj diff --git a/jscomp/test/build.ninja b/jscomp/test/build.ninja index 7339f80516b..e35e732e7e1 100644 --- a/jscomp/test/build.ninja +++ b/jscomp/test/build.ninja @@ -431,6 +431,7 @@ build printf_sim.cmi printf_sim.cmj : cc printf_sim.ml build printf_test.cmi printf_test.cmj : cc printf_test.ml | mt.cmj build promise.cmi promise.cmj : cc promise.ml build promise_catch_test.cmi promise_catch_test.cmj : cc promise_catch_test.ml | mt.cmj +build promise_test.cmi promise_test.cmj : cc promise_test.ml | promise.cmj build qcc.cmi qcc.cmj : cc qcc.ml build queue_test.cmi queue_test.cmj : cc queue_test.ml | mt.cmj build random_test.cmi random_test.cmj : cc random_test.ml | mt_global.cmj mt.cmj diff --git a/jscomp/test/promise_test.js b/jscomp/test/promise_test.js new file mode 100644 index 00000000000..7103138a853 --- /dev/null +++ b/jscomp/test/promise_test.js @@ -0,0 +1,8 @@ +'use strict'; + +var $$Promise = require("./promise.js"); + +var v = $$Promise.f; + +exports.v = v; +/* Promise Not a pure module */ diff --git a/jscomp/test/promise_test.ml b/jscomp/test/promise_test.ml new file mode 100644 index 00000000000..0ad52226eb1 --- /dev/null +++ b/jscomp/test/promise_test.ml @@ -0,0 +1,3 @@ + + +let v = Promise.f \ No newline at end of file diff --git a/lib/js/js.js b/lib/js/js.js index 1d49244e9e2..c5b24315f33 100644 --- a/lib/js/js.js +++ b/lib/js/js.js @@ -21,7 +21,7 @@ var $$String = 0; var Re = 0; -var Promise = 0; +var $$Promise = 0; var $$Date = 0; @@ -63,7 +63,7 @@ exports.Exn = Exn; exports.$$Array = $$Array; exports.$$String = $$String; exports.Re = Re; -exports.Promise = Promise; +exports.$$Promise = $$Promise; exports.$$Date = $$Date; exports.Dict = Dict; exports.Global = Global; diff --git a/lib/whole_compiler.ml b/lib/whole_compiler.ml index d8913e48154..80af5b1ea75 100644 --- a/lib/whole_compiler.ml +++ b/lib/whole_compiler.ml @@ -61050,7 +61050,7 @@ let reserved_words = "Buffer"; (* Node *) "Map"; (* es6*) "Set"; - + "Promise"; "Infinity"; "isFinite"; From 118f353cac5b4135afceb85d5f1f5ed8cd188d70 Mon Sep 17 00:00:00 2001 From: Hongbo Date: Fri, 21 Dec 2018 17:44:19 +0800 Subject: [PATCH 4/4] fix ci --- jscomp/test/.depend | 2 +- jscomp/test/build.ninja | 2 +- jscomp/test/{promise_test.js => test_promise_bind.js} | 0 jscomp/test/{promise_test.ml => test_promise_bind.ml} | 0 4 files changed, 2 insertions(+), 2 deletions(-) rename jscomp/test/{promise_test.js => test_promise_bind.js} (100%) rename jscomp/test/{promise_test.ml => test_promise_bind.ml} (100%) diff --git a/jscomp/test/.depend b/jscomp/test/.depend index 4c4dad93134..28a41f963ee 100644 --- a/jscomp/test/.depend +++ b/jscomp/test/.depend @@ -457,7 +457,6 @@ printf_sim.cmj : printf_test.cmj : mt.cmj promise.cmj : ../runtime/js.cmj promise_catch_test.cmj : mt.cmj ../runtime/js.cmj -promise_test.cmj : promise.cmj qcc.cmj : queue_test.cmj : mt.cmj random_test.cmj : mt_global.cmj mt.cmj @@ -581,6 +580,7 @@ test_pervasive.cmj : test_pervasives2.cmj : test_pervasives3.cmj : test_primitive.cmj : +test_promise_bind.cmj : promise.cmj test_ramification.cmj : test_react.cmj : ../runtime/js.cmj test_react_case.cmj : diff --git a/jscomp/test/build.ninja b/jscomp/test/build.ninja index e35e732e7e1..5b5bf4ffbe7 100644 --- a/jscomp/test/build.ninja +++ b/jscomp/test/build.ninja @@ -431,7 +431,6 @@ build printf_sim.cmi printf_sim.cmj : cc printf_sim.ml build printf_test.cmi printf_test.cmj : cc printf_test.ml | mt.cmj build promise.cmi promise.cmj : cc promise.ml build promise_catch_test.cmi promise_catch_test.cmj : cc promise_catch_test.ml | mt.cmj -build promise_test.cmi promise_test.cmj : cc promise_test.ml | promise.cmj build qcc.cmi qcc.cmj : cc qcc.ml build queue_test.cmi queue_test.cmj : cc queue_test.ml | mt.cmj build random_test.cmi random_test.cmj : cc random_test.ml | mt_global.cmj mt.cmj @@ -562,6 +561,7 @@ build test_pervasive.cmi test_pervasive.cmj : cc test_pervasive.ml build test_pervasives2.cmi test_pervasives2.cmj : cc test_pervasives2.ml build test_pervasives3.cmi test_pervasives3.cmj : cc test_pervasives3.ml build test_primitive.cmi test_primitive.cmj : cc test_primitive.ml +build test_promise_bind.cmi test_promise_bind.cmj : cc test_promise_bind.ml | promise.cmj build test_ramification.cmi test_ramification.cmj : cc test_ramification.ml build test_react.cmi test_react.cmj : cc test_react.ml build test_react_case.cmi test_react_case.cmj : cc test_react_case.ml diff --git a/jscomp/test/promise_test.js b/jscomp/test/test_promise_bind.js similarity index 100% rename from jscomp/test/promise_test.js rename to jscomp/test/test_promise_bind.js diff --git a/jscomp/test/promise_test.ml b/jscomp/test/test_promise_bind.ml similarity index 100% rename from jscomp/test/promise_test.ml rename to jscomp/test/test_promise_bind.ml