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/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 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..28a41f963ee 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 : @@ -583,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 7339f80516b..5b5bf4ffbe7 100644 --- a/jscomp/test/build.ninja +++ b/jscomp/test/build.ninja @@ -561,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/test_promise_bind.js b/jscomp/test/test_promise_bind.js new file mode 100644 index 00000000000..7103138a853 --- /dev/null +++ b/jscomp/test/test_promise_bind.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/test_promise_bind.ml b/jscomp/test/test_promise_bind.ml new file mode 100644 index 00000000000..0ad52226eb1 --- /dev/null +++ b/jscomp/test/test_promise_bind.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";