diff --git a/jscomp/others/node_fs.ml b/jscomp/others/node_fs.ml index d0640bea9..14ca2ed80 100644 --- a/jscomp/others/node_fs.ml +++ b/jscomp/others/node_fs.ml @@ -67,7 +67,7 @@ module Watch = struct f: ([ `change of (string (*eventType*) -> Node.string_buffer (* filename *) -> unit[@u]) - | `error of (unit -> unit[@u]) ] + | `error of (unit -> unit[@u0]) ] [@mel.string]) -> t = "on" [@@mel.send] diff --git a/jscomp/runtime/caml_external_polyfill.ml b/jscomp/runtime/caml_external_polyfill.ml index 7f668f78e..fd11ced25 100644 --- a/jscomp/runtime/caml_external_polyfill.ml +++ b/jscomp/runtime/caml_external_polyfill.ml @@ -28,7 +28,7 @@ open struct module Js = Js_internal end -let getGlobalThis : (unit -> global[@u]) = +let getGlobalThis : (unit -> global[@u0]) = [%raw {| function(){ if (typeof globalThis !== 'undefined') return globalThis; diff --git a/jscomp/stdlib/camlinternalLazy.ml b/jscomp/stdlib/camlinternalLazy.ml index 61edcf460..5414ee9ab 100644 --- a/jscomp/stdlib/camlinternalLazy.ml +++ b/jscomp/stdlib/camlinternalLazy.ml @@ -36,8 +36,8 @@ type 'a concrete = { exception Undefined -external fnToVal : (unit -> 'a [@u]) -> 'a = "%identity" -external valToFn : 'a -> (unit -> 'a [@u]) = "%identity" +external fnToVal : (unit -> 'a [@u0]) -> 'a = "%identity" +external valToFn : 'a -> (unit -> 'a [@u0]) = "%identity" external castToConcrete : 'a lazy_t -> 'a concrete = "%identity" external of_concrete : 'a concrete -> 'a lazy_t = "%identity" @@ -46,15 +46,15 @@ let is_val (type a ) (l : a lazy_t) : bool = -let forward_with_closure (type a ) (blk : a concrete) (closure : unit -> a [@u]) : a = - let result = closure () [@u] in +let forward_with_closure (type a ) (blk : a concrete) (closure : unit -> a [@u0]) : a = + let result = closure () [@u0] in (* do set_field BEFORE set_tag *) blk.value <- result; blk.tag<- true; result -let raise_undefined = (fun [@u] () -> raise Undefined) +let raise_undefined = (fun [@u0] () -> raise Undefined) (* Assume [blk] is a block with tag lazy *) let force_lazy_block (type a ) (blk : a t) : a = @@ -64,7 +64,7 @@ let force_lazy_block (type a ) (blk : a t) : a = try forward_with_closure blk closure with e -> - blk.value <- fnToVal (fun [@u] () -> raise e); + blk.value <- fnToVal (fun [@u0] () -> raise e); raise e diff --git a/jscomp/test/demo.ml b/jscomp/test/demo.ml index fee9fe057..e89e094ff 100644 --- a/jscomp/test/demo.ml +++ b/jscomp/test/demo.ml @@ -94,7 +94,7 @@ let ui_layout with e -> () end; let fmt v = toFixed v 2 in - set_interval (fun [@u] () -> + set_interval (fun [@u0] () -> grid##dataSource #= ( array_map data (fun [@u] {ticker; price } -> diff --git a/jscomp/test/demo_binding.ml b/jscomp/test/demo_binding.ml index 6dc23ce64..e77dbeec1 100644 --- a/jscomp/test/demo_binding.ml +++ b/jscomp/test/demo_binding.ml @@ -102,7 +102,7 @@ class type textArea = end[@u] -external set_interval : (unit -> unit [@u]) -> float -> unit = "setInterval" +external set_interval : (unit -> unit [@u0]) -> float -> unit = "setInterval" [@@mel.module "@runtime", "Runtime"] external toFixed : float -> int -> string = "toFixed" [@@mel.send] diff --git a/jscomp/test/dist/jscomp/test/event_ffi.js b/jscomp/test/dist/jscomp/test/event_ffi.js index a2847be6f..470821e5d 100644 --- a/jscomp/test/dist/jscomp/test/event_ffi.js +++ b/jscomp/test/dist/jscomp/test/event_ffi.js @@ -5,11 +5,11 @@ var Curry = require("melange.js/curry.js"); var Stdlib__List = require("melange/list.js"); function h0(x) { - return x(); + return x(undefined); } function h00(x) { - return x(); + return x(undefined); } function h1(x, y) { @@ -39,7 +39,7 @@ function ocaml_run(b, c) { return (x + b | 0) + c | 0; } -function a0() { +function a0(param) { console.log("hi"); } diff --git a/jscomp/test/dist/jscomp/test/exception_raise_test.js b/jscomp/test/dist/jscomp/test/exception_raise_test.js index 4e5222398..ccdf6afc7 100644 --- a/jscomp/test/dist/jscomp/test/exception_raise_test.js +++ b/jscomp/test/dist/jscomp/test/exception_raise_test.js @@ -196,7 +196,7 @@ function eq(loc, x, y) { try { ((()=>{throw 2} - )()); + )(undefined)); } catch (raw_e$2){ var e = Caml_js_exceptions.internalToOCamlException(raw_e$2); diff --git a/jscomp/test/dist/jscomp/test/ffi_arity_test.js b/jscomp/test/dist/jscomp/test/ffi_arity_test.js index 12b5daa48..8e9a99f42 100644 --- a/jscomp/test/dist/jscomp/test/ffi_arity_test.js +++ b/jscomp/test/dist/jscomp/test/ffi_arity_test.js @@ -40,7 +40,7 @@ var hh = [ return parseInt(x); }); -function u() { +function u(param) { return 3; } @@ -54,8 +54,8 @@ function fff(param) { vvv.contents = vvv.contents + 1 | 0; } -function g() { - return fff(undefined); +function g(param) { + fff(undefined); } function abc(x, y, z) { @@ -66,7 +66,7 @@ function abc(x, y, z) { var abc_u = abc; -g(); +g(undefined); Mt.from_pair_suites("Ffi_arity_test", { hd: [ diff --git a/jscomp/test/dist/jscomp/test/ocaml_parsetree_test.js b/jscomp/test/dist/jscomp/test/ocaml_parsetree_test.js index 93de45ca1..3c858e244 100644 --- a/jscomp/test/dist/jscomp/test/ocaml_parsetree_test.js +++ b/jscomp/test/dist/jscomp/test/ocaml_parsetree_test.js @@ -2042,56 +2042,56 @@ function from_pair_suites(name, suites) { var match = Stdlib__Array.to_list(Process.argv); if (match) { if (is_mocha(undefined)) { - describe(name, (function () { - return Stdlib__List.iter((function (param) { - var code = param[1]; - it(param[0], (function () { - var spec = Curry._1(code, undefined); - switch (spec.TAG | 0) { - case /* Eq */0 : - Assert.deepEqual(spec._0, spec._1); - return ; - case /* Neq */1 : - Assert.notDeepEqual(spec._0, spec._1); - return ; - case /* StrictEq */2 : - Assert.strictEqual(spec._0, spec._1); - return ; - case /* StrictNeq */3 : - Assert.notStrictEqual(spec._0, spec._1); - return ; - case /* Ok */4 : - Assert.ok(spec._0); - return ; - case /* Approx */5 : - var b = spec._1; - var a = spec._0; - if (!close_enough(undefined, a, b)) { - Assert.deepEqual(a, b); - return ; - } else { - return ; - } - case /* ApproxThreshold */6 : - var b$1 = spec._2; - var a$1 = spec._1; - if (!close_enough(spec._0, a$1, b$1)) { - Assert.deepEqual(a$1, b$1); - return ; - } else { - return ; - } - case /* ThrowAny */7 : - Assert.throws(spec._0); - return ; - case /* Fail */8 : - return assert_fail("failed"); - case /* FailWith */9 : - return assert_fail(spec._0); - + describe(name, (function (param) { + Stdlib__List.iter((function (param) { + var code = param[1]; + it(param[0], (function () { + var spec = Curry._1(code, undefined); + switch (spec.TAG | 0) { + case /* Eq */0 : + Assert.deepEqual(spec._0, spec._1); + return ; + case /* Neq */1 : + Assert.notDeepEqual(spec._0, spec._1); + return ; + case /* StrictEq */2 : + Assert.strictEqual(spec._0, spec._1); + return ; + case /* StrictNeq */3 : + Assert.notStrictEqual(spec._0, spec._1); + return ; + case /* Ok */4 : + Assert.ok(spec._0); + return ; + case /* Approx */5 : + var b = spec._1; + var a = spec._0; + if (!close_enough(undefined, a, b)) { + Assert.deepEqual(a, b); + return ; + } else { + return ; + } + case /* ApproxThreshold */6 : + var b$1 = spec._2; + var a$1 = spec._1; + if (!close_enough(spec._0, a$1, b$1)) { + Assert.deepEqual(a$1, b$1); + return ; + } else { + return ; } - })); - }), suites); + case /* ThrowAny */7 : + Assert.throws(spec._0); + return ; + case /* Fail */8 : + return assert_fail("failed"); + case /* FailWith */9 : + return assert_fail(spec._0); + + } + })); + }), suites); })); return ; } else { diff --git a/jscomp/test/dist/jscomp/test/ppx_apply_test.js b/jscomp/test/dist/jscomp/test/ppx_apply_test.js index 04694dcd3..ae7d13de8 100644 --- a/jscomp/test/dist/jscomp/test/ppx_apply_test.js +++ b/jscomp/test/dist/jscomp/test/ppx_apply_test.js @@ -30,7 +30,7 @@ function eq(loc, x, y) { var u = 3; -function nullary() { +function nullary(param) { return 3; } diff --git a/jscomp/test/dist/jscomp/test/raw_output_test.js b/jscomp/test/dist/jscomp/test/raw_output_test.js index be06893a9..a1974236a 100644 --- a/jscomp/test/dist/jscomp/test/raw_output_test.js +++ b/jscomp/test/dist/jscomp/test/raw_output_test.js @@ -10,9 +10,9 @@ function mk(fn) { (((_)=> console.log('should works') )(undefined)); -console.log((function () { +console.log((function (param) { return 1; - })()); + })(undefined)); exports.mk = mk; /* Not a pure module */ diff --git a/jscomp/test/dist/jscomp/test/re_or_res/reactTestUtils.js b/jscomp/test/dist/jscomp/test/re_or_res/reactTestUtils.js index 5c9543624..f3ff88ef9 100644 --- a/jscomp/test/dist/jscomp/test/re_or_res/reactTestUtils.js +++ b/jscomp/test/dist/jscomp/test/re_or_res/reactTestUtils.js @@ -8,14 +8,14 @@ var Curry = require("melange.js/curry.js"); var TestUtils = require("react-dom/test-utils"); function act(func) { - var reactFunc = function () { + var reactFunc = function (param) { Curry._1(func, undefined); }; TestUtils.act(reactFunc); } function actAsync(func) { - return TestUtils.act(function () { + return TestUtils.act(function (param) { return Curry._1(func, undefined); }); } diff --git a/jscomp/test/dist/jscomp/test/uncurry_glob_test.js b/jscomp/test/dist/jscomp/test/uncurry_glob_test.js index f8ce2fb1f..67cd5f61c 100644 --- a/jscomp/test/dist/jscomp/test/uncurry_glob_test.js +++ b/jscomp/test/dist/jscomp/test/uncurry_glob_test.js @@ -9,11 +9,11 @@ function M(U) { }; } -function f() { +function f(param) { return 3; } -f(); +f(undefined); function $plus$great(a, h) { return h(a); diff --git a/jscomp/test/gpr_2682_test.ml b/jscomp/test/gpr_2682_test.ml index 70523f9de..a09359f30 100644 --- a/jscomp/test/gpr_2682_test.ml +++ b/jscomp/test/gpr_2682_test.ml @@ -52,9 +52,8 @@ end ;; forIn [%obj{x = 3 ; y = 3}] (fun[@u] x -> Js.log x) -let f3 : unit -> bool [@u] = [%raw"()=>true"] +let f3 : unit -> bool [@u0] = [%raw"()=>true"] -let bbbb = f3 () [@u] +let bbbb = f3 () [@u0] ;;assert (bbbb) - diff --git a/jscomp/test/http_types.ml b/jscomp/test/http_types.ml index df1e866ec..fa49571ed 100644 --- a/jscomp/test/http_types.ml +++ b/jscomp/test/http_types.ml @@ -23,7 +23,7 @@ class type _resp = type resp = _resp Js.t class type _server = object - method listen : int -> string -> (unit -> unit [@u]) -> unit + method listen : int -> string -> (unit -> unit [@u0]) -> unit end[@u] type server = _server Js.t class type _http = diff --git a/jscomp/test/mt.ml b/jscomp/test/mt.ml index 22171618a..ce1f5ae37 100644 --- a/jscomp/test/mt.ml +++ b/jscomp/test/mt.ml @@ -1,4 +1,4 @@ -external describe : string -> (unit -> unit[@u]) -> unit = "describe" +external describe : string -> (unit -> unit[@u0]) -> unit = "describe" external it : string -> (unit -> unit[@mel.uncurry]) -> unit = "it" external it_promise : string -> (unit -> _ Js.Promise.t [@mel.uncurry]) -> unit = "it" @@ -37,7 +37,7 @@ let from_suites name (suite : (string * ('a -> unit)) list) = match Array.to_list Node.Process.process##argv with | _cmd :: _ -> if is_mocha () then - describe name (fun [@u] () -> + describe name (fun [@u0] () -> List.iter (fun (name, code) -> it name code) suite) | _ -> () @@ -96,7 +96,7 @@ let from_pair_suites name (suites : pair_suites) = match Array.to_list Node.Process.process##argv with | _cmd :: _ -> if is_mocha () then - describe name (fun [@u] () -> + describe name (fun [@u0] () -> suites |> List.iter (fun (name, code) -> it name (fun _ -> @@ -111,7 +111,7 @@ let from_promise_suites name (suites : (string * _ Js.Promise.t ) list) = match Array.to_list Node.Process.process##argv with | _cmd :: _ -> if is_mocha () then - describe name (fun [@u] () -> + describe name (fun [@u0] () -> suites |> List.iter (fun (name, code) -> it_promise name (fun _ -> diff --git a/jscomp/test/ocaml_typedtree_test.ml b/jscomp/test/ocaml_typedtree_test.ml index be366f210..a288d5707 100644 --- a/jscomp/test/ocaml_typedtree_test.ml +++ b/jscomp/test/ocaml_typedtree_test.ml @@ -11621,7 +11621,7 @@ end = struct -external describe : string -> (unit -> unit[@u]) -> unit = "describe" +external describe : string -> (unit -> unit[@u0]) -> unit = "describe" external it : string -> (unit -> unit[@mel.uncurry]) -> unit = "it" @@ -11677,7 +11677,7 @@ let from_suites name (suite : (string * ('a -> unit)) list) = match Array.to_list Node.Process.process##argv with | cmd :: _ -> if is_mocha () then - describe name (fun [@u] () -> + describe name (fun [@u0] () -> List.iter (fun (name, code) -> it name code) suite) | _ -> () @@ -11736,7 +11736,7 @@ let from_pair_suites name (suites : pair_suites) = match Array.to_list Node.Process.process##argv with | cmd :: _ -> if is_mocha () then - describe name (fun [@u] () -> + describe name (fun [@u0] () -> suites |> List.iter (fun (name, code) -> it name (fun _ -> @@ -11751,7 +11751,7 @@ let from_promise_suites name (suites : (string * _ Js.Promise.t ) list) = match Array.to_list Node.Process.process##argv with | cmd :: _ -> if is_mocha () then - describe name (fun [@u] () -> + describe name (fun [@u0] () -> suites |> List.iter (fun (name, code) -> it_promise name (fun _ -> diff --git a/jscomp/test/pipe_send_readline.ml b/jscomp/test/pipe_send_readline.ml index 2295841ef..1bf2f4915 100644 --- a/jscomp/test/pipe_send_readline.ml +++ b/jscomp/test/pipe_send_readline.ml @@ -1,18 +1,17 @@ - (* should give a warning on unused attribute.. [@@mel.xx] *) type readline external on : ([ `line of (string -> unit [@u]) - | `close of (unit -> unit [@u])] + | `close of (unit -> unit [@u0])] [@mel.string]) -> 'self = "on" [@@mel.send.pipe:readline as 'self] let u rl = rl |> on (`line (fun [@u] x -> Js.log x )) - |> on (`close (fun [@u] () -> Js.log "finished")) + |> on (`close (fun [@u0] () -> Js.log "finished")) diff --git a/jscomp/test/test_http_server.ml b/jscomp/test/test_http_server.ml index 485eee4f0..7903e93e6 100644 --- a/jscomp/test/test_http_server.ml +++ b/jscomp/test/test_http_server.ml @@ -1,6 +1,3 @@ - - - let port = 3000 let hostname = "127.0.0.1" let create_server http = @@ -9,11 +6,10 @@ let create_server http = resp##setHeader "Content-Type" "text/plain"; resp##_end "Hello world\n" end in - server##listen port hostname begin fun [@u] () -> + server##listen port hostname begin fun [@u0] () -> Js.log ("Server running at http://"^ hostname ^ ":" ^ string_of_int port ^ "/") end let () = create_server Http_types.http - diff --git a/jscomp/test/tramp_fib.ml b/jscomp/test/tramp_fib.ml index 05d83dfb5..a0b187589 100644 --- a/jscomp/test/tramp_fib.ml +++ b/jscomp/test/tramp_fib.ml @@ -5,7 +5,7 @@ let test_id = ref 0 let eq loc x y = Mt.eq_suites ~test_id ~suites loc x y -type 'a bounce = Continue of 'a | Suspend of (unit -> 'a bounce [@u]) +type 'a bounce = Continue of 'a | Suspend of (unit -> 'a bounce [@u0]) (* https://eli.thegreenplace.net/2017/on-recursion-continuations-and-trampolines/ *) (* http://gallium.inria.fr/seminaires/transparents/20141027.Frederic.Bour.pdf *) (* http://www.usrsb.in/blog/blog/2012/08/12/bouncing-pythons-generators-with-a-trampoline/ *) @@ -17,7 +17,7 @@ let rec fib n k = (* Suspend (fun [@u]() -> k (Continue 1 ) [@u]) *) k 1 [@u] | _ -> - Suspend (fun [@u] () -> + Suspend (fun [@u0] () -> fib (n-1) (fun [@u] v0 -> fib (n-2) (fun [@u] v1 -> k (v0 + v1) [@u] @@ -37,7 +37,7 @@ let u = fib 10 (fun [@u] x -> Continue x) let rec iter (bounce : 'a bounce) : 'a = match bounce with | Continue v -> v - | Suspend f -> iter (f () [@u]) + | Suspend f -> iter (f () [@u0]) (* first it needs to be tailcall *) @@ -45,7 +45,7 @@ let rec isEven n = match n with | 0 -> Continue true | 1 -> Continue false - | _ -> Suspend (fun [@u] () -> isOdd (n - 1)) + | _ -> Suspend (fun [@u0] () -> isOdd (n - 1)) and isOdd n = match n with | 0 -> Continue false diff --git a/jscomp/test/uncurry_test.ml b/jscomp/test/uncurry_test.ml index c514a5552..812c61166 100644 --- a/jscomp/test/uncurry_test.ml +++ b/jscomp/test/uncurry_test.ml @@ -1,6 +1,6 @@ type ('a0, 'a1) t = ('a0 -> 'a1 [@u]) -let f0 = fun [@u] () -> 0 +let f0 = fun [@u0] () -> 0 let f1 = fun [@u] a0 -> a0 let f2 = fun [@u] a0 a1 -> (a0,a1) let f3= fun [@u]a0 a1 a2 -> ( a0,a1,a2) @@ -25,7 +25,7 @@ let f21= fun [@u]a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a let f22= fun [@u]a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 -> ( a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21) (* let f23= fun [@u]a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 -> ( a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21) *) (* TODO: better errror message than Unbound record field Js.Fn.I_23 *) -;; f0 () [@u] |. Js.log +;; f0 () [@u0] |. Js.log ;; f1 0 [@u] |. Js.log ;; f2 0 1 [@u] |. Js.log @@ -50,4 +50,4 @@ let f22= fun [@u]a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a ;; f21 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [@u] |. Js.log ;; f22 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 [@u] |. Js.log -let rec xx = fun [@u] () -> xx () [@u] +let rec xx = fun [@u0] () -> xx () [@u0] diff --git a/jscomp/test/uncurry_test.mli b/jscomp/test/uncurry_test.mli index 97493544d..3246e4303 100644 --- a/jscomp/test/uncurry_test.mli +++ b/jscomp/test/uncurry_test.mli @@ -1,5 +1,5 @@ type ('a0, 'a1) t = ('a0 -> 'a1 [@u]) -val f0 : (unit -> int [@u]) +val f0 : (unit -> int [@u0]) val f1 : ('a -> 'a [@u]) val f2 : ('a -> 'b -> 'a * 'b [@u]) val f3 : ('a -> 'b -> 'c -> 'a * 'b * 'c [@u]) @@ -265,4 +265,4 @@ val f22 : 'p * 'q * 'r * 's * 't * 'u * 'v [@u]) -val xx : unit -> 'a [@u] +val xx : unit -> 'a [@u0]