diff --git a/CHANGELOG.md b/CHANGELOG.md index 14300453a5..5f900fc5e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,6 +66,7 @@ - Avoid generating calls to Curry when adjusting arity of uncurried functions. https://github.com/rescript-lang/rescript-compiler/pull/6870 - Remove `@@uncurried.swap`, which was used for internal tests. https://github.com/rescript-lang/rescript-compiler/pull/6875 - Build the compiler libraries/tests in uncurried mode. https://github.com/rescript-lang/rescript-compiler/pull/6864 +- Ignore `-uncurried` command-line flag. https://github.com/rescript-lang/rescript-compiler/pull/6885 #### :nail_care: Polish diff --git a/jscomp/bsc/rescript_compiler_main.ml b/jscomp/bsc/rescript_compiler_main.ml index e0da2d6364..16e927f42b 100644 --- a/jscomp/bsc/rescript_compiler_main.ml +++ b/jscomp/bsc/rescript_compiler_main.ml @@ -40,7 +40,6 @@ let process_file sourcefile ?(kind ) ppf = The {!Location.input_name} relies on that we write the binary ast properly *) - let uncurried = !Config.uncurried in setup_outcome_printer (); let kind = match kind with @@ -78,11 +77,9 @@ let process_file sourcefile ?(kind ) ppf = | Unknown -> Bsc_args.bad_arg ("don't know what to do with " ^ sourcefile) in - Config.uncurried := uncurried; res let reprint_source_file sourcefile = - let uncurried = !Config.uncurried in let kind = Ext_file_extensions.classify_input (Ext_filename.get_extension_maybe sourcefile) in let sourcefile = set_abs_input_name sourcefile in let res = match kind with @@ -119,7 +116,6 @@ let reprint_source_file sourcefile = print_endline ("Invalid input for reprinting ReScript source. Must be a ReScript file: " ^ sourcefile); exit 2 in - Config.uncurried := uncurried; res let usage = "Usage: bsc \nOptions are:" @@ -406,8 +402,8 @@ let buckle_script_flags : (string * Bsc_args.spec * string) array = "-nopervasives", set Clflags.nopervasives, "*internal*"; - "-uncurried", unit_call (fun () -> Config.uncurried := Uncurried), - "*internal* Set jsx module"; + "-uncurried", unit_call (fun () -> ()), + "*internal* deprecated"; "-v", unit_call print_version_string, "Print compiler version and location of standard library and exit"; diff --git a/jscomp/build_tests/super_errors/expected/warnings3.res.expected b/jscomp/build_tests/super_errors/expected/warnings3.res.expected index d5bfef3589..11f5a87056 100644 --- a/jscomp/build_tests/super_errors/expected/warnings3.res.expected +++ b/jscomp/build_tests/super_errors/expected/warnings3.res.expected @@ -6,7 +6,7 @@ 2 │ let _ = string_of_float(34.) 3 │ let _ = string_of_float(34.) - deprecated: PervasivesU.string_of_float + deprecated: Pervasives.string_of_float Please use Js.Float.toString instead, string_of_float generates unparseable floats @@ -18,7 +18,7 @@ 3 │ let _ = string_of_float(34.) 4 │ - deprecated: PervasivesU.string_of_float + deprecated: Pervasives.string_of_float Please use Js.Float.toString instead, string_of_float generates unparseable floats @@ -30,5 +30,5 @@ 3 │ let _ = string_of_float(34.) 4 │ - deprecated: PervasivesU.string_of_float + deprecated: Pervasives.string_of_float Please use Js.Float.toString instead, string_of_float generates unparseable floats \ No newline at end of file diff --git a/jscomp/build_tests/super_errors/input.js b/jscomp/build_tests/super_errors/input.js index cdf31feffe..d6bf82eb3a 100644 --- a/jscomp/build_tests/super_errors/input.js +++ b/jscomp/build_tests/super_errors/input.js @@ -11,7 +11,7 @@ const fixtures = fs .filter(fileName => path.extname(fileName) === ".res"); // const runtime = path.join(__dirname, '..', '..', 'runtime') -const prefix = `${bsc} -w +A -uncurried`; +const prefix = `${bsc} -w +A`; const updateTests = process.argv[2] === "update"; diff --git a/jscomp/build_tests/uncurried_printer/input.js b/jscomp/build_tests/uncurried_printer/input.js deleted file mode 100755 index e5b78de60a..0000000000 --- a/jscomp/build_tests/uncurried_printer/input.js +++ /dev/null @@ -1,15 +0,0 @@ -const assert = require("assert"); -const child_process = require("child_process"); -const fs = require("fs"); -const path = require("path"); - -const expectedContent = `let a = (. b) => b\n`; -const filePath = path.join(__dirname, "src", "a.res"); - -fs.writeFileSync(filePath, expectedContent, "utf-8"); - -child_process.execSync(`../../../rescript format -all`, { cwd: __dirname }); - -const content = fs.readFileSync(filePath, "utf-8"); - -assert.equal(content, expectedContent); diff --git a/jscomp/build_tests/uncurried_printer/rescript.json b/jscomp/build_tests/uncurried_printer/rescript.json deleted file mode 100644 index ded06e80cd..0000000000 --- a/jscomp/build_tests/uncurried_printer/rescript.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "uncurried_printer", - "version": "0.1.0", - "sources": ["src"], - "uncurried": false -} diff --git a/jscomp/build_tests/uncurried_printer/src/a.res b/jscomp/build_tests/uncurried_printer/src/a.res deleted file mode 100644 index 568bcab521..0000000000 --- a/jscomp/build_tests/uncurried_printer/src/a.res +++ /dev/null @@ -1 +0,0 @@ -let a = (. b) => b diff --git a/jscomp/core/res_compmisc.ml b/jscomp/core/res_compmisc.ml index 6213e2e022..f5889a520e 100644 --- a/jscomp/core/res_compmisc.ml +++ b/jscomp/core/res_compmisc.ml @@ -53,7 +53,7 @@ let initial_env ?(modulename) () = let initial = Env.initial_safe_string in let env = if !Clflags.nopervasives then initial - else open_implicit_module (if !Config.uncurried = Uncurried then "PervasivesU" else "Pervasives") initial + else open_implicit_module "Pervasives" initial in List.fold_left (fun env m -> open_implicit_module m env) diff --git a/jscomp/ext/config.ml b/jscomp/ext/config.ml index d5cbdc10c1..5cf917e78c 100644 --- a/jscomp/ext/config.ml +++ b/jscomp/ext/config.ml @@ -12,9 +12,8 @@ let bs_only = ref true let unsafe_empty_array = ref false type uncurried = Legacy | Uncurried -let uncurried = ref Legacy -and cmi_magic_number = "Caml1999I022" +let cmi_magic_number = "Caml1999I022" and ast_impl_magic_number = "Caml1999M022" diff --git a/jscomp/ext/config.mli b/jscomp/ext/config.mli index bd5511dabf..e74846c06f 100644 --- a/jscomp/ext/config.mli +++ b/jscomp/ext/config.mli @@ -43,4 +43,3 @@ val cmt_magic_number : string val print_config : out_channel -> unit type uncurried = Legacy | Uncurried -val uncurried : uncurried ref \ No newline at end of file diff --git a/jscomp/frontend/ast_attributes.ml b/jscomp/frontend/ast_attributes.ml index 95302ccfc3..37ed475b3d 100644 --- a/jscomp/frontend/ast_attributes.ml +++ b/jscomp/frontend/ast_attributes.ml @@ -188,16 +188,13 @@ let iter_process_bs_string_int_unwrap_uncurry (attrs : t) = st := v) else Bs_syntaxerr.err loc Conflict_attributes in - Ext_list.iter attrs (fun (({txt; loc = _}, (payload : _)) as attr) -> + Ext_list.iter attrs (fun (({txt; loc = _}, _) as attr) -> match txt with | "string" -> assign `String attr | "int" -> assign `Int attr | "ignore" -> assign `Ignore attr | "unwrap" -> assign `Unwrap attr - | "uncurry" -> - if !Config.uncurried = Uncurried then - Used_attributes.mark_used_attribute attr - else assign (`Uncurry (Ast_payload.is_single_int payload)) attr + | "uncurry" -> Used_attributes.mark_used_attribute attr | _ -> ()); !st diff --git a/jscomp/frontend/ast_config.ml b/jscomp/frontend/ast_config.ml index c35fb6b988..e0f569965b 100644 --- a/jscomp/frontend/ast_config.ml +++ b/jscomp/frontend/ast_config.ml @@ -50,8 +50,6 @@ let process_directives str = match Ast_payload.is_single_string payload with | Some (d, _) -> Js_config.directives := !Js_config.directives @ [d] | None -> Bs_syntaxerr.err item.pstr_loc Expect_string_literal) - | Pstr_attribute ({txt = "uncurried"}, _) -> - Config.uncurried := Uncurried | _ -> ()) let rec iter_on_bs_config_str (x : Parsetree.structure) = diff --git a/jscomp/frontend/ast_derive_projector.ml b/jscomp/frontend/ast_derive_projector.ml index f9cb679135..c84e935e92 100644 --- a/jscomp/frontend/ast_derive_projector.ml +++ b/jscomp/frontend/ast_derive_projector.ml @@ -22,10 +22,8 @@ let init () = (fun (tdcls : tdcls) _explict_nonrec -> let handle_uncurried_accessor_tranform ~loc ~arity accessor = (* Accessors with no params (arity of 0) are simply values and not functions *) - match Config.uncurried.contents with - | Uncurried when arity > 0 -> - Ast_uncurried.uncurried_fun ~loc ~arity accessor - | _ -> accessor + if arity > 0 then Ast_uncurried.uncurried_fun ~loc ~arity accessor + else accessor in let handle_tdcl tdcl = let core_type = @@ -121,11 +119,8 @@ let init () = signature_gen = (fun (tdcls : Parsetree.type_declaration list) _explict_nonrec -> let handle_uncurried_type_tranform ~loc ~arity t = - match Config.uncurried.contents with - (* Accessors with no params (arity of 0) are simply values and not functions *) - | Uncurried when arity > 0 -> - Ast_uncurried.uncurried_type ~loc ~arity t - | _ -> t + if arity > 0 then Ast_uncurried.uncurried_type ~loc ~arity t + else t in let handle_tdcl tdcl = let core_type = diff --git a/jscomp/gentype/TranslateTypeExprFromTypes.ml b/jscomp/gentype/TranslateTypeExprFromTypes.ml index a8793542b9..dc067d92eb 100644 --- a/jscomp/gentype/TranslateTypeExprFromTypes.ml +++ b/jscomp/gentype/TranslateTypeExprFromTypes.ml @@ -119,7 +119,7 @@ let translate_constr ~config ~params_translation ~(path : Path.t) ~type_env = {param_translation with type_ = Array (param_translation.type_, Mutable)} | ["ImmutableArray"; "t"], [param_translation] -> {param_translation with type_ = Array (param_translation.type_, Immutable)} - | [("Pervasives" | "PervasivesU"); "ref"], [param_translation] -> + | ["Pervasives"; "ref"], [param_translation] -> { dependencies = param_translation.dependencies; type_ = @@ -217,7 +217,7 @@ let translate_constr ~config ~params_translation ~(path : Path.t) ~type_env = | ( ( ["React"; "element"] | ["ReactV3"; "React"; "element"] | ["ReasonReact"; "reactElement"] - | [("Pervasives" | "PervasivesU"); "Jsx"; "element"] ), + | ["Pervasives"; "Jsx"; "element"] ), [] ) -> {dependencies = []; type_ = EmitType.type_react_element} | (["FB"; "option"] | ["option"]), [param_translation] -> diff --git a/jscomp/jsoo/jsoo_playground_main.ml b/jscomp/jsoo/jsoo_playground_main.ml index bbd4cafe84..ea972a0b29 100644 --- a/jscomp/jsoo/jsoo_playground_main.ml +++ b/jscomp/jsoo/jsoo_playground_main.ml @@ -76,11 +76,6 @@ module BundleConfig = struct mutable filename: string option; mutable warn_flags: string; mutable open_modules: string list; - - (* This one can't be mutated since we only provide - third-party packages that were compiled for uncurried - mode *) - uncurried: bool; } let make () = { @@ -88,7 +83,6 @@ module BundleConfig = struct filename=None; warn_flags=Bsc_warnings.defaults_w; open_modules=[]; - uncurried=(!Config.uncurried = Uncurried); } @@ -201,8 +195,6 @@ end (* One time setup for all relevant modules *) let () = Bs_conditional_initial.setup_env (); - (* From now on the default setting will be uncurried mode *) - Config.uncurried := Uncurried; Clflags.binary_annotations := false; Clflags.color := Some Always; Lazy.force Res_outcome_printer.setup @@ -646,7 +638,6 @@ module Export = struct ); "warn_flags", inject @@ (Js.string config.warn_flags); - "uncurried", inject @@ (Js.bool config.uncurried); "open_modules", inject @@ (config.open_modules |> Array.of_list |> Js.array); |])) ); diff --git a/jscomp/ml/ctype.ml b/jscomp/ml/ctype.ml index 35da537cde..d3b1a325b8 100644 --- a/jscomp/ml/ctype.ml +++ b/jscomp/ml/ctype.ml @@ -2329,7 +2329,7 @@ and unify3 env t1 t1' t2 t2' = link_type t2' t1; | (Tfield _, Tfield _) -> (* special case for GADTs *) unify_fields env t1' t2' - | (Tconstr (Pident {name="function$"}, [t_fun; _], _), Tarrow _) when !Config.uncurried = Uncurried -> + | (Tconstr (Pident {name="function$"}, [t_fun; _], _), Tarrow _) -> (* subtype: an uncurried function is cast to a curried one *) unify2 env t_fun t2 | _ -> diff --git a/jscomp/ml/printtyp.ml b/jscomp/ml/printtyp.ml index 2e7fd26a0e..f0dbba1434 100644 --- a/jscomp/ml/printtyp.ml +++ b/jscomp/ml/printtyp.ml @@ -51,11 +51,10 @@ let ident ppf id = pp_print_string ppf (ident_name id) (* Print a path *) let ident_pervasives = Ident.create_persistent "Pervasives" -let ident_pervasives_u = Ident.create_persistent "PervasivesU" let printing_env = ref Env.empty let non_shadowed_pervasive = function | Pdot(Pident id, s, _pos) as path -> - (Ident.same id ident_pervasives || Ident.same id ident_pervasives_u) && + (Ident.same id ident_pervasives) && (try Path.same path (Env.lookup_type (Lident s) !printing_env) with Not_found -> true) | _ -> false diff --git a/jscomp/ml/typecore.ml b/jscomp/ml/typecore.ml index d30430d1fa..16e57a3905 100644 --- a/jscomp/ml/typecore.ml +++ b/jscomp/ml/typecore.ml @@ -3076,7 +3076,6 @@ and type_argument ?type_clash_context ?recarg env sarg ty_expected' ty_expected texp and is_automatic_curried_application env funct = (* When a curried function is used with uncurried application, treat it as a curried application *) - !Config.uncurried = Uncurried && match (expand_head env funct.exp_type).desc with | Tarrow _ -> true | _ -> false diff --git a/jscomp/others/release.ninja b/jscomp/others/release.ninja index 8056470d24..bc8c3d95b0 100644 --- a/jscomp/others/release.ninja +++ b/jscomp/others/release.ninja @@ -1,5 +1,5 @@ -bsc_primitive_flags = -no-keep-locs -no-alias-deps -bs-no-version-header -bs-no-check-div-by-zero -nostdlib -bs-cross-module-opt -make-runtime -nopervasives -unsafe -w +50 -warn-error A -uncurried +bsc_primitive_flags = -no-keep-locs -no-alias-deps -bs-no-version-header -bs-no-check-div-by-zero -nostdlib -bs-cross-module-opt -make-runtime -nopervasives -unsafe -w +50 -warn-error A bsc_flags = $bsc_primitive_flags -open Belt_internals rule cc diff --git a/jscomp/runtime/release.ninja b/jscomp/runtime/release.ninja index d6318b7ae0..d0bd28fbd2 100644 --- a/jscomp/runtime/release.ninja +++ b/jscomp/runtime/release.ninja @@ -1,5 +1,5 @@ -bsc_no_open_flags = -no-keep-locs -no-alias-deps -bs-no-version-header -bs-no-check-div-by-zero -nostdlib -bs-cross-module-opt -make-runtime -nopervasives -unsafe -w +50 -warn-error A -uncurried +bsc_no_open_flags = -no-keep-locs -no-alias-deps -bs-no-version-header -bs-no-check-div-by-zero -nostdlib -bs-cross-module-opt -make-runtime -nopervasives -unsafe -w +50 -warn-error A bsc_flags = $bsc_no_open_flags -open Bs_stdlib_mini rule cc @@ -10,7 +10,7 @@ rule cc_cmi description = $in -> $out o runtime/bs_stdlib_mini.cmi : cc runtime/bs_stdlib_mini.resi - bsc_flags = -nostdlib -nopervasives -uncurried + bsc_flags = -nostdlib -nopervasives o runtime/js.cmj runtime/js.cmi : cc runtime/js.res bsc_flags = $bsc_no_open_flags o runtime/caml.cmj : cc_cmi runtime/caml.res | runtime/caml.cmi runtime/caml_int64_extern.cmj diff --git a/jscomp/stdlib-406/pervasivesU.res b/jscomp/stdlib-406/pervasivesU.res deleted file mode 100644 index c044504bb7..0000000000 --- a/jscomp/stdlib-406/pervasivesU.res +++ /dev/null @@ -1,321 +0,0 @@ -/* ************************************************************************ */ -/* */ -/* OCaml */ -/* */ -/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ -/* */ -/* Copyright 1996 Institut National de Recherche en Informatique et */ -/* en Automatique. */ -/* */ -/* All rights reserved. This file is distributed under the terms of */ -/* the GNU Lesser General Public License version 2.1, with the */ -/* special exception on linking described in the file LICENSE. */ -/* */ -/* ************************************************************************ */ - -@@uncurried - -module Jsx = JsxU -module JsxEvent = JsxEventU -module JsxDOM = JsxDOMU -module JsxPPXReactSupport = JsxPPXReactSupportU -module JsxModules = { - module Jsx = JsxU - module JsxEvent = JsxEventU - module JsxDOM = JsxDOMU -} - -/* Internal */ -external __unsafe_cast: 'a => 'b = "%identity" - -/* Exceptions */ - -external raise: exn => 'a = "%raise" -external raise_notrace: exn => 'a = "%raise_notrace" - -let failwith = s => raise(Failure(s)) -let invalid_arg = s => raise(Invalid_argument(s)) - -exception Exit - -/* Composition operators */ - -external \"|>": ('a, 'a => 'b) => 'b = "%revapply" -external \"@@": ('a => 'b, 'a) => 'b = "%apply" - -/* Debugging */ - -external __LOC__: string = "%loc_LOC" -external __FILE__: string = "%loc_FILE" -external __LINE__: int = "%loc_LINE" -external __MODULE__: string = "%loc_MODULE" -external __POS__: (string, int, int, int) = "%loc_POS" - -external __LOC_OF__: 'a => (string, 'a) = "%loc_LOC" -external __LINE_OF__: 'a => (int, 'a) = "%loc_LINE" -external __POS_OF__: 'a => ((string, int, int, int), 'a) = "%loc_POS" - -/* Comparisons */ - -external \"=": ('a, 'a) => bool = "%equal" -external \"<>": ('a, 'a) => bool = "%notequal" -external \"<": ('a, 'a) => bool = "%lessthan" -external \">": ('a, 'a) => bool = "%greaterthan" -external \"<=": ('a, 'a) => bool = "%lessequal" -external \">=": ('a, 'a) => bool = "%greaterequal" -external compare: ('a, 'a) => int = "%compare" -external min: ('a, 'a) => 'a = "%bs_min" -external max: ('a, 'a) => 'a = "%bs_max" -external \"==": ('a, 'a) => bool = "%eq" -external \"!=": ('a, 'a) => bool = "%noteq" - -/* Boolean operations */ - -external not: bool => bool = "%boolnot" - -external \"&&": (bool, bool) => bool = "%sequand" - -external \"||": (bool, bool) => bool = "%sequor" - -/* Integer operations */ - -external \"~-": int => int = "%negint" -external \"~+": int => int = "%identity" -external succ: int => int = "%succint" -external pred: int => int = "%predint" -external \"+": (int, int) => int = "%addint" -external \"-": (int, int) => int = "%subint" -external \"*": (int, int) => int = "%mulint" -external \"/": (int, int) => int = "%divint" -external mod: (int, int) => int = "%modint" - -let abs = x => - if x >= 0 { - x - } else { - -x - } - -external land: (int, int) => int = "%andint" -external lor: (int, int) => int = "%orint" -external lxor: (int, int) => int = "%xorint" - -let lnot = x => lxor(x, -1) - -external lsl: (int, int) => int = "%lslint" -external lsr: (int, int) => int = "%lsrint" -external asr: (int, int) => int = "%asrint" - -let max_int = lsr(-1, 1) -let min_int = max_int + 1 - -/* Floating-point operations */ - -external \"~-.": float => float = "%negfloat" -external \"~+.": float => float = "%identity" -external \"+.": (float, float) => float = "%addfloat" -external \"-.": (float, float) => float = "%subfloat" -external \"*.": (float, float) => float = "%mulfloat" -external \"/.": (float, float) => float = "%divfloat" - -@val @scope("Math") external \"**": (float, float) => float = "pow" -@val @scope("Math") external exp: float => float = "exp" -external expm1: float => float = "?expm1_float" - -@val @scope("Math") external acos: float => float = "acos" -@val @scope("Math") external asin: float => float = "asin" -@val @scope("Math") external atan: float => float = "atan" -@val @scope("Math") external atan2: (float, float) => float = "atan2" -external hypot: (float, float) => float = "?hypot_float" - -@val @scope("Math") external cos: float => float = "cos" -@val @scope("Math") external cosh: float => float = "cosh" -@val @scope("Math") external log: float => float = "log" -@val @scope("Math") external log10: float => float = "log10" -@val @scope("Math") external log1p: float => float = "log1p" -@val @scope("Math") external sin: float => float = "sin" -@val @scope("Math") external sinh: float => float = "sinh" -@val @scope("Math") external sqrt: float => float = "sqrt" -@val @scope("Math") external tan: float => float = "tan" -@val @scope("Math") external tanh: float => float = "tanh" -@val @scope("Math") external ceil: float => float = "ceil" -@val @scope("Math") external floor: float => float = "floor" -@val @scope("Math") external abs_float: float => float = "abs" -external copysign: (float, float) => float = "?copysign_float" -external mod_float: (float, float) => float = "?fmod_float" -external frexp: float => (float, int) = "?frexp_float" -external ldexp: (float, int) => float = "?ldexp_float" -external modf: float => (float, float) = "?modf_float" -external float: int => float = "%floatofint" -external float_of_int: int => float = "%floatofint" -external truncate: float => int = "%intoffloat" -external int_of_float: float => int = "%intoffloat" - -let infinity = 0x1p2047 -let neg_infinity = -0x1p2047 -@val @scope("Number") external nan: float = "NaN" -let max_float = 1.79769313486231571e+308 /* 0x1.ffff_ffff_ffff_fp+1023 */ -let min_float = 2.22507385850720138e-308 /* 0x1p-1022 */ -let epsilon_float = 2.22044604925031308e-16 /* 0x1p-52 */ - -type fpclass = - | FP_normal - | FP_subnormal - | FP_zero - | FP_infinite - | FP_nan - -let classify_float = (x: float): fpclass => - if (%raw(`isFinite`): _ => _)(x) { - if abs_float(x) >= /* 0x1p-1022 */ /* 2.22507385850720138e-308 */ min_float { - FP_normal - } else if x != 0. { - FP_subnormal - } else { - FP_zero - } - } else if (%raw(`isNaN`): _ => _)(x) { - FP_nan - } else { - FP_infinite - } - -/* String and byte sequence operations -- more in modules String and Bytes */ - -external string_length: string => int = "%string_length" - -external \"^": (string, string) => string = "#string_append" -/* Character operations -- more in module Char */ - -external int_of_char: char => int = "%identity" -external unsafe_char_of_int: int => char = "%identity" -let char_of_int = n => - if n < 0 || n > 255 { - invalid_arg("char_of_int") - } else { - unsafe_char_of_int(n) - } - -/* Unit operations */ - -external ignore: 'a => unit = "%ignore" - -/* Pair operations */ - -external fst: (('a, 'b)) => 'a = "%field0" -external snd: (('a, 'b)) => 'b = "%field1" - -/* References */ - -type ref<'a> = {mutable contents: 'a} -external ref: 'a => ref<'a> = "%makemutable" -external \"!": ref<'a> => 'a = "%bs_ref_field0" -external \":=": (ref<'a>, 'a) => unit = "%bs_ref_setfield0" -external incr: ref => unit = "%incr" -external decr: ref => unit = "%decr" - -/* String conversion functions */ -external format_float: (string, float) => string = "?format_float" - -let string_of_bool = b => - if b { - "true" - } else { - "false" - } -let bool_of_string = param => - switch param { - | "true" => true - | "false" => false - | _ => invalid_arg("bool_of_string") - } - -let bool_of_string_opt = param => - switch param { - | "true" => Some(true) - | "false" => Some(false) - | _ => None - } - -@val external string_of_int: int => string = "String" - -external int_of_string: string => int = "?int_of_string" - -let int_of_string_opt = s => - /* TODO: provide this directly as a non-raising primitive. */ - try Some(int_of_string(s)) catch { - | Failure(_) => None - } - -external string_get: (string, int) => char = "%string_safe_get" - -let valid_float_lexem = s => { - let l = string_length(s) - let rec loop = i => - if i >= l { - s ++ "." - } else { - switch string_get(s, i) { - | '0' .. '9' | '-' => loop(i + 1) - | _ => s - } - } - - loop(0) -} - -let string_of_float = f => valid_float_lexem(format_float("%.12g", f)) - -external float_of_string: string => float = "?float_of_string" - -let float_of_string_opt = s => - /* TODO: provide this directly as a non-raising primitive. */ - try Some(float_of_string(s)) catch { - | Failure(_) => None - } - -/* List operations -- more in module List */ - -let rec \"@" = (l1, l2) => - switch l1 { - | list{} => l2 - | list{hd, ...tl} => list{hd, ...\"@"(tl, l2)} - } - -/* Output functions on standard output */ - -@val @scope("console") external print_endline: string => unit = "log" -let print_newline = () => print_endline("") - -/* Output functions on standard error */ - -@val @scope("console") external prerr_endline: string => unit = "error" -let prerr_newline = () => prerr_endline("") - -let print_int = (i: int) => print_endline(string_of_int(i)) -let print_float = (i: float) => print_endline(string_of_float(i)) -let print_string = print_endline - -/* Miscellaneous */ - -external sys_exit: int => 'a = "?sys_exit" - -let exit_function = ref(ignore) - -let at_exit = f => { - let g = exit_function.contents - exit_function := - () => { - f() - g() - } -} - -let do_at_exit = () => exit_function.contents() - -let exit = retcode => { - do_at_exit() - sys_exit(retcode) -} - -type int32 = int diff --git a/jscomp/stdlib-406/pervasivesU.resi b/jscomp/stdlib-406/pervasivesU.resi deleted file mode 100644 index 4b0f05928b..0000000000 --- a/jscomp/stdlib-406/pervasivesU.resi +++ /dev/null @@ -1,763 +0,0 @@ -/* ************************************************************************ */ -/* */ -/* OCaml */ -/* */ -/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ -/* */ -/* Copyright 1996 Institut National de Recherche en Informatique et */ -/* en Automatique. */ -/* */ -/* All rights reserved. This file is distributed under the terms of */ -/* the GNU Lesser General Public License version 2.1, with the */ -/* special exception on linking described in the file LICENSE. */ -/* */ -/* ************************************************************************ */ - -/*** The initially opened module. - - This module provides the basic operations over the built-in types - (numbers, booleans, byte sequences, strings, exceptions, references, - lists, arrays, input-output channels, ...). - - This module is automatically opened at the beginning of each compilation. - All components of this module can therefore be referred by their short - name, without prefixing them by [Pervasives]. -*/ - -@@uncurried - -module Jsx = JsxU -module JsxEvent = JsxEventU -module JsxDOM = JsxDOMU -module JsxPPXReactSupport = JsxPPXReactSupportU - -/* For autocomplete */ -module JsxModules: { - module Jsx = JsxU - module JsxEvent = JsxEventU - module JsxDOM = JsxDOMU - // skip JsxPPXReactSupport as it's not user-facing -} - -/* Internal */ -external __unsafe_cast: 'a => 'b = "%identity" - -/*** {1 Exceptions} */ - -/** Raise the given exception value */ -external raise: exn => 'a = "%raise" - -/** A faster version [raise] which does not record the backtrace. - @since 4.02.0 -*/ -external raise_notrace: exn => 'a = "%raise_notrace" - -/** Raise exception [Invalid_argument] with the given string. */ -let invalid_arg: string => 'a - -/** Raise exception [Failure] with the given string. */ -let failwith: string => 'a - -/** The [Exit] exception is not raised by any library function. It is - provided for use in your programs. */ -exception Exit - -/*** {1 Comparisons} */ - -/** [e1 = e2] tests for structural equality of [e1] and [e2]. - Mutable structures (e.g. references and arrays) are equal - if and only if their current contents are structurally equal, - even if the two mutable objects are not the same physical object. - Equality between functional values raises [Invalid_argument]. - Equality between cyclic data structures may not terminate. - Left-associative operator at precedence level 4/11. */ -external \"=": ('a, 'a) => bool = "%equal" - -/** Negation of {!Pervasives.( = )}. - Left-associative operator at precedence level 4/11. */ -external \"<>": ('a, 'a) => bool = "%notequal" - -/** See {!Pervasives.( >= )}. - Left-associative operator at precedence level 4/11. */ -external \"<": ('a, 'a) => bool = "%lessthan" - -/** See {!Pervasives.( >= )}. - Left-associative operator at precedence level 4/11. */ -external \">": ('a, 'a) => bool = "%greaterthan" - -/** See {!Pervasives.( >= )}. - Left-associative operator at precedence level 4/11. */ -external \"<=": ('a, 'a) => bool = "%lessequal" - -/** Structural ordering functions. These functions coincide with - the usual orderings over integers, characters, strings, byte sequences - and floating-point numbers, and extend them to a - total ordering over all types. - The ordering is compatible with [( = )]. As in the case - of [( = )], mutable structures are compared by contents. - Comparison between functional values raises [Invalid_argument]. - Comparison between cyclic structures may not terminate. - Left-associative operator at precedence level 4/11. */ -external \">=": ('a, 'a) => bool = "%greaterequal" - -/** [compare x y] returns [0] if [x] is equal to [y], - a negative integer if [x] is less than [y], and a positive integer - if [x] is greater than [y]. The ordering implemented by [compare] - is compatible with the comparison predicates [=], [<] and [>] - defined above, with one difference on the treatment of the float value - {!Pervasives.nan}. Namely, the comparison predicates treat [nan] - as different from any other float value, including itself; - while [compare] treats [nan] as equal to itself and less than any - other float value. This treatment of [nan] ensures that [compare] - defines a total ordering relation. - - [compare] applied to functional values may raise [Invalid_argument]. - [compare] applied to cyclic structures may not terminate. - - The [compare] function can be used as the comparison function - required by the {!Set.Make} and {!Map.Make} functors, as well as - the {!List.sort} and {!Array.sort} functions. */ -external compare: ('a, 'a) => int = "%compare" - -/** Return the smaller of the two arguments. - The result is unspecified if one of the arguments contains - the float value [nan]. */ -external min: ('a, 'a) => 'a = "%bs_min" - -/** Return the greater of the two arguments. - The result is unspecified if one of the arguments contains - the float value [nan]. */ -external max: ('a, 'a) => 'a = "%bs_max" - -/** [e1 == e2] tests for physical equality of [e1] and [e2]. - On mutable types such as references, arrays, byte sequences, records with - mutable fields and objects with mutable instance variables, - [e1 == e2] is true if and only if physical modification of [e1] - also affects [e2]. - On non-mutable types, the behavior of [( == )] is - implementation-dependent; however, it is guaranteed that - [e1 == e2] implies [compare e1 e2 = 0]. - Left-associative operator at precedence level 4/11. */ -external \"==": ('a, 'a) => bool = "%eq" - -/** Negation of {!Pervasives.( == )}. - Left-associative operator at precedence level 4/11. */ -external \"!=": ('a, 'a) => bool = "%noteq" - -/*** {1 Boolean operations} */ - -/** The boolean negation. */ -external not: bool => bool = "%boolnot" - -/** The boolean 'and'. Evaluation is sequential, left-to-right: - in [e1 && e2], [e1] is evaluated first, and if it returns [false], - [e2] is not evaluated at all. - Right-associative operator at precedence level 3/11. */ -external \"&&": (bool, bool) => bool = "%sequand" - -/** The boolean 'or'. Evaluation is sequential, left-to-right: - in [e1 || e2], [e1] is evaluated first, and if it returns [true], - [e2] is not evaluated at all. - Right-associative operator at precedence level 2/11. -*/ -external \"||": (bool, bool) => bool = "%sequor" - -/*** {1 Debugging} */ - -/** [__LOC__] returns the location at which this expression appears in - the file currently being parsed by the compiler, with the standard - error format of OCaml: "File %S, line %d, characters %d-%d". - @since 4.02.0 -*/ -external __LOC__: string = "%loc_LOC" - -/** [__FILE__] returns the name of the file currently being - parsed by the compiler. - @since 4.02.0 -*/ -external __FILE__: string = "%loc_FILE" - -/** [__LINE__] returns the line number at which this expression - appears in the file currently being parsed by the compiler. - @since 4.02.0 -*/ -external __LINE__: int = "%loc_LINE" - -/** [__MODULE__] returns the module name of the file being - parsed by the compiler. - @since 4.02.0 -*/ -external __MODULE__: string = "%loc_MODULE" - -/** [__POS__] returns a tuple [(file,lnum,cnum,enum)], corresponding - to the location at which this expression appears in the file - currently being parsed by the compiler. [file] is the current - filename, [lnum] the line number, [cnum] the character position in - the line and [enum] the last character position in the line. - @since 4.02.0 - */ -external __POS__: (string, int, int, int) = "%loc_POS" - -/** [__LOC_OF__ expr] returns a pair [(loc, expr)] where [loc] is the - location of [expr] in the file currently being parsed by the - compiler, with the standard error format of OCaml: "File %S, line - %d, characters %d-%d". - @since 4.02.0 -*/ -external __LOC_OF__: 'a => (string, 'a) = "%loc_LOC" - -/** [__LINE__ expr] returns a pair [(line, expr)], where [line] is the - line number at which the expression [expr] appears in the file - currently being parsed by the compiler. - @since 4.02.0 - */ -external __LINE_OF__: 'a => (int, 'a) = "%loc_LINE" - -/** [__POS_OF__ expr] returns a pair [(loc,expr)], where [loc] is a - tuple [(file,lnum,cnum,enum)] corresponding to the location at - which the expression [expr] appears in the file currently being - parsed by the compiler. [file] is the current filename, [lnum] the - line number, [cnum] the character position in the line and [enum] - the last character position in the line. - @since 4.02.0 - */ -external __POS_OF__: 'a => ((string, int, int, int), 'a) = "%loc_POS" - -/*** {1 Composition operators} */ - -/** Reverse-application operator: [x |> f |> g] is exactly equivalent - to [g (f (x))]. - Left-associative operator at precedence level 4/11. - @since 4.01 - */ -external \"|>": ('a, 'a => 'b) => 'b = "%revapply" - -/** Application operator: [g @@ f @@ x] is exactly equivalent to - [g (f (x))]. - Right-associative operator at precedence level 5/11. - @since 4.01 -*/ -external \"@@": ('a => 'b, 'a) => 'b = "%apply" - -/*** {1 Integer arithmetic} */ - -/*** Integers are 31 bits wide (or 63 bits on 64-bit processors). - All operations are taken modulo 2{^31} (or 2{^63}). - They do not fail on overflow. */ - -/** Unary negation. You can also write [- e] instead of [~- e]. - Unary operator at precedence level 9/11 for [- e] - and 11/11 for [~- e]. */ -external \"~-": int => int = "%negint" - -/** Unary addition. You can also write [+ e] instead of [~+ e]. - Unary operator at precedence level 9/11 for [+ e] - and 11/11 for [~+ e]. - @since 3.12.0 -*/ -external \"~+": int => int = "%identity" - -/** [succ x] is [x + 1]. */ -external succ: int => int = "%succint" - -/** [pred x] is [x - 1]. */ -external pred: int => int = "%predint" - -/** Integer addition. - Left-associative operator at precedence level 6/11. */ -external \"+": (int, int) => int = "%addint" - -/** Integer subtraction. - Left-associative operator at precedence level 6/11. */ -external \"-": (int, int) => int = "%subint" - -/** Integer multiplication. - Left-associative operator at precedence level 7/11. */ -external \"*": (int, int) => int = "%mulint" - -/** Integer division. - Raise [Division_by_zero] if the second argument is 0. - Integer division rounds the real quotient of its arguments towards zero. - More precisely, if [x >= 0] and [y > 0], [x / y] is the greatest integer - less than or equal to the real quotient of [x] by [y]. Moreover, - [(- x) / y = x / (- y) = - (x / y)]. - Left-associative operator at precedence level 7/11. */ -external \"/": (int, int) => int = "%divint" - -/** Integer remainder. If [y] is not zero, the result - of [x mod y] satisfies the following properties: - [x = (x / y) * y + x mod y] and - [abs(x mod y) <= abs(y) - 1]. - If [y = 0], [x mod y] raises [Division_by_zero]. - Note that [x mod y] is negative only if [x < 0]. - Raise [Division_by_zero] if [y] is zero. - Left-associative operator at precedence level 7/11. */ -external mod: (int, int) => int = "%modint" - -/** Return the absolute value of the argument. Note that this may be - negative if the argument is [min_int]. */ -let abs: int => int - -/** The greatest representable integer. */ -let max_int: int - -/** The smallest representable integer. */ -let min_int: int - -/*** {2 Bitwise operations} */ - -/** Bitwise logical and. - Left-associative operator at precedence level 7/11. */ -external land: (int, int) => int = "%andint" - -/** Bitwise logical or. - Left-associative operator at precedence level 7/11. */ -external lor: (int, int) => int = "%orint" - -/** Bitwise logical exclusive or. - Left-associative operator at precedence level 7/11. */ -external lxor: (int, int) => int = "%xorint" - -/** Bitwise logical negation. */ -let lnot: int => int - -/** [n lsl m] shifts [n] to the left by [m] bits. - The result is unspecified if [m < 0] or [m >= bitsize], - where [bitsize] is [32] on a 32-bit platform and - [64] on a 64-bit platform. - Right-associative operator at precedence level 8/11. */ -external lsl: (int, int) => int = "%lslint" - -/** [n lsr m] shifts [n] to the right by [m] bits. - This is a logical shift: zeroes are inserted regardless of - the sign of [n]. - The result is unspecified if [m < 0] or [m >= bitsize]. - Right-associative operator at precedence level 8/11. */ -external lsr: (int, int) => int = "%lsrint" - -/** [n asr m] shifts [n] to the right by [m] bits. - This is an arithmetic shift: the sign bit of [n] is replicated. - The result is unspecified if [m < 0] or [m >= bitsize]. - Right-associative operator at precedence level 8/11. */ -external asr: (int, int) => int = "%asrint" - -/*** {1 Floating-point arithmetic} - - OCaml's floating-point numbers follow the - IEEE 754 standard, using double precision (64 bits) numbers. - Floating-point operations never raise an exception on overflow, - underflow, division by zero, etc. Instead, special IEEE numbers - are returned as appropriate, such as [infinity] for [1.0 /. 0.0], - [neg_infinity] for [-1.0 /. 0.0], and [nan] ('not a number') - for [0.0 /. 0.0]. These special numbers then propagate through - floating-point computations as expected: for instance, - [1.0 /. infinity] is [0.0], and any arithmetic operation with [nan] - as argument returns [nan] as result. -*/ - -/** Unary negation. You can also write [-. e] instead of [~-. e]. - Unary operator at precedence level 9/11 for [-. e] - and 11/11 for [~-. e]. */ -external \"~-.": float => float = "%negfloat" - -/** Unary addition. You can also write [+. e] instead of [~+. e]. - Unary operator at precedence level 9/11 for [+. e] - and 11/11 for [~+. e]. - @since 3.12.0 -*/ -external \"~+.": float => float = "%identity" - -/** Floating-point addition. - Left-associative operator at precedence level 6/11. */ -external \"+.": (float, float) => float = "%addfloat" - -/** Floating-point subtraction. - Left-associative operator at precedence level 6/11. */ -external \"-.": (float, float) => float = "%subfloat" - -/** Floating-point multiplication. - Left-associative operator at precedence level 7/11. */ -external \"*.": (float, float) => float = "%mulfloat" - -/** Floating-point division. - Left-associative operator at precedence level 7/11. */ -external \"/.": (float, float) => float = "%divfloat" - -@val @scope("Math") /** Exponentiation. */ -external \"**": (float, float) => float = "pow" - -@val @scope("Math") /** Square root. */ -external sqrt: float => float = "sqrt" - -@val @scope("Math") /** Exponential. */ -external exp: float => float = "exp" - -@val @scope("Math") /** Natural logarithm. */ -external log: float => float = "log" - -@val @scope("Math") /** Base 10 logarithm. */ -external log10: float => float = "log10" - -/** [expm1 x] computes [exp x -. 1.0], giving numerically-accurate results - even if [x] is close to [0.0]. - @since 3.12.0 -*/ -external expm1: float => float = "?expm1_float" - -@val -@scope("Math") -/** [log1p x] computes [log(1.0 +. x)] (natural logarithm), - giving numerically-accurate results even if [x] is close to [0.0]. - @since 3.12.0 -*/ -external log1p: float => float = "log1p" - -@val @scope("Math") /** Cosine. Argument is in radians. */ -external cos: float => float = "cos" - -@val @scope("Math") /** Sine. Argument is in radians. */ -external sin: float => float = "sin" - -@val @scope("Math") /** Tangent. Argument is in radians. */ -external tan: float => float = "tan" - -@val -@scope("Math") -/** Arc cosine. The argument must fall within the range [[-1.0, 1.0]]. - Result is in radians and is between [0.0] and [pi]. */ -external acos: float => float = "acos" - -@val -@scope("Math") -/** Arc sine. The argument must fall within the range [[-1.0, 1.0]]. - Result is in radians and is between [-pi/2] and [pi/2]. */ -external asin: float => float = "asin" - -@val @scope("Math") /** Arc tangent. - Result is in radians and is between [-pi/2] and [pi/2]. */ -external atan: float => float = "atan" - -@val -@scope("Math") -/** [atan2 y x] returns the arc tangent of [y /. x]. The signs of [x] - and [y] are used to determine the quadrant of the result. - Result is in radians and is between [-pi] and [pi]. */ -external atan2: (float, float) => float = "atan2" - -/** [hypot x y] returns [sqrt(x *. x + y *. y)], that is, the length - of the hypotenuse of a right-angled triangle with sides of length - [x] and [y], or, equivalently, the distance of the point [(x,y)] - to origin. - @since 4.00.0 */ -external hypot: (float, float) => float = "?hypot_float" - -@val @scope("Math") /** Hyperbolic cosine. Argument is in radians. */ -external cosh: float => float = "cosh" - -@val @scope("Math") /** Hyperbolic sine. Argument is in radians. */ -external sinh: float => float = "sinh" - -@val @scope("Math") /** Hyperbolic tangent. Argument is in radians. */ -external tanh: float => float = "tanh" - -@val -@scope("Math") -/** Round above to an integer value. - [ceil f] returns the least integer value greater than or equal to [f]. - The result is returned as a float. */ -external ceil: float => float = "ceil" - -@val -@scope("Math") -/** Round below to an integer value. - [floor f] returns the greatest integer value less than or - equal to [f]. - The result is returned as a float. */ -external floor: float => float = "floor" - -@val @scope("Math") /** [abs_float f] returns the absolute value of [f]. */ -external abs_float: float => float = "abs" - -/** [copysign x y] returns a float whose absolute value is that of [x] - and whose sign is that of [y]. If [x] is [nan], returns [nan]. - If [y] is [nan], returns either [x] or [-. x], but it is not - specified which. - @since 4.00.0 */ -external copysign: (float, float) => float = "?copysign_float" - -/** [mod_float a b] returns the remainder of [a] with respect to - [b]. The returned value is [a -. n *. b], where [n] - is the quotient [a /. b] rounded towards zero to an integer. */ -external mod_float: (float, float) => float = "?fmod_float" - -/** [frexp f] returns the pair of the significant - and the exponent of [f]. When [f] is zero, the - significant [x] and the exponent [n] of [f] are equal to - zero. When [f] is non-zero, they are defined by - [f = x *. 2 ** n] and [0.5 <= x < 1.0]. */ -external frexp: float => (float, int) = "?frexp_float" - -/** [ldexp x n] returns [x *. 2 ** n]. */ -external ldexp: (float, int) => float = "?ldexp_float" - -/** [modf f] returns the pair of the fractional and integral - part of [f]. */ -external modf: float => (float, float) = "?modf_float" - -/** Same as {!Pervasives.float_of_int}. */ -external float: int => float = "%floatofint" - -/** Convert an integer to floating-point. */ -external float_of_int: int => float = "%floatofint" - -/** Same as {!Pervasives.int_of_float}. */ -external truncate: float => int = "%intoffloat" - -/** Truncate the given floating-point number to an integer. - The result is unspecified if the argument is [nan] or falls outside the - range of representable integers. */ -external int_of_float: float => int = "%intoffloat" - -/** Positive infinity. */ -let infinity: float - -/** Negative infinity. */ -let neg_infinity: float - -@val -@scope("Number") -/** A special floating-point value denoting the result of an - undefined operation such as [0.0 /. 0.0]. Stands for - 'not a number'. Any floating-point operation with [nan] as - argument returns [nan] as result. As for floating-point comparisons, - [=], [<], [<=], [>] and [>=] return [false] and [<>] returns [true] - if one or both of their arguments is [nan]. */ -external nan: float = "NaN" -/* we could also use [0. /. 0.] */ - -/** The largest positive finite value of type [float]. */ -let max_float: float - -/** The smallest positive, non-zero, non-denormalized value of type [float]. */ -let min_float: float - -/** The difference between [1.0] and the smallest exactly representable - floating-point number greater than [1.0]. */ -let epsilon_float: float - -/** The five classes of floating-point numbers, as determined by - the {!Pervasives.classify_float} function. */ -type fpclass = - | /** Normal number, none of the below */ FP_normal - | /** Number very close to 0.0, has reduced precision */ FP_subnormal - | /** Number is 0.0 or -0.0 */ FP_zero - | /** Number is positive or negative infinity */ FP_infinite - | /** Not a number: result of an undefined operation */ FP_nan - -/** Return the class of the given floating-point number: - normal, subnormal, zero, infinite, or not a number. */ -let classify_float: float => fpclass - -/** {1 String operations} - - More string operations are provided in module {!String}. -*/ -/** String concatenation. - Right-associative operator at precedence level 5/11. */ -external \"^": (string, string) => string = "#string_append" - -/*** {1 Character operations} - - More character operations are provided in module {!Char}. -*/ - -/** Return the ASCII code of the argument. */ -external int_of_char: char => int = "%identity" - -/** Return the character with the given ASCII code. - Raise [Invalid_argument "char_of_int"] if the argument is - outside the range 0--255. */ -let char_of_int: int => char - -/*** {1 Unit operations} */ - -/** Discard the value of its argument and return [()]. - For instance, [ignore(f x)] discards the result of - the side-effecting function [f]. It is equivalent to - [f x; ()], except that the latter may generate a - compiler warning; writing [ignore(f x)] instead - avoids the warning. */ -external ignore: 'a => unit = "%ignore" - -/*** {1 String conversion functions} */ - -/** Return the string representation of a boolean. As the returned values - may be shared, the user should not modify them directly. -*/ -let string_of_bool: bool => string - -/** Convert the given string to a boolean. - Raise [Invalid_argument "bool_of_string"] if the string is not - ["true"] or ["false"]. */ -let bool_of_string: string => bool - -/** Convert the given string to a boolean. - Return [None] if the string is not - ["true"] or ["false"]. - @since 4.05 -*/ -let bool_of_string_opt: string => option - -@val /** Return the string representation of an integer, in decimal. */ -external string_of_int: int => string = "String" - -/** Convert the given string to an integer. - The string is read in decimal (by default, or if the string - begins with [0u]), in hexadecimal (if it begins with [0x] or - [0X]), in octal (if it begins with [0o] or [0O]), or in binary - (if it begins with [0b] or [0B]). - - The [0u] prefix reads the input as an unsigned integer in the range - [[0, 2*max_int+1]]. If the input exceeds {!max_int} - it is converted to the signed integer - [min_int + input - max_int - 1]. - - The [_] (underscore) character can appear anywhere in the string - and is ignored. - Raise [Failure "int_of_string"] if the given string is not - a valid representation of an integer, or if the integer represented - exceeds the range of integers representable in type [int]. */ -external int_of_string: string => int = "?int_of_string" - -/** Same as [int_of_string], but returns [None] instead of raising. - @since 4.05 -*/ -let int_of_string_opt: string => option - -@deprecated("Please use Js.Float.toString instead, string_of_float generates unparseable floats") -/** Return the string representation of a floating-point number. */ -let string_of_float: float => string - -/** Convert the given string to a float. The string is read in decimal - (by default) or in hexadecimal (marked by [0x] or [0X]). - The format of decimal floating-point numbers is - [ [-] dd.ddd (e|E) [+|-] dd ], where [d] stands for a decimal digit. - The format of hexadecimal floating-point numbers is - [ [-] 0(x|X) hh.hhh (p|P) [+|-] dd ], where [h] stands for an - hexadecimal digit and [d] for a decimal digit. - In both cases, at least one of the integer and fractional parts must be - given; the exponent part is optional. - The [_] (underscore) character can appear anywhere in the string - and is ignored. - Depending on the execution platforms, other representations of - floating-point numbers can be accepted, but should not be relied upon. - Raise [Failure "float_of_string"] if the given string is not a valid - representation of a float. */ -external float_of_string: string => float = "?float_of_string" - -/** Same as [float_of_string], but returns [None] instead of raising. - @since 4.05 -*/ -let float_of_string_opt: string => option - -/*** {1 Pair operations} */ - -/** Return the first component of a pair. */ -external fst: (('a, 'b)) => 'a = "%field0" - -/** Return the second component of a pair. */ -external snd: (('a, 'b)) => 'b = "%field1" - -/*** {1 List operations} - - More list operations are provided in module {!List}. -*/ - -@deprecated("Use Belt.List.concat instead") -/** List concatenation. Tail-recursive (length of the first argument). - Right-associative operator at precedence level 5/11. */ -let \"@": (list<'a>, list<'a>) => list<'a> - -type int32 = int - -/** Print a string on standard output. */ -let print_string: string => unit - -/** Print an integer, in decimal, on standard output. */ -let print_int: int => unit - -/** Print a floating-point number, in decimal, on standard output. */ -let print_float: float => unit - -/** Print a floating-point number, in decimal, on standard output. */ -@val -@scope("console") -/** Print a string, followed by a newline character, on - standard output and flush standard output. */ -external print_endline: string => unit = "log" - -/** Print a newline character on standard output, and flush - standard output. This can be used to simulate line - buffering of standard output. */ -let print_newline: unit => unit - -@val -@scope("console") -/** Print a string, followed by a newline character on standard - error and flush standard error. */ -external prerr_endline: string => unit = "error" - -/** Print a newline character on standard error, and flush - standard error. */ -let prerr_newline: unit => unit - -/*** {1 References} */ - -/** The type of references (mutable indirection cells) containing - a value of type ['a]. */ -type ref<'a> = {mutable contents: 'a} - -/** Return a fresh reference containing the given value. */ -external ref: 'a => ref<'a> = "%makemutable" - -/** [!r] returns the current contents of reference [r]. - Equivalent to [fun r -> r.contents]. - Unary operator at precedence level 11/11.*/ -external \"!": ref<'a> => 'a = "%bs_ref_field0" - -/** [r := a] stores the value of [a] in reference [r]. - Equivalent to [fun r v -> r.contents <- v]. - Right-associative operator at precedence level 1/11. */ -external \":=": (ref<'a>, 'a) => unit = "%bs_ref_setfield0" - -/** Increment the integer contained in the given reference. - Equivalent to [fun r -> r := succ !r]. */ -external incr: ref => unit = "%incr" - -/** Decrement the integer contained in the given reference. - Equivalent to [fun r -> r := pred !r]. */ -external decr: ref => unit = "%decr" - -/*** {1 Program termination} */ - -/** Terminate the process, returning the given status code - to the operating system: usually 0 to indicate no errors, - and a small positive integer to indicate failure. - All open output channels are flushed with [flush_all]. - An implicit [exit 0] is performed each time a program - terminates normally. An implicit [exit 2] is performed if the program - terminates early because of an uncaught exception. */ -let exit: int => 'a - -/** Register the given function to be called at program termination - time. The functions registered with [at_exit] will be called when - the program does any of the following: - - executes {!Pervasives.exit} - - terminates, either normally or because of an uncaught - exception - - executes the C function [caml_shutdown]. - The functions are called in 'last in, first out' order: the - function most recently added with [at_exit] is called first. */ -let at_exit: (unit => unit) => unit - -let valid_float_lexem: string => string diff --git a/jscomp/stdlib-406/release.ninja b/jscomp/stdlib-406/release.ninja index 751ac9f0a4..fcf7b28038 100644 --- a/jscomp/stdlib-406/release.ninja +++ b/jscomp/stdlib-406/release.ninja @@ -1,5 +1,5 @@ -bsc_flags = -no-keep-locs -no-alias-deps -bs-no-version-header -bs-no-check-div-by-zero -nostdlib -bs-cross-module-opt -make-runtime -w -9-3-106 -warn-error A -I others -uncurried +bsc_flags = -no-keep-locs -no-alias-deps -bs-no-version-header -bs-no-check-div-by-zero -nostdlib -bs-cross-module-opt -make-runtime -w -9-3-106 -warn-error A -I others rule cc command = $bsc -bs-cmi -bs-cmj $bsc_flags -I stdlib-406 $in @@ -9,15 +9,11 @@ rule cc_cmi description = $in -> $out o stdlib-406/pervasives.cmj : cc_cmi stdlib-406/pervasives.res | stdlib-406/pervasives.cmi $bsc others - bsc_flags = $bsc_flags -nopervasives -uncurried + bsc_flags = $bsc_flags -nopervasives o stdlib-406/pervasives.cmi : cc stdlib-406/pervasives.resi | $bsc others - bsc_flags = $bsc_flags -nopervasives -uncurried -o stdlib-406/pervasivesU.cmj : cc_cmi stdlib-406/pervasivesU.res | stdlib-406/pervasivesU.cmi $bsc others - bsc_flags = $bsc_flags -nopervasives -uncurried -o stdlib-406/pervasivesU.cmi : cc stdlib-406/pervasivesU.resi | $bsc others - bsc_flags = $bsc_flags -nopervasives -uncurried -o stdlib-406/arg.cmj : cc_cmi stdlib-406/arg.res | stdlib-406/arg.cmi stdlib-406/array.cmj stdlib-406/buffer.cmj stdlib-406/list.cmj stdlib-406/string.cmj stdlib-406/sys.cmj $bsc others -o stdlib-406/arg.cmi : cc stdlib-406/arg.resi | stdlib-406/pervasives.cmj $bsc others + bsc_flags = $bsc_flags -nopervasives +o stdlib-406/arg.cmj : cc_cmi stdlib-406/arg.res | stdlib-406/arg.cmi stdlib-406/array.cmj stdlib-406/buffer.cmj stdlib-406/list.cmj stdlib-406/set.cmj stdlib-406/string.cmj stdlib-406/sys.cmj $bsc others +o stdlib-406/arg.cmi : cc stdlib-406/arg.resi | stdlib-406/pervasives.cmj stdlib-406/set.cmi stdlib-406/string.cmi $bsc others o stdlib-406/array.cmj : cc_cmi stdlib-406/array.res | stdlib-406/array.cmi $bsc others o stdlib-406/array.cmi : cc stdlib-406/array.resi | stdlib-406/pervasives.cmj $bsc others o stdlib-406/arrayLabels.cmj : cc_cmi stdlib-406/arrayLabels.res | stdlib-406/arrayLabels.cmi $bsc others @@ -43,7 +39,7 @@ o stdlib-406/digest.cmi : cc stdlib-406/digest.resi | stdlib-406/pervasives.cmj o stdlib-406/filename.cmj : cc_cmi stdlib-406/filename.res | stdlib-406/buffer.cmj stdlib-406/filename.cmi stdlib-406/string.cmj stdlib-406/sys.cmj $bsc others o stdlib-406/filename.cmi : cc stdlib-406/filename.resi | stdlib-406/pervasives.cmj $bsc others o stdlib-406/genlex.cmj : cc_cmi stdlib-406/genlex.res | stdlib-406/bytes.cmj stdlib-406/char.cmj stdlib-406/genlex.cmi stdlib-406/hashtbl.cmj stdlib-406/list.cmj stdlib-406/stream.cmj stdlib-406/string.cmj $bsc others -o stdlib-406/genlex.cmi : cc stdlib-406/genlex.resi | stdlib-406/pervasives.cmj stdlib-406/stream.cmi $bsc others +o stdlib-406/genlex.cmi : cc stdlib-406/genlex.resi | stdlib-406/char.cmi stdlib-406/pervasives.cmj stdlib-406/stream.cmi stdlib-406/string.cmi $bsc others o stdlib-406/hashtbl.cmj : cc_cmi stdlib-406/hashtbl.res | stdlib-406/array.cmj stdlib-406/hashtbl.cmi stdlib-406/lazy.cmj stdlib-406/random.cmj $bsc others o stdlib-406/hashtbl.cmi : cc stdlib-406/hashtbl.resi | stdlib-406/pervasives.cmj $bsc others o stdlib-406/hashtblLabels.cmi stdlib-406/hashtblLabels.cmj : cc stdlib-406/hashtblLabels.res | stdlib-406/hashtbl.cmj stdlib-406/pervasives.cmj $bsc others @@ -70,7 +66,7 @@ o stdlib-406/parsing.cmj : cc_cmi stdlib-406/parsing.res | stdlib-406/array.cmj o stdlib-406/parsing.cmi : cc stdlib-406/parsing.resi | stdlib-406/lexing.cmi stdlib-406/obj.cmi stdlib-406/pervasives.cmj $bsc others o stdlib-406/queue.cmj : cc_cmi stdlib-406/queue.res | stdlib-406/queue.cmi $bsc others o stdlib-406/queue.cmi : cc stdlib-406/queue.resi | stdlib-406/pervasives.cmj $bsc others -o stdlib-406/random.cmj : cc_cmi stdlib-406/random.res | stdlib-406/array.cmj stdlib-406/char.cmj stdlib-406/digest.cmj stdlib-406/int32.cmj stdlib-406/int64.cmj stdlib-406/random.cmi stdlib-406/string.cmj $bsc others +o stdlib-406/random.cmj : cc_cmi stdlib-406/random.res | stdlib-406/array.cmj stdlib-406/char.cmj stdlib-406/digest.cmj stdlib-406/int32.cmj stdlib-406/int64.cmj stdlib-406/random.cmi $bsc others o stdlib-406/random.cmi : cc stdlib-406/random.resi | stdlib-406/int32.cmi stdlib-406/int64.cmi stdlib-406/pervasives.cmj $bsc others o stdlib-406/set.cmj : cc_cmi stdlib-406/set.res | stdlib-406/list.cmj stdlib-406/set.cmi $bsc others o stdlib-406/set.cmi : cc stdlib-406/set.resi | stdlib-406/pervasives.cmj $bsc others @@ -91,4 +87,4 @@ o stdlib-406/sys.cmj : cc_cmi stdlib-406/sys.res | stdlib-406/sys.cmi $bsc other o stdlib-406/sys.cmi : cc stdlib-406/sys.resi | stdlib-406/pervasives.cmj $bsc others o stdlib-406/uchar.cmj : cc_cmi stdlib-406/uchar.res | stdlib-406/char.cmj stdlib-406/uchar.cmi $bsc others o stdlib-406/uchar.cmi : cc stdlib-406/uchar.resi | stdlib-406/pervasives.cmj $bsc others -o $stdlib : phony stdlib-406/pervasivesU.cmi stdlib-406/pervasivesU.cmj stdlib-406/arg.cmi stdlib-406/arg.cmj stdlib-406/array.cmi stdlib-406/array.cmj stdlib-406/arrayLabels.cmi stdlib-406/arrayLabels.cmj stdlib-406/buffer.cmi stdlib-406/buffer.cmj stdlib-406/bytes.cmi stdlib-406/bytes.cmj stdlib-406/bytesLabels.cmi stdlib-406/bytesLabels.cmj stdlib-406/callback.cmi stdlib-406/callback.cmj stdlib-406/camlinternalLazy.cmi stdlib-406/camlinternalLazy.cmj stdlib-406/camlinternalMod.cmi stdlib-406/camlinternalMod.cmj stdlib-406/char.cmi stdlib-406/char.cmj stdlib-406/complex.cmi stdlib-406/complex.cmj stdlib-406/digest.cmi stdlib-406/digest.cmj stdlib-406/filename.cmi stdlib-406/filename.cmj stdlib-406/genlex.cmi stdlib-406/genlex.cmj stdlib-406/hashtbl.cmi stdlib-406/hashtbl.cmj stdlib-406/hashtblLabels.cmi stdlib-406/hashtblLabels.cmj stdlib-406/int32.cmi stdlib-406/int32.cmj stdlib-406/int64.cmi stdlib-406/int64.cmj stdlib-406/lazy.cmi stdlib-406/lazy.cmj stdlib-406/lexing.cmi stdlib-406/lexing.cmj stdlib-406/list.cmi stdlib-406/list.cmj stdlib-406/listLabels.cmi stdlib-406/listLabels.cmj stdlib-406/map.cmi stdlib-406/map.cmj stdlib-406/mapLabels.cmi stdlib-406/mapLabels.cmj stdlib-406/moreLabels.cmi stdlib-406/moreLabels.cmj stdlib-406/obj.cmi stdlib-406/obj.cmj stdlib-406/parsing.cmi stdlib-406/parsing.cmj stdlib-406/queue.cmi stdlib-406/queue.cmj stdlib-406/random.cmi stdlib-406/random.cmj stdlib-406/set.cmi stdlib-406/set.cmj stdlib-406/setLabels.cmi stdlib-406/setLabels.cmj stdlib-406/sort.cmi stdlib-406/sort.cmj stdlib-406/stack.cmi stdlib-406/stack.cmj stdlib-406/stdLabels.cmi stdlib-406/stdLabels.cmj stdlib-406/stream.cmi stdlib-406/stream.cmj stdlib-406/string.cmi stdlib-406/string.cmj stdlib-406/stringLabels.cmi stdlib-406/stringLabels.cmj stdlib-406/sys.cmi stdlib-406/sys.cmj stdlib-406/uchar.cmi stdlib-406/uchar.cmj +o $stdlib : phony stdlib-406/arg.cmi stdlib-406/arg.cmj stdlib-406/array.cmi stdlib-406/array.cmj stdlib-406/arrayLabels.cmi stdlib-406/arrayLabels.cmj stdlib-406/buffer.cmi stdlib-406/buffer.cmj stdlib-406/bytes.cmi stdlib-406/bytes.cmj stdlib-406/bytesLabels.cmi stdlib-406/bytesLabels.cmj stdlib-406/callback.cmi stdlib-406/callback.cmj stdlib-406/camlinternalLazy.cmi stdlib-406/camlinternalLazy.cmj stdlib-406/camlinternalMod.cmi stdlib-406/camlinternalMod.cmj stdlib-406/char.cmi stdlib-406/char.cmj stdlib-406/complex.cmi stdlib-406/complex.cmj stdlib-406/digest.cmi stdlib-406/digest.cmj stdlib-406/filename.cmi stdlib-406/filename.cmj stdlib-406/genlex.cmi stdlib-406/genlex.cmj stdlib-406/hashtbl.cmi stdlib-406/hashtbl.cmj stdlib-406/hashtblLabels.cmi stdlib-406/hashtblLabels.cmj stdlib-406/int32.cmi stdlib-406/int32.cmj stdlib-406/int64.cmi stdlib-406/int64.cmj stdlib-406/lazy.cmi stdlib-406/lazy.cmj stdlib-406/lexing.cmi stdlib-406/lexing.cmj stdlib-406/list.cmi stdlib-406/list.cmj stdlib-406/listLabels.cmi stdlib-406/listLabels.cmj stdlib-406/map.cmi stdlib-406/map.cmj stdlib-406/mapLabels.cmi stdlib-406/mapLabels.cmj stdlib-406/moreLabels.cmi stdlib-406/moreLabels.cmj stdlib-406/obj.cmi stdlib-406/obj.cmj stdlib-406/parsing.cmi stdlib-406/parsing.cmj stdlib-406/queue.cmi stdlib-406/queue.cmj stdlib-406/random.cmi stdlib-406/random.cmj stdlib-406/set.cmi stdlib-406/set.cmj stdlib-406/setLabels.cmi stdlib-406/setLabels.cmj stdlib-406/sort.cmi stdlib-406/sort.cmj stdlib-406/stack.cmi stdlib-406/stack.cmj stdlib-406/stdLabels.cmi stdlib-406/stdLabels.cmj stdlib-406/stream.cmi stdlib-406/stream.cmj stdlib-406/string.cmi stdlib-406/string.cmj stdlib-406/stringLabels.cmi stdlib-406/stringLabels.cmj stdlib-406/sys.cmi stdlib-406/sys.cmj stdlib-406/uchar.cmi stdlib-406/uchar.cmj diff --git a/jscomp/syntax/src/jsx_v4.ml b/jscomp/syntax/src/jsx_v4.ml index 29e6e8bfce..af2a37e2a5 100644 --- a/jscomp/syntax/src/jsx_v4.ml +++ b/jscomp/syntax/src/jsx_v4.ml @@ -998,11 +998,9 @@ let map_binding ~config ~empty_loc ~pstr_loc ~file_name ~rec_flag binding = else inner_expression) in let full_expression = - if !Config.uncurried = Uncurried then - full_expression - |> Ast_uncurried.uncurried_fun ~loc:full_expression.pexp_loc - ~arity:(if has_forward_ref then 2 else 1) - else full_expression + full_expression + |> Ast_uncurried.uncurried_fun ~loc:full_expression.pexp_loc + ~arity:(if has_forward_ref then 2 else 1) in let full_expression = match full_module_name with diff --git a/jscomp/syntax/src/reactjs_jsx_v3.ml b/jscomp/syntax/src/reactjs_jsx_v3.ml index 46de98bf4a..64658b6feb 100644 --- a/jscomp/syntax/src/reactjs_jsx_v3.ml +++ b/jscomp/syntax/src/reactjs_jsx_v3.ml @@ -979,11 +979,9 @@ let jsx_mapper ~config = inner_expression_with_ref in let full_expression = - if !Config.uncurried = Uncurried then - full_expression - |> Ast_uncurried.uncurried_fun ~loc:full_expression.pexp_loc - ~arity:1 - else full_expression + full_expression + |> Ast_uncurried.uncurried_fun ~loc:full_expression.pexp_loc + ~arity:1 in let full_expression = match full_module_name with diff --git a/jscomp/syntax/src/res_multi_printer.ml b/jscomp/syntax/src/res_multi_printer.ml index 3a9c108d5a..ff877538c2 100644 --- a/jscomp/syntax/src/res_multi_printer.ml +++ b/jscomp/syntax/src/res_multi_printer.ml @@ -1,72 +1,7 @@ let default_print_width = 100 -(* Look at rescript.json (or bsconfig.json) to set Uncurried or Legacy mode if it contains "uncurried": false *) -let get_uncurried_from_config ~filename = - let rec find_config ~dir = - let config = Filename.concat dir "rescript.json" in - if Sys.file_exists config then Some (Res_io.read_file ~filename:config) - else - let config = Filename.concat dir "bsconfig.json" in - if Sys.file_exists config then Some (Res_io.read_file ~filename:config) - else - let parent = Filename.dirname dir in - if parent = dir then None else find_config ~dir:parent - in - let rec find_from_node_modules ~dir = - let parent = Filename.dirname dir in - if Filename.basename dir = "node_modules" then - let config = Filename.concat parent "rescript.json" in - if Sys.file_exists config then Some (Res_io.read_file ~filename:config) - else - let config = Filename.concat parent "bsconfig.json" in - if Sys.file_exists config then Some (Res_io.read_file ~filename:config) - else None - else if parent = dir then None - else find_from_node_modules ~dir:parent - in - let dir = - if Filename.is_relative filename then - Filename.dirname (Filename.concat (Sys.getcwd ()) filename) - else Filename.dirname filename - in - let config () = - match find_config ~dir with - | None -> - (* The editor calls format on a temporary file. So bsconfig can't be found. - This looks outside the node_modules containing the bsc binary *) - let dir = (Filename.dirname Sys.argv.(0) [@doesNotRaise]) in - find_from_node_modules ~dir - | x -> x - in - match config () with - | exception _ -> () - | None -> () - | Some config -> - let lines = config |> String.split_on_char '\n' in - let is_legacy_uncurried = - lines - |> List.exists (fun line -> - let is_uncurried_option = ref false in - let is_option_falsy = ref false in - let words = line |> String.split_on_char ' ' in - words - |> List.iter (fun word -> - match word with - | "\"uncurried\"" | "\"uncurried\":" -> - is_uncurried_option := true - | "\"uncurried\":false" | "\"uncurried\":false," -> - is_uncurried_option := true; - is_option_falsy := true - | "false" | ":false" | "false," | ":false," -> - is_option_falsy := true - | _ -> ()); - !is_uncurried_option && !is_option_falsy) - in - if not is_legacy_uncurried then Config.uncurried := Uncurried - (* print res files to res syntax *) let print_res ~ignore_parse_errors ~is_interface ~filename = - get_uncurried_from_config ~filename; if is_interface then ( let parse_result = Res_driver.parsing_engine.parse_interface ~for_printer:true ~filename diff --git a/jscomp/syntax/src/res_outcome_printer.ml b/jscomp/syntax/src/res_outcome_printer.ml index f087359ff8..1f2f7b5f7a 100644 --- a/jscomp/syntax/src/res_outcome_printer.ml +++ b/jscomp/syntax/src/res_outcome_printer.ml @@ -267,7 +267,7 @@ let rec print_out_type_doc (out_type : Outcometree.out_type) = ] and print_out_arrow_type ~uncurried typ = - let uncurried = Res_uncurried.get_dotted ~uncurried !Config.uncurried in + let uncurried = Res_uncurried.get_dotted ~uncurried Uncurried in let typ_args, typ = collect_arrow_args typ [] in let args = Doc.join diff --git a/jscomp/syntax/src/res_parser.ml b/jscomp/syntax/src/res_parser.ml index 03678e9452..9ec5c38463 100644 --- a/jscomp/syntax/src/res_parser.ml +++ b/jscomp/syntax/src/res_parser.ml @@ -131,7 +131,7 @@ let make ?(mode = ParseForTypeChecker) src filename = diagnostics = []; comments = []; regions = [ref Report]; - uncurried_config = !Config.uncurried; + uncurried_config = Uncurried; } in parser_state.scanner.err <- diff --git a/jscomp/syntax/src/res_printer.ml b/jscomp/syntax/src/res_printer.ml index 3e3a4405bf..eda418fe2d 100644 --- a/jscomp/syntax/src/res_printer.ml +++ b/jscomp/syntax/src/res_printer.ml @@ -547,7 +547,7 @@ module State = struct type t = {custom_layout: int; mutable uncurried_config: Config.uncurried} - let init () = {custom_layout = 0; uncurried_config = !Config.uncurried} + let init () = {custom_layout = 0; uncurried_config = Uncurried} let next_custom_layout t = {t with custom_layout = t.custom_layout + 1} diff --git a/jscomp/syntax/tests/conversion/reason/expected/attributes.res.txt b/jscomp/syntax/tests/conversion/reason/expected/attributes.res.txt index d7f62c9132..3adb465c6e 100644 --- a/jscomp/syntax/tests/conversion/reason/expected/attributes.res.txt +++ b/jscomp/syntax/tests/conversion/reason/expected/attributes.res.txt @@ -17,4 +17,4 @@ list{1, 2, 3}->map(a => a + 1)->filter(a => modulo(a, 2) == 0)->Js.log type t @new external make: unit => t = "DOMParser" -Js.log(make() |> parseHtmlFromString("sdsd")) +Js.log(parseHtmlFromString("sdsd", make())) diff --git a/jscomp/syntax/tests/conversion/reason/expected/fastPipe.res.txt b/jscomp/syntax/tests/conversion/reason/expected/fastPipe.res.txt index a7007b68b5..4855435431 100644 --- a/jscomp/syntax/tests/conversion/reason/expected/fastPipe.res.txt +++ b/jscomp/syntax/tests/conversion/reason/expected/fastPipe.res.txt @@ -7,7 +7,7 @@ Element.querySelectorAll(selector, element) let x = @attr ((@attr2 a)->f(b)->c(d)) -5->doStuff(3, _, 7) +5->(doStuff(3, _, 7)) (event->target)["value"] diff --git a/jscomp/syntax/tests/conversion/reason/expected/uncurrried.res.txt b/jscomp/syntax/tests/conversion/reason/expected/uncurrried.res.txt index 48283a4128..2b5ba37fb2 100644 --- a/jscomp/syntax/tests/conversion/reason/expected/uncurrried.res.txt +++ b/jscomp/syntax/tests/conversion/reason/expected/uncurrried.res.txt @@ -1,5 +1,5 @@ // ok -let updateBriefletNarrative = (. updateObj) => Js.log("patented merge algorithm goes here") +let updateBriefletNarrative = updateObj => Js.log("patented merge algorithm goes here") // this is a bug in Reason, the . will be parsed wrong and disappear. /* updateBriefletNarrative(. briefletNarrativeUpdateObj); */ @@ -13,52 +13,52 @@ module D = { } // ok -let x = foo(. 3) +let x = foo(3) let x = { let a = 3 // ok - foo(. a) + foo(a) } let x = { // ok - let f = (. a, b) => apply(. a + b) + let f = (a, b) => apply(a + b) let a = 3 // ok - foo(. a) + foo(a) // ok - f(. 2, 2) + f(2, 2) } // ok -let () = switch something(. x, y) { +let () = switch something(x, y) { | None => // ok - log(. a, b) + log(a, b) | Some(_) => let a = 1 // ok - log(. a, 2) + log(a, 2) } let () = { // ok - let dontDoThisAhome = (. a, b) => (. c, d) => (. e, f) => a + b + c + d + e + f + let dontDoThisAhome = (a, b, c, d, e, f) => a + b + c + d + e + f // ok - dontDoThisAhome(. a, b)(. c, d)(. e, f) + dontDoThisAhome(a, b)(c, d)(e, f) } -let _ = library.getBalance(. account)->Promise.Js.catch(_ => Promise.resolved(None)) +let _ = library.getBalance(account)->Promise.Js.catch(_ => Promise.resolved(None)) let _ = - library.getBalance(. account) + library.getBalance(account) ->Promise.Js.catch(_ => Promise.resolved(None)) ->Promise.get(newBalance => dispatch( LoadAddress( account, - newBalance->Belt.Option.flatMap(balance => Eth.make(balance.toString(.))), + newBalance->Belt.Option.flatMap(balance => Eth.make(balance.toString())), ), ) ) diff --git a/jscomp/syntax/tests/conversion/reason/expected/underscoreSugar.res.txt b/jscomp/syntax/tests/conversion/reason/expected/underscoreSugar.res.txt index 9330f5c835..9590b1d1fc 100644 --- a/jscomp/syntax/tests/conversion/reason/expected/underscoreSugar.res.txt +++ b/jscomp/syntax/tests/conversion/reason/expected/underscoreSugar.res.txt @@ -1 +1 @@ -let photo = pricedRoom["room"]["photos"] |> filterNone |> Array.get(_, 0) +let photo = (Array.get(_, 0))(filterNone(pricedRoom["room"]["photos"])) diff --git a/jscomp/syntax/tests/parsing/errors/expressions/expected/array.res.txt b/jscomp/syntax/tests/parsing/errors/expressions/expected/array.res.txt index e73c7a9b25..a58823980b 100644 --- a/jscomp/syntax/tests/parsing/errors/expressions/expected/array.res.txt +++ b/jscomp/syntax/tests/parsing/errors/expressions/expected/array.res.txt @@ -8,4 +8,6 @@ Did you forget a `]` here? -let xs = x.map (fun key -> [|key;(predicates.(key))|]) \ No newline at end of file +let xs = + ((x.map ((Function$ (fun key -> [|key;(predicates.(key))|]))[@res.arity 1])) + [@res.uapp ]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/errors/expressions/expected/arrow.res.txt b/jscomp/syntax/tests/parsing/errors/expressions/expected/arrow.res.txt index bbd0f16a8b..ae1ab77b2d 100644 --- a/jscomp/syntax/tests/parsing/errors/expressions/expected/arrow.res.txt +++ b/jscomp/syntax/tests/parsing/errors/expressions/expected/arrow.res.txt @@ -8,6 +8,8 @@ Did you forget a `,` here? -;;(Object.keys providers).reduce - (fun elements -> - fun providerId -> ((let x = 1 in let b = 2 in x + b)[@res.braces ])) \ No newline at end of file +;;((((Object.keys providers)[@res.uapp ]).reduce + ((Function$ + (fun elements -> + fun providerId -> ((let x = 1 in let b = 2 in x + b) + [@res.braces ])))[@res.arity 2]))[@res.uapp ]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/errors/expressions/expected/block.res.txt b/jscomp/syntax/tests/parsing/errors/expressions/expected/block.res.txt index 96fa794985..2c59b4f8f5 100644 --- a/jscomp/syntax/tests/parsing/errors/expressions/expected/block.res.txt +++ b/jscomp/syntax/tests/parsing/errors/expressions/expected/block.res.txt @@ -63,25 +63,35 @@ Looks like there might be an expression missing here -let findThreadByIdLinearScan ~threads:((threads)[@res.namedArgLoc ]) - ~id:((id)[@res.namedArgLoc ]) = - ((Js.Array2.findi ThreadsModel.threads - (fun thread -> - fun i -> - ((let thisId = - match thread with - | ServerData.OneToOne { otherPersonIDWhichIsAlsoThreadID } -> - otherPersonIDWhichIsAlsoThreadID - | Group { id } -> id - | Unknown { id } -> - (unknown.id |. Js.String.make) |. FBID.ofStringUnsafe in - thisId == id) - [@res.braces ]))) - [@res.braces ]) -let x = ((loop 0 (Nil |. (push doc)))[@res.braces ]) +let findThreadByIdLinearScan = + ((Function$ + (fun ~threads:((threads)[@res.namedArgLoc ]) -> + fun ~id:((id)[@res.namedArgLoc ]) -> + ((Js.Array2.findi ThreadsModel.threads + ((Function$ + (fun thread -> + fun i -> + ((let thisId = + match thread with + | ServerData.OneToOne + { otherPersonIDWhichIsAlsoThreadID } -> + otherPersonIDWhichIsAlsoThreadID + | Group { id } -> id + | Unknown { id } -> + (unknown.id |.u Js.String.make) |.u + FBID.ofStringUnsafe in + thisId == id) + [@res.braces ])))[@res.arity 2])) + [@res.braces ][@res.uapp ]))) + [@res.arity 2]) +let x = ((loop 0 (Nil |.u ((push doc)[@res.uapp ]))) + [@res.braces ][@res.uapp ]) ;;match stack with | Empty -> [%rescript.exprhole ] | Cons (doc, rest) -> () - | Join (doc1, doc2) -> (buffer |. (Buffer.add_string indentation); loop ()) + | Join (doc1, doc2) -> + (buffer |.u ((Buffer.add_string indentation)[@res.uapp ]); + ((loop ()) + [@res.uapp ])) let pipeline = match scheduler with | Some -> [%rescript.exprhole ] | None -> () \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/errors/expressions/expected/consecutive.res.txt b/jscomp/syntax/tests/parsing/errors/expressions/expected/consecutive.res.txt index 054e9d9558..7e1dc9883e 100644 --- a/jscomp/syntax/tests/parsing/errors/expressions/expected/consecutive.res.txt +++ b/jscomp/syntax/tests/parsing/errors/expressions/expected/consecutive.res.txt @@ -44,8 +44,11 @@ consecutive expressions on a line must be separated by ';' or a newline -let f a b = a + 3 +let f = ((Function$ (fun a -> fun b -> a + 3))[@res.arity 2]) ;;b -let f g h = ((a + 3; b)[@res.braces ]) -let () = ((sideEffect1 (); sideEffect2 ())[@res.braces ]) -let () = ((let open Foo in let exception End in x ())[@res.braces ]) \ No newline at end of file +let f = ((Function$ (fun g -> fun h -> ((a + 3; b)[@res.braces ]))) + [@res.arity 2]) +let () = ((((sideEffect1 ())[@res.uapp ]); ((sideEffect2 ())[@res.uapp ])) + [@res.braces ]) +let () = ((let open Foo in let exception End in ((x ())[@res.uapp ])) + [@res.braces ]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/errors/expressions/expected/emptyBlock.res.txt b/jscomp/syntax/tests/parsing/errors/expressions/expected/emptyBlock.res.txt index 36cfe2e4c1..545f257b92 100644 --- a/jscomp/syntax/tests/parsing/errors/expressions/expected/emptyBlock.res.txt +++ b/jscomp/syntax/tests/parsing/errors/expressions/expected/emptyBlock.res.txt @@ -1,2 +1,2 @@ let x = { } -let f a b = { } \ No newline at end of file +let f = ((Function$ (fun a -> fun b -> { }))[@res.arity 2]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/errors/expressions/expected/ifLet.res.txt b/jscomp/syntax/tests/parsing/errors/expressions/expected/ifLet.res.txt index c76f8aa9e2..f181c2a63f 100644 --- a/jscomp/syntax/tests/parsing/errors/expressions/expected/ifLet.res.txt +++ b/jscomp/syntax/tests/parsing/errors/expressions/expected/ifLet.res.txt @@ -35,12 +35,13 @@ switch result { | _ => () } -;;((match result with | Some x -> Js.log {js|The sky is blue|js} | _ -> ()) - [@res.iflet ][@warning "-4"]) ;;((match result with - | Error x -> Js.log {js|The sky is red|js} + | Some x -> ((Js.log {js|The sky is blue|js})[@res.uapp ]) + | _ -> ())[@res.iflet ][@warning "-4"]) +;;((match result with + | Error x -> ((Js.log {js|The sky is red|js})[@res.uapp ]) | _ -> (((match result with - | Ok y -> Js.log {js|The sky is blue|js} + | Ok y -> ((Js.log {js|The sky is blue|js})[@res.uapp ]) | _ -> ())) [@res.iflet ][@warning "-4"]))[@res.iflet ][@warning "-4"]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/errors/expressions/expected/implementation.res.txt b/jscomp/syntax/tests/parsing/errors/expressions/expected/implementation.res.txt index ceb0c00366..035f1f08bd 100644 --- a/jscomp/syntax/tests/parsing/errors/expressions/expected/implementation.res.txt +++ b/jscomp/syntax/tests/parsing/errors/expressions/expected/implementation.res.txt @@ -12,7 +12,8 @@ module InstallerDownload = struct - let make () = ((div ~children:[] ())[@res.braces ][@JSX ])[@@react.component - ] + let make = + ((Function$ (fun () -> ((div ~children:[] ())[@res.braces ][@JSX ]))) + [@res.arity 1])[@@react.component ] end module LicenseList = struct end \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/errors/expressions/expected/letBinding.res.txt b/jscomp/syntax/tests/parsing/errors/expressions/expected/letBinding.res.txt index 941de470ad..3299eccd55 100644 --- a/jscomp/syntax/tests/parsing/errors/expressions/expected/letBinding.res.txt +++ b/jscomp/syntax/tests/parsing/errors/expressions/expected/letBinding.res.txt @@ -82,7 +82,7 @@ let foo = 2. let foo = true let foo = 2 -let foo = f () +let foo = ((f ())[@res.uapp ]) let foo = ((2)[@res.braces ]) let foo = (({js|foo|js})[@res.braces ]) let foo as x = () \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/errors/expressions/expected/record.res.txt b/jscomp/syntax/tests/parsing/errors/expressions/expected/record.res.txt index 6939140b09..5ed6f40760 100644 --- a/jscomp/syntax/tests/parsing/errors/expressions/expected/record.res.txt +++ b/jscomp/syntax/tests/parsing/errors/expressions/expected/record.res.txt @@ -48,7 +48,8 @@ Missing expression -let newWrapper = { updateF; value = (f xWrapper.currentValue) } -let newWrapper = { updateF; updateF2; value = (f xWrapper.currentValue) } +let newWrapper = { updateF; value = ((f xWrapper.currentValue)[@res.uapp ]) } +let newWrapper = + { updateF; updateF2; value = ((f xWrapper.currentValue)[@res.uapp ]) } let record = { field = ([%rescript.exprhole ]) } let record = { field = 2 } \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/errors/expressions/expected/setField.res.txt b/jscomp/syntax/tests/parsing/errors/expressions/expected/setField.res.txt index 12f3225d1a..8f961889a4 100644 --- a/jscomp/syntax/tests/parsing/errors/expressions/expected/setField.res.txt +++ b/jscomp/syntax/tests/parsing/errors/expressions/expected/setField.res.txt @@ -13,4 +13,4 @@ ;;if match then let a = 1 in (m.left).compatibleTypeArgs <- ([%rescript.exprhole ]) - else sideEffect () \ No newline at end of file + else ((sideEffect ())[@res.uapp ]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/errors/expressions/expected/try.res.txt b/jscomp/syntax/tests/parsing/errors/expressions/expected/try.res.txt index 1e024f9432..7f72c70373 100644 --- a/jscomp/syntax/tests/parsing/errors/expressions/expected/try.res.txt +++ b/jscomp/syntax/tests/parsing/errors/expressions/expected/try.res.txt @@ -9,4 +9,5 @@ Did you forget a `catch` here? -let parsedPayload = try Js.Json.parseExn response with | _ -> Js.Json.null \ No newline at end of file +let parsedPayload = + try ((Js.Json.parseExn response)[@res.uapp ]) with | _ -> Js.Json.null \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/errors/other/expected/breadcrumbs170.res.txt b/jscomp/syntax/tests/parsing/errors/other/expected/breadcrumbs170.res.txt index 25b2291040..b10a36d330 100644 --- a/jscomp/syntax/tests/parsing/errors/other/expected/breadcrumbs170.res.txt +++ b/jscomp/syntax/tests/parsing/errors/other/expected/breadcrumbs170.res.txt @@ -10,7 +10,7 @@ I'm not sure what to parse here when looking at "}". -let l = (Some [1; 2; 3]) |> Obj.magic +let l = ((Obj.magic (Some [1; 2; 3]))[@res.uapp ]) module M = struct ;;match l with | None -> [] | Some l -> l#prop end ;;from ;;now diff --git a/jscomp/syntax/tests/parsing/errors/other/expected/labelledParameters.res.txt b/jscomp/syntax/tests/parsing/errors/other/expected/labelledParameters.res.txt index 162d9ed152..004817c55f 100644 --- a/jscomp/syntax/tests/parsing/errors/other/expected/labelledParameters.res.txt +++ b/jscomp/syntax/tests/parsing/errors/other/expected/labelledParameters.res.txt @@ -31,7 +31,12 @@ A labeled parameter starts with a `~`. Did you mean: `~x`? -let f x ?(y= 2) z = (x + y) + z -let g ~x:((x)[@res.namedArgLoc ]) ?y:(((y)[@res.namedArgLoc ])= 2) - ~z:((z)[@res.namedArgLoc ]) = (x + y) + z -type nonrec f = x:int -> y:int -> int \ No newline at end of file +let f = ((Function$ (fun x -> fun ?(y= 2) -> fun z -> (x + y) + z)) + [@res.arity 3]) +let g = + ((Function$ + (fun ~x:((x)[@res.namedArgLoc ]) -> + fun ?y:(((y)[@res.namedArgLoc ])= 2) -> + fun ~z:((z)[@res.namedArgLoc ]) -> (x + y) + z)) + [@res.arity 3]) +type nonrec f = (x:int -> y:int -> int, [ `Has_arity2 ]) function$ \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/errors/other/expected/regionMissingComma.res.txt b/jscomp/syntax/tests/parsing/errors/other/expected/regionMissingComma.res.txt index 11ff69899c..87257cc40c 100644 --- a/jscomp/syntax/tests/parsing/errors/other/expected/regionMissingComma.res.txt +++ b/jscomp/syntax/tests/parsing/errors/other/expected/regionMissingComma.res.txt @@ -23,9 +23,9 @@ Did you forget a `,` here? external make : - ?style:((ReactDOMRe.Style.t)[@res.namedArgLoc ]) -> - (?image:((bool)[@res.namedArgLoc ]) -> React.element, [ `Has_arity1 ]) - function$ = "ModalContent" + (?style:((ReactDOMRe.Style.t)[@res.namedArgLoc ]) -> + ?image:((bool)[@res.namedArgLoc ]) -> React.element, + [ `Has_arity2 ]) function$ = "ModalContent" type nonrec 'extraInfo student = { name: string ; diff --git a/jscomp/syntax/tests/parsing/errors/pattern/expected/missing.res.txt b/jscomp/syntax/tests/parsing/errors/pattern/expected/missing.res.txt index a6a10a2c50..d04809deb3 100644 --- a/jscomp/syntax/tests/parsing/errors/pattern/expected/missing.res.txt +++ b/jscomp/syntax/tests/parsing/errors/pattern/expected/missing.res.txt @@ -44,5 +44,9 @@ I was expecting a pattern to match on before the `=>` let 2 = [%rescript.exprhole ] -let 4 = for [%rescript.patternhole ] = 0 to 10 do Js.log {js|for|js} done +let 4 = + for [%rescript.patternhole ] = 0 to 10 do + ((Js.log {js|for|js}) + [@res.uapp ]) + done ;;match x with | () -> [%rescript.exprhole ] \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/errors/structure/expected/external.res.txt b/jscomp/syntax/tests/parsing/errors/structure/expected/external.res.txt index 5d9f438695..537d1d77af 100644 --- a/jscomp/syntax/tests/parsing/errors/structure/expected/external.res.txt +++ b/jscomp/syntax/tests/parsing/errors/structure/expected/external.res.txt @@ -8,4 +8,6 @@ An external requires the name of the JS value you're referring to, like "setTimeout". -external setTimeout : (unit -> unit) -> int -> float \ No newline at end of file +external setTimeout : + ((unit -> unit, [ `Has_arity1 ]) function$ -> int -> float, + [ `Has_arity2 ]) function$ \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/errors/structure/expected/gh16A.res.txt b/jscomp/syntax/tests/parsing/errors/structure/expected/gh16A.res.txt index 4e8d983a56..d64de4d685 100644 --- a/jscomp/syntax/tests/parsing/errors/structure/expected/gh16A.res.txt +++ b/jscomp/syntax/tests/parsing/errors/structure/expected/gh16A.res.txt @@ -10,5 +10,8 @@ I'm not sure what to parse here when looking at ")". -module C = struct module T = (Fun)(struct ;;foo (a + c) (b + d) end) end -;;Js.log {js|test|js} \ No newline at end of file +module C = + struct + module T = (Fun)(struct ;;((foo (a + c) (b + d))[@res.uapp ]) end) + end +;;((Js.log {js|test|js})[@res.uapp ]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/errors/structure/expected/gh16B.res.txt b/jscomp/syntax/tests/parsing/errors/structure/expected/gh16B.res.txt index e35185e0ad..6c3b404fe0 100644 --- a/jscomp/syntax/tests/parsing/errors/structure/expected/gh16B.res.txt +++ b/jscomp/syntax/tests/parsing/errors/structure/expected/gh16B.res.txt @@ -12,29 +12,41 @@ I'm not sure what to parse here when looking at ")". open Ws -let wss = Server.make { port = 82 } -let address = wss |. Server.address -let log msg = - Js.log - (((((({js|> Server: |js})[@res.template ]) ^ msg)[@res.template ]) ^ - (({js||js})[@res.template ]))[@res.template ]) -;;log - (((((((((((((({js|Running on: |js})[@res.template ]) ^ address.address) - [@res.template ]) ^ (({js|:|js})[@res.template ])) - [@res.template ]) ^ (address.port |. string_of_int)) - [@res.template ]) ^ (({js| (|js})[@res.template ])) - [@res.template ]) ^ address.family) - [@res.template ]) ^ (({js|)|js})[@res.template ]))[@res.template ]) +let wss = ((Server.make { port = 82 })[@res.uapp ]) +let address = wss |.u Server.address +let log = + ((Function$ + (fun msg -> + ((Js.log + (((((({js|> Server: |js})[@res.template ]) ^ msg) + [@res.template ]) ^ (({js||js})[@res.template ])) + [@res.template ])) + [@res.uapp ]))) + [@res.arity 1]) +;;((log + (((((((((((((({js|Running on: |js})[@res.template ]) ^ address.address) + [@res.template ]) ^ (({js|:|js})[@res.template ])) + [@res.template ]) ^ (address.port |.u string_of_int)) + [@res.template ]) ^ (({js| (|js})[@res.template ])) + [@res.template ]) ^ address.family) + [@res.template ]) ^ (({js|)|js})[@res.template ]))[@res.template ])) + [@res.uapp ]) module ClientSet = struct module T = (Belt.Id.MakeComparable)(struct type nonrec t = Client.t - let cmp a b = - ((compare (a |. Client.getUniqueId) - (b |. Client.getUniqueId)) - [@res.braces ]) + let cmp = + ((Function$ + (fun a -> + fun b -> + ((compare + (a |.u Client.getUniqueId) + (b |.u Client.getUniqueId)) + [@res.braces ][@res.uapp ]))) + [@res.arity 2]) end) - let empty = Belt.Set.make ~id:(((module T))[@res.namedArgLoc ]) + let empty = ((Belt.Set.make ~id:(((module T))[@res.namedArgLoc ])) + [@res.uapp ]) end -;;Js.log {js|test|js} \ No newline at end of file +;;((Js.log {js|test|js})[@res.uapp ]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/errors/structure/expected/letBinding.res.txt b/jscomp/syntax/tests/parsing/errors/structure/expected/letBinding.res.txt index c71ead73ed..e54db10b9f 100644 --- a/jscomp/syntax/tests/parsing/errors/structure/expected/letBinding.res.txt +++ b/jscomp/syntax/tests/parsing/errors/structure/expected/letBinding.res.txt @@ -98,10 +98,12 @@ Did you forget a `=` here? let rightResource = - (ur.resources).find - (fun r -> r.account_id == ((connection.left).account).id) -let x = ((let field = p |. parseFieldDeclaration in field)[@res.braces ]) -let t = ((let (_, _, token) = scanner |. scan in token)[@res.braces ]) + (((ur.resources).find + ((Function$ (fun r -> r.account_id == ((connection.left).account).id)) + [@res.arity 1])) + [@res.uapp ]) +let x = ((let field = p |.u parseFieldDeclaration in field)[@res.braces ]) +let t = ((let (_, _, token) = scanner |.u scan in token)[@res.braces ]) let (keyTable : int Belt.Map.String.t) = [%rescript.exprhole ] let foo = [%rescript.exprhole ] let (x : int) = string = y diff --git a/jscomp/syntax/tests/parsing/errors/typeDef/expected/inlineRecord.res.txt b/jscomp/syntax/tests/parsing/errors/typeDef/expected/inlineRecord.res.txt index 0aeade9a3a..dd01bd803d 100644 --- a/jscomp/syntax/tests/parsing/errors/typeDef/expected/inlineRecord.res.txt +++ b/jscomp/syntax/tests/parsing/errors/typeDef/expected/inlineRecord.res.txt @@ -43,5 +43,12 @@ type nonrec user = { name: string ; address: < street: string ;country: string > } -let make (props : < handleClick: Click.t -> unit ;value: string > ) = - render props \ No newline at end of file +let make = + ((Function$ + (fun + (props : + < + handleClick: (Click.t -> unit, [ `Has_arity1 ]) function$ ; + value: string > ) + -> ((render props)[@res.uapp ]))) + [@res.arity 1]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/errors/typeDef/expected/namedParameters.res.txt b/jscomp/syntax/tests/parsing/errors/typeDef/expected/namedParameters.res.txt index bb5b73195a..47b0813be7 100644 --- a/jscomp/syntax/tests/parsing/errors/typeDef/expected/namedParameters.res.txt +++ b/jscomp/syntax/tests/parsing/errors/typeDef/expected/namedParameters.res.txt @@ -7,4 +7,4 @@ A labeled parameter starts with a `~`. Did you mean: `~stroke`? -type nonrec draw = stroke:pencil -> unit \ No newline at end of file +type nonrec draw = (stroke:pencil -> unit, [ `Has_arity1 ]) function$ \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/errors/typeDef/expected/typeParams.res.txt b/jscomp/syntax/tests/parsing/errors/typeDef/expected/typeParams.res.txt index 511070b55a..ca5e7b16ae 100644 --- a/jscomp/syntax/tests/parsing/errors/typeDef/expected/typeParams.res.txt +++ b/jscomp/syntax/tests/parsing/errors/typeDef/expected/typeParams.res.txt @@ -62,16 +62,16 @@ type nonrec 'a node = { type nonrec ('from, 'for) derivedNode = { mutable value: 'to_ ; - updateF: 'from -> 'to_ } + updateF: ('from -> 'to_, [ `Has_arity1 ]) function$ } type nonrec ('from, ') derivedNode = { mutable value: 'to_ ; - updateF: 'from -> 'to_ } + updateF: ('from -> 'to_, [ `Has_arity1 ]) function$ } type nonrec ('from, ') derivedNode = { mutable value: 'to_ ; - updateF: 'from -> 'to_ } + updateF: ('from -> 'to_, [ `Has_arity1 ]) function$ } type nonrec ('from, 'foo) derivedNode = { mutable value: 'to_ ; - updateF: 'from -> 'to_ } \ No newline at end of file + updateF: ('from -> 'to_, [ `Has_arity1 ]) function$ } \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/errors/typexpr/expected/arrow.res.txt b/jscomp/syntax/tests/parsing/errors/typexpr/expected/arrow.res.txt index 264001c328..1872f20bfc 100644 --- a/jscomp/syntax/tests/parsing/errors/typexpr/expected/arrow.res.txt +++ b/jscomp/syntax/tests/parsing/errors/typexpr/expected/arrow.res.txt @@ -33,14 +33,17 @@ Did you forget a `:` here? It signals the start of a type -external add_nat : nat -> int = "add_nat_bytecode" +external add_nat : + (nat -> int, [ `Has_arity1 ]) function$ = "add_nat_bytecode" module Error2 = struct type nonrec observation = { observed: int ; onStep: - currentValue:((unit)[@res.namedArgLoc ]) -> [%rescript.typehole ] } + (currentValue:((unit)[@res.namedArgLoc ]) -> [%rescript.typehole ], + [ `Has_arity1 ]) function$ + } end module Error3 = struct diff --git a/jscomp/syntax/tests/parsing/errors/typexpr/expected/bsObjSugar.res.txt b/jscomp/syntax/tests/parsing/errors/typexpr/expected/bsObjSugar.res.txt index f348c94148..4813266564 100644 --- a/jscomp/syntax/tests/parsing/errors/typexpr/expected/bsObjSugar.res.txt +++ b/jscomp/syntax/tests/parsing/errors/typexpr/expected/bsObjSugar.res.txt @@ -141,7 +141,10 @@ type nonrec state = < url: string ;protocols: [%rescript.typehole ] ;websocket: Websocket.t > type nonrec state = < url: string ;protocols: [%rescript.typehole ] > -type nonrec state = < send: string -> [%rescript.typehole ] [@meth ] > +type nonrec state = + < + send: (string -> [%rescript.typehole ], [ `Has_arity1 ]) function$ + [@meth ] > type nonrec state = < age: [%rescript.typehole ] ;name: string > type nonrec state = < age: [%rescript.typehole ] [@set ] ;name: string > type nonrec state = < age: [%rescript.typehole ] ;.. > diff --git a/jscomp/syntax/tests/parsing/errors/typexpr/expected/garbage.res.txt b/jscomp/syntax/tests/parsing/errors/typexpr/expected/garbage.res.txt index 266ba05fae..ffbd700f71 100644 --- a/jscomp/syntax/tests/parsing/errors/typexpr/expected/garbage.res.txt +++ b/jscomp/syntax/tests/parsing/errors/typexpr/expected/garbage.res.txt @@ -8,5 +8,6 @@ I'm not sure what to parse here when looking at "?". -external printName : name:((unit)[@res.namedArgLoc ]) -> unit = "printName" -[@@module {js|moduleName|js}] \ No newline at end of file +external printName : + (name:((unit)[@res.namedArgLoc ]) -> unit, [ `Has_arity1 ]) function$ = + "printName"[@@module {js|moduleName|js}] \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/errors/typexpr/expected/objectSpread.res.txt b/jscomp/syntax/tests/parsing/errors/typexpr/expected/objectSpread.res.txt index 1f4a1a70f4..360531db88 100644 --- a/jscomp/syntax/tests/parsing/errors/typexpr/expected/objectSpread.res.txt +++ b/jscomp/syntax/tests/parsing/errors/typexpr/expected/objectSpread.res.txt @@ -30,4 +30,4 @@ type nonrec u = private { type nonrec x = | Type of < a ;u: int > type nonrec u = < a ;u: int ;v: int > -let f (x : < a: int ;b: int > ) = () \ No newline at end of file +let f = ((Function$ (fun (x : < a: int ;b: int > ) -> ()))[@res.arity 1]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/UncurriedByDefault.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/UncurriedByDefault.res.txt index 16b4bcc4c8..de6bcce8eb 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/UncurriedByDefault.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/UncurriedByDefault.res.txt @@ -1,41 +1,56 @@ -let cApp = foo 3 +let cApp = ((foo 3)[@res.uapp ]) let uApp = ((foo 3)[@res.uapp ]) -let cFun x = 3 +let cFun = ((Function$ (fun x -> 3))[@res.arity 1]) let uFun = ((Function$ (fun x -> 3))[@res.arity 1]) -let mixFun a = +let mixFun = ((Function$ - (fun b -> - fun c -> - ((fun d -> - fun e -> - fun f -> fun g -> ((Function$ (fun h -> 4))[@res.arity 1])) - [@res.braces ]))) - [@res.arity 2]) -let bracesFun = ((Function$ (fun x -> ((fun y -> x + y)[@res.braces ]))) + (fun a -> + fun b -> + fun c -> + ((Function$ + (fun d -> + fun e -> + fun f -> ((Function$ (fun g -> fun h -> 4)) + [@res.arity 2]))) + [@res.arity 3]))) + [@res.arity 3]) +let bracesFun = + ((Function$ (fun x -> ((Function$ (fun y -> x + y))[@res.arity 1]))) [@res.arity 1]) -let cFun2 x y = 3 +let cFun2 = ((Function$ (fun x -> fun y -> 3))[@res.arity 2]) let uFun2 = ((Function$ (fun x -> fun y -> 3))[@res.arity 2]) -type nonrec cTyp = string -> int +type nonrec cTyp = (string -> int, [ `Has_arity1 ]) function$ type nonrec uTyp = (string -> int, [ `Has_arity1 ]) function$ type nonrec mixTyp = - string -> - (string -> + (string -> + string -> string -> - string -> - string -> - string -> string -> (string -> int, [ `Has_arity1 ]) function$, - [ `Has_arity2 ]) function$ -type nonrec bTyp = (string -> string -> int, [ `Has_arity1 ]) function$ -type nonrec cTyp2 = string -> string -> int + (string -> + string -> + string -> (string -> string -> int, [ `Has_arity2 ]) function$, + [ `Has_arity3 ]) function$, + [ `Has_arity3 ]) function$ +type nonrec bTyp = + (string -> (string -> int, [ `Has_arity1 ]) function$, [ `Has_arity1 ]) + function$ +type nonrec cTyp2 = (string -> string -> int, [ `Has_arity2 ]) function$ type nonrec uTyp2 = (string -> string -> int, [ `Has_arity2 ]) function$ -type nonrec cu = unit -> int -type nonrec cp = unit -> int -type nonrec cuu = unit -> unit -> int -type nonrec cpu = unit -> unit -> int -type nonrec cup = unit -> unit -> int -type nonrec cpp = unit -> unit -> int -type nonrec cu2 = unit -> unit -> unit -type nonrec cp2 = unit -> unit -> unit +type nonrec cu = (unit -> int, [ `Has_arity1 ]) function$ +type nonrec cp = (unit -> int, [ `Has_arity1 ]) function$ +type nonrec cuu = + (unit -> (unit -> int, [ `Has_arity1 ]) function$, [ `Has_arity1 ]) + function$ +type nonrec cpu = + (unit -> (unit -> int, [ `Has_arity1 ]) function$, [ `Has_arity1 ]) + function$ +type nonrec cup = + (unit -> (unit -> int, [ `Has_arity1 ]) function$, [ `Has_arity1 ]) + function$ +type nonrec cpp = + (unit -> (unit -> int, [ `Has_arity1 ]) function$, [ `Has_arity1 ]) + function$ +type nonrec cu2 = (unit -> unit -> unit, [ `Has_arity2 ]) function$ +type nonrec cp2 = (unit -> unit -> unit, [ `Has_arity2 ]) function$ type nonrec uu = (unit -> int, [ `Has_arity1 ]) function$ type nonrec up = (unit -> int, [ `Has_arity1 ]) function$ type nonrec uuu = @@ -52,7 +67,9 @@ type nonrec upp = function$ type nonrec uu2 = (unit -> unit -> unit, [ `Has_arity2 ]) function$ type nonrec up2 = (unit -> unit -> unit, [ `Has_arity2 ]) function$ -type nonrec cnested = (string -> unit) -> unit +type nonrec cnested = + ((string -> unit, [ `Has_arity1 ]) function$ -> unit, [ `Has_arity1 ]) + function$ type nonrec unested = ((string -> unit, [ `Has_arity1 ]) function$ -> unit, [ `Has_arity1 ]) function$ @@ -60,26 +77,30 @@ let (uannpoly : ('a -> string, [ `Has_arity1 ]) function$) = xx let (uannint : (int -> string, [ `Has_arity1 ]) function$) = xx let _ = ((Function$ ((fun x -> 34)[@att ]))[@res.arity 1]) let _ = ((Function$ ((fun x -> 34)[@res.async ][@att ]))[@res.arity 1]) -let _ = preserveAttr ((Function$ ((fun x -> 34)[@att ]))[@res.arity 1]) +let _ = ((preserveAttr ((Function$ ((fun x -> 34)[@att ]))[@res.arity 1])) + [@res.uapp ]) let _ = - preserveAttr ((Function$ ((fun x -> 34)[@res.async ][@att ])) - [@res.arity 1]) -let t0 (type a) (type b) (l : a list) (x : a) = x :: l + ((preserveAttr ((Function$ ((fun x -> 34)[@res.async ][@att ])) + [@res.arity 1])) + [@res.uapp ]) +let t0 (type a) (type b) = + ((Function$ (fun (l : a list) -> fun (x : a) -> x :: l))[@res.arity 2]) let t1 (type a) (type b) = ((Function$ (fun (l : a list) -> fun (x : a) -> x :: l))[@res.arity 2]) let t2 (type a) (type b) = ((Function$ (fun (l : a list) -> fun (x : a) -> x :: l))[@res.arity 2]) let t3 (type a) (type b) = ((Function$ (fun (l : a list) -> fun (x : a) -> x :: l))[@res.arity 2]) -let t4 (type a) (type b) (l : a list) (x : a) = x :: l +let t4 (type a) (type b) = + ((Function$ (fun (l : a list) -> fun (x : a) -> x :: l))[@res.arity 2]) let t5 (type a) (type b) = ((Function$ (fun (l : a list) -> fun (x : a) -> x :: l))[@res.arity 2]) let t6 (type a) (type b) = ((Function$ (fun (l : a list) -> fun (x : a) -> x :: l))[@res.arity 2]) type nonrec arrowPath1 = (int -> string, [ `Has_arity1 ]) function$ type nonrec arrowPath2 = (I.t -> string, [ `Has_arity1 ]) function$ -type nonrec arrowPath3 = int -> string -type nonrec arrowPath4 = I.t -> string +type nonrec arrowPath3 = (int -> string, [ `Has_arity1 ]) function$ +type nonrec arrowPath4 = (I.t -> string, [ `Has_arity1 ]) function$ type nonrec callback1 = (ReactEvent.Mouse.t -> unit, [ `Has_arity1 ]) function$ as 'callback type nonrec callback2 = @@ -87,41 +108,49 @@ type nonrec callback2 = type nonrec callback3 = (ReactEvent.Mouse.t -> unit, [ `Has_arity1 ]) function$ as 'callback let cApp = ((foo 3)[@res.uapp ]) -let uApp = foo 3 +let uApp = ((foo 3)[@res.uapp ]) let cFun = ((Function$ (fun x -> 3))[@res.arity 1]) -let uFun x = 3 +let uFun = ((Function$ (fun x -> 3))[@res.arity 1]) let mixFun = ((Function$ (fun a -> - ((fun b -> - fun c -> - ((Function$ - (fun d -> - fun e -> - fun f -> - ((Function$ (fun g -> ((fun h -> 4)[@res.braces ]))) - [@res.arity 1]))) - [@res.arity 3])) - [@res.braces ]))) + ((Function$ + (fun b -> + fun c -> + ((Function$ + (fun d -> + fun e -> + fun f -> + ((Function$ + (fun g -> ((Function$ (fun h -> 4)) + [@res.arity 1]))) + [@res.arity 1]))) + [@res.arity 3]))) + [@res.arity 2]))) [@res.arity 1]) -let bracesFun x = ((Function$ (fun y -> x + y))[@res.arity 1]) -let cFun2 = ((Function$ (fun x -> fun y -> 3))[@res.arity 2]) -let uFun2 x y = 3 -let cFun2Dots = - ((Function$ (fun x -> ((Function$ (fun y -> 3))[@res.arity 1]))) +let bracesFun = + ((Function$ (fun x -> ((Function$ (fun y -> x + y))[@res.arity 1]))) [@res.arity 1]) +let cFun2 = ((Function$ (fun x -> fun y -> 3))[@res.arity 2]) +let uFun2 = ((Function$ (fun x -> fun y -> 3))[@res.arity 2]) +let cFun2Dots = ((Function$ (fun x -> fun y -> 3))[@res.arity 2]) type nonrec cTyp = (string -> int, [ `Has_arity1 ]) function$ -type nonrec uTyp = string -> int +type nonrec uTyp = (string -> int, [ `Has_arity1 ]) function$ type nonrec mixTyp = (string -> - string -> - string -> - (string -> string -> string -> string -> string -> int, - [ `Has_arity4 ]) function$, + (string -> + string -> + (string -> + string -> + string -> string -> (string -> int, [ `Has_arity1 ]) function$, + [ `Has_arity4 ]) function$, + [ `Has_arity2 ]) function$, [ `Has_arity1 ]) function$ -type nonrec bTyp = string -> (string -> int, [ `Has_arity1 ]) function$ +type nonrec bTyp = + (string -> (string -> int, [ `Has_arity1 ]) function$, [ `Has_arity1 ]) + function$ type nonrec cTyp2 = (string -> string -> int, [ `Has_arity2 ]) function$ -type nonrec uTyp2 = string -> string -> int +type nonrec uTyp2 = (string -> string -> int, [ `Has_arity2 ]) function$ type nonrec cu = (unit -> int, [ `Has_arity1 ]) function$ type nonrec cp = (unit -> int, [ `Has_arity1 ]) function$ type nonrec cuu = @@ -138,36 +167,54 @@ type nonrec cpp = function$ type nonrec cu2 = (unit -> unit -> unit, [ `Has_arity2 ]) function$ type nonrec cp2 = (unit -> unit -> unit, [ `Has_arity2 ]) function$ -type nonrec uu = unit -> int -type nonrec up = unit -> int -type nonrec uuu = unit -> unit -> int -type nonrec upu = unit -> unit -> int -type nonrec uup = unit -> unit -> int -type nonrec upp = unit -> unit -> int -type nonrec uu2 = unit -> unit -> unit -type nonrec up2 = unit -> unit -> unit +type nonrec uu = (unit -> int, [ `Has_arity1 ]) function$ +type nonrec up = (unit -> int, [ `Has_arity1 ]) function$ +type nonrec uuu = + (unit -> (unit -> int, [ `Has_arity1 ]) function$, [ `Has_arity1 ]) + function$ +type nonrec upu = + (unit -> (unit -> int, [ `Has_arity1 ]) function$, [ `Has_arity1 ]) + function$ +type nonrec uup = + (unit -> (unit -> int, [ `Has_arity1 ]) function$, [ `Has_arity1 ]) + function$ +type nonrec upp = + (unit -> (unit -> int, [ `Has_arity1 ]) function$, [ `Has_arity1 ]) + function$ +type nonrec uu2 = (unit -> unit -> unit, [ `Has_arity2 ]) function$ +type nonrec up2 = (unit -> unit -> unit, [ `Has_arity2 ]) function$ type nonrec cnested = ((string -> unit, [ `Has_arity1 ]) function$ -> unit, [ `Has_arity1 ]) function$ -type nonrec unested = (string -> unit) -> unit -let pipe1 = 3 |. f -let (uannpoly : 'a -> string) = xx -let (uannint : int -> string) = xx -let _ = ((fun x -> 34)[@att ]) -let _ = ((fun x -> 34)[@res.async ][@att ]) -let _ = preserveAttr ((fun x -> 34)[@att ]) -let _ = preserveAttr ((fun x -> 34)[@res.async ][@att ]) -let t0 (type a) (type b) (l : a list) (x : a) = x :: l +type nonrec unested = + ((string -> unit, [ `Has_arity1 ]) function$ -> unit, [ `Has_arity1 ]) + function$ +let pipe1 = 3 |.u f +let (uannpoly : ('a -> string, [ `Has_arity1 ]) function$) = xx +let (uannint : (int -> string, [ `Has_arity1 ]) function$) = xx +let _ = ((Function$ ((fun x -> 34)[@att ]))[@res.arity 1]) +let _ = ((Function$ ((fun x -> 34)[@res.async ][@att ]))[@res.arity 1]) +let _ = ((preserveAttr ((Function$ ((fun x -> 34)[@att ]))[@res.arity 1])) + [@res.uapp ]) +let _ = + ((preserveAttr ((Function$ ((fun x -> 34)[@res.async ][@att ])) + [@res.arity 1])) + [@res.uapp ]) +let t0 (type a) (type b) = + ((Function$ (fun (l : a list) -> fun (x : a) -> x :: l))[@res.arity 2]) let t1 (type a) (type b) = ((Function$ (fun (l : a list) -> fun (x : a) -> x :: l))[@res.arity 2]) let t2 (type a) (type b) = ((Function$ (fun (l : a list) -> fun (x : a) -> x :: l))[@res.arity 2]) let t3 (type a) (type b) = ((Function$ (fun (l : a list) -> fun (x : a) -> x :: l))[@res.arity 2]) -type nonrec arrowPath1 = int -> string -type nonrec arrowPath2 = I.t -> string +type nonrec arrowPath1 = (int -> string, [ `Has_arity1 ]) function$ +type nonrec arrowPath2 = (I.t -> string, [ `Has_arity1 ]) function$ type nonrec arrowPath3 = (int -> string, [ `Has_arity1 ]) function$ type nonrec arrowPath4 = (I.t -> string, [ `Has_arity1 ]) function$ -type nonrec callback1 = (ReactEvent.Mouse.t -> unit) as 'callback -type nonrec callback2 = ReactEvent.Mouse.t -> unit as 'u -type nonrec callback3 = (ReactEvent.Mouse.t -> unit) as 'callback \ No newline at end of file +type nonrec callback1 = + (ReactEvent.Mouse.t -> unit, [ `Has_arity1 ]) function$ as 'callback +type nonrec callback2 = + (ReactEvent.Mouse.t -> unit as 'u, [ `Has_arity1 ]) function$ +type nonrec callback3 = + (ReactEvent.Mouse.t -> unit, [ `Has_arity1 ]) function$ as 'callback \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/apply.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/apply.res.txt index e6a0aa7437..1d9662ef6f 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/apply.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/apply.res.txt @@ -1,8 +1,12 @@ -;;foo (fun _ -> bla) blaz -;;foo (fun _ -> bla) blaz -;;foo ((Function$ (fun _ -> bla))[@res.arity 1]) blaz -;;foo (fun _ -> bla) (fun _ -> blaz) -;;List.map (fun x -> x + 1) myList -;;List.reduce (fun acc -> fun curr -> acc + curr) 0 myList +;;((foo ((Function$ (fun _ -> bla))[@res.arity 1]) blaz)[@res.uapp ]) +;;((foo ((Function$ (fun _ -> bla))[@res.arity 1]) blaz)[@res.uapp ]) +;;((foo ((Function$ (fun _ -> bla))[@res.arity 1]) blaz)[@res.uapp ]) +;;((foo ((Function$ (fun _ -> bla))[@res.arity 1]) + ((Function$ (fun _ -> blaz))[@res.arity 1]))[@res.uapp ]) +;;((List.map ((Function$ (fun x -> x + 1))[@res.arity 1]) myList) + [@res.uapp ]) +;;((List.reduce ((Function$ (fun acc -> fun curr -> acc + curr)) + [@res.arity 2]) 0 myList)[@res.uapp ]) let unitUncurried = ((apply ())[@res.uapp ]) -;;call ~a:(((((a)[@res.namedArgLoc ]) : int))[@res.namedArgLoc ]) \ No newline at end of file +;;((call ~a:(((((a)[@res.namedArgLoc ]) : int))[@res.namedArgLoc ])) + [@res.uapp ]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/argument.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/argument.res.txt index 5e176ba56f..854cde12a1 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/argument.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/argument.res.txt @@ -1,13 +1,18 @@ -let foo ~a:((a)[@res.namedArgLoc ]) = - ((a (let __res_unit = () in __res_unit))[@res.uapp ]) +. 1. +let foo = + ((Function$ + (fun ~a:((a)[@res.namedArgLoc ]) -> + ((a (let __res_unit = () in __res_unit))[@res.uapp ]) +. 1.)) + [@res.arity 1]) let a = ((Function$ (fun () -> 2))[@res.arity 1]) -let bar = foo ~a:((a)[@res.namedArgLoc ]) +let bar = ((foo ~a:((a)[@res.namedArgLoc ]))[@res.uapp ]) let comparisonResult = ((compare currentNode.value ~targetValue:((targetValue)[@res.namedArgLoc ])) [@res.uapp ]) ;;((callback firstNode ~y:((y)[@res.namedArgLoc ]))[@res.uapp ]) ;;((document.createElementWithOptions {js|div|js} - (elementProps ~onClick:((fun _ -> Js.log {js|hello world|js}) - [@res.namedArgLoc ])))[@res.uapp ]) + ((elementProps + ~onClick:((Function$ + (fun _ -> ((Js.log {js|hello world|js})[@res.uapp ]))) + [@res.namedArgLoc ][@res.arity 1]))[@res.uapp ]))[@res.uapp ]) ;;((resolve ())[@res.uapp ]) ;;((resolve (let __res_unit = () in __res_unit))[@res.uapp ]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/arrow.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/arrow.res.txt index caded38220..8c09e9dcd7 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/arrow.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/arrow.res.txt @@ -1,100 +1,149 @@ -let f x = x + 1 -let f _ = Js.log {js|test|js} -let f () = Js.log {js|unit|js} -let f (Reducer (inst, comp)) = inst.render comp -let f (Instance) = () -let f a b = a + b -let f 1 2 = () -let f {js|stringPattern|js} = () -let f {js|stringPattern|js} {js|stringPattern|js} = () -let f () = () -let f (a : int) (b : int) = a + b -let f _ _ = () -let f [|a;b|] [|c;d|] = ((a + b) + c) + d -let f { a } = a + 1 -let f { a; b } { c; d } = ((a + b) + c) + d -let f (a, b) = a + b -let f (a, b) (c, d) = ((a + b) + c) + d -let f exception Terminate = () -let f exception Terminate exception Exit = () -let f [] = () -let f (x::xs) = x + (xs |. Belt.List.length) -let f (x : int) (y : int) = x + y -let f ~a:((a)[@res.namedArgLoc ]) ~b:((b)[@res.namedArgLoc ]) = a + b -let f ~a:((x)[@res.namedArgLoc ]) ~b:((y)[@res.namedArgLoc ]) = x + y -let f ~a:(((x : int))[@res.namedArgLoc ]) - ~b:(((y : int))[@res.namedArgLoc ]) = x + y -let f ?a:(((a)[@res.namedArgLoc ])= 1) ?b:(((b)[@res.namedArgLoc ])= 2) c = - (a + b) + c -let f ?a:(((x)[@res.namedArgLoc ])= 1) ?b:(((y)[@res.namedArgLoc ])= 2) c = - (x + y) + c -let f ?a:((((x : int))[@res.namedArgLoc ])= 1) - ?b:((((y : int))[@res.namedArgLoc ])= 2) c = (x + y) + c -let f ?a:((a)[@res.namedArgLoc ]) ?b:((b)[@res.namedArgLoc ]) c = - match (a, b) with | (Some a, Some b) -> (a + b) + c | _ -> 3 -let f ?a:((x)[@res.namedArgLoc ]) ?b:((y)[@res.namedArgLoc ]) c = - match (x, y) with | (Some a, Some b) -> (a + b) + c | _ -> 3 -let f ?a:(((x : int option))[@res.namedArgLoc ]) - ?b:(((y : int option))[@res.namedArgLoc ]) c = - match (x, y) with | (Some a, Some b) -> (a + b) + c | _ -> 3 -let f a b = a + b -let f = ((Function$ (fun () -> ()))[@res.arity 1]) +let f = ((Function$ (fun x -> x + 1))[@res.arity 1]) +let f = ((Function$ (fun _ -> ((Js.log {js|test|js})[@res.uapp ]))) + [@res.arity 1]) +let f = ((Function$ (fun () -> ((Js.log {js|unit|js})[@res.uapp ]))) + [@res.arity 1]) +let f = + ((Function$ + (fun (Reducer (inst, comp)) -> ((inst.render comp)[@res.uapp ]))) + [@res.arity 1]) +let f = ((Function$ (fun (Instance) -> ()))[@res.arity 1]) +let f = ((Function$ (fun a -> fun b -> a + b))[@res.arity 2]) +let f = ((Function$ (fun 1 -> fun 2 -> ()))[@res.arity 2]) +let f = ((Function$ (fun {js|stringPattern|js} -> ()))[@res.arity 1]) +let f = + ((Function$ (fun {js|stringPattern|js} -> fun {js|stringPattern|js} -> ())) + [@res.arity 2]) let f = ((Function$ (fun () -> ()))[@res.arity 1]) -let f = ((Function$ (fun a -> fun b -> fun c -> ()))[@res.arity 3]) +let f = ((Function$ (fun (a : int) -> fun (b : int) -> a + b))[@res.arity 2]) +let f = ((Function$ (fun _ -> fun _ -> ()))[@res.arity 2]) +let f = ((Function$ (fun [|a;b|] -> fun [|c;d|] -> ((a + b) + c) + d)) + [@res.arity 2]) +let f = ((Function$ (fun { a } -> a + 1))[@res.arity 1]) +let f = ((Function$ (fun { a; b } -> fun { c; d } -> ((a + b) + c) + d)) + [@res.arity 2]) +let f = ((Function$ (fun (a, b) -> a + b))[@res.arity 1]) +let f = ((Function$ (fun (a, b) -> fun (c, d) -> ((a + b) + c) + d)) + [@res.arity 2]) +let f = ((Function$ (fun exception Terminate -> ()))[@res.arity 1]) +let f = ((Function$ (fun exception Terminate -> fun exception Exit -> ())) + [@res.arity 2]) +let f = ((Function$ (fun [] -> ()))[@res.arity 1]) +let f = ((Function$ (fun (x::xs) -> x + (xs |.u Belt.List.length))) + [@res.arity 1]) +let f = ((Function$ (fun (x : int) -> fun (y : int) -> x + y))[@res.arity 2]) let f = ((Function$ - (fun a -> fun b -> ((Function$ (fun c -> fun d -> ()))[@res.arity 2]))) + (fun ~a:((a)[@res.namedArgLoc ]) -> + fun ~b:((b)[@res.namedArgLoc ]) -> a + b)) [@res.arity 2]) let f = ((Function$ - (fun a -> - ((Function$ (fun b -> ((Function$ (fun c -> ()))[@res.arity 1]))) - [@res.arity 1]))) - [@res.arity 1]) + (fun ~a:((x)[@res.namedArgLoc ]) -> + fun ~b:((y)[@res.namedArgLoc ]) -> x + y)) + [@res.arity 2]) let f = ((Function$ - (fun ~a:((a)[@res.namedArgLoc ][@attr ]) -> - fun b -> - ((Function$ - (fun ~c:((c)[@res.namedArgLoc ][@attr ]) -> fun d -> ())) - [@res.arity 2]))) + (fun ~a:(((x : int))[@res.namedArgLoc ]) -> + fun ~b:(((y : int))[@res.namedArgLoc ]) -> x + y)) [@res.arity 2]) +let f = + ((Function$ + (fun ?a:(((a)[@res.namedArgLoc ])= 1) -> + fun ?b:(((b)[@res.namedArgLoc ])= 2) -> fun c -> (a + b) + c)) + [@res.arity 3]) +let f = + ((Function$ + (fun ?a:(((x)[@res.namedArgLoc ])= 1) -> + fun ?b:(((y)[@res.namedArgLoc ])= 2) -> fun c -> (x + y) + c)) + [@res.arity 3]) +let f = + ((Function$ + (fun ?a:((((x : int))[@res.namedArgLoc ])= 1) -> + fun ?b:((((y : int))[@res.namedArgLoc ])= 2) -> fun c -> (x + y) + c)) + [@res.arity 3]) +let f = + ((Function$ + (fun ?a:((a)[@res.namedArgLoc ]) -> + fun ?b:((b)[@res.namedArgLoc ]) -> + fun c -> + match (a, b) with | (Some a, Some b) -> (a + b) + c | _ -> 3)) + [@res.arity 3]) +let f = + ((Function$ + (fun ?a:((x)[@res.namedArgLoc ]) -> + fun ?b:((y)[@res.namedArgLoc ]) -> + fun c -> + match (x, y) with | (Some a, Some b) -> (a + b) + c | _ -> 3)) + [@res.arity 3]) +let f = + ((Function$ + (fun ?a:(((x : int option))[@res.namedArgLoc ]) -> + fun ?b:(((y : int option))[@res.namedArgLoc ]) -> + fun c -> + match (x, y) with | (Some a, Some b) -> (a + b) + c | _ -> 3)) + [@res.arity 3]) +let f = ((Function$ (fun a -> fun b -> a + b))[@res.arity 2]) +let f = ((Function$ (fun () -> ()))[@res.arity 1]) +let f = ((Function$ (fun () -> ()))[@res.arity 1]) +let f = ((Function$ (fun a -> fun b -> fun c -> ()))[@res.arity 3]) +let f = ((Function$ (fun a -> fun b -> fun c -> fun d -> ()))[@res.arity 4]) +let f = ((Function$ (fun a -> fun b -> fun c -> ()))[@res.arity 3]) +let f = + ((Function$ + (fun ~a:((a)[@res.namedArgLoc ][@attr ]) -> + fun b -> fun ~c:((c)[@res.namedArgLoc ][@attr ]) -> fun d -> ())) + [@res.arity 4]) let f = ((Function$ (fun ~a:((a)[@res.namedArgLoc ][@attr ]) -> fun ((b)[@attrOnB ]) -> - ((Function$ - (fun ~c:((c)[@res.namedArgLoc ][@attr ]) -> - fun ((d)[@attrOnD ]) -> ())) - [@res.arity 2]))) - [@res.arity 2]) -let f list = list () + fun ~c:((c)[@res.namedArgLoc ][@attr ]) -> + fun ((d)[@attrOnD ]) -> ())) + [@res.arity 4]) +let f = ((Function$ (fun list -> ((list ())[@res.uapp ])))[@res.arity 1]) ;;match colour with | Red when (l = l') || (Clflags.classic.contents && - ((l = Nolabel) && (not (is_optional l')))) + ((l = Nolabel) && (not ((is_optional l')[@res.uapp ])))) -> (t1, t2) | _ -> () let arr = - [|((fun _ -> doThings ()));((fun _ -> doThings ()));((fun _ -> doThings ()))|] + [|((Function$ ((fun _ -> ((doThings ())[@res.uapp ])))) + [@res.arity 1]);((Function$ ((fun _ -> ((doThings ())[@res.uapp ])))) + [@res.arity 1]);((Function$ ((fun _ -> ((doThings ())[@res.uapp ])))) + [@res.arity 1])|] let list = - [(fun _ -> doThings ()); (fun _ -> doThings ()); (fun _ -> doThings ())] + [((Function$ ((fun _ -> ((doThings ())[@res.uapp ])))) + [@res.arity 1]); + ((Function$ ((fun _ -> ((doThings ())[@res.uapp ])))) + [@res.arity 1]); + ((Function$ ((fun _ -> ((doThings ())[@res.uapp ])))) + [@res.arity 1])] let tuple = - ((fun _ -> doThings ()), (fun _ -> doThings ()), (fun _ -> doThings ())) -;;fun _ -> doThings () + (((Function$ (fun _ -> ((doThings ())[@res.uapp ])))[@res.arity 1]), + ((Function$ (fun _ -> ((doThings ())[@res.uapp ])))[@res.arity 1]), + ((Function$ (fun _ -> ((doThings ())[@res.uapp ])))[@res.arity 1])) +;;((Function$ (fun _ -> ((doThings ())[@res.uapp ])))[@res.arity 1]) let x = Constructore - ((fun _ -> copyChecklistItemCB ()), (fun _ -> copyChecklistItemCB ())) + (((Function$ (fun _ -> ((copyChecklistItemCB ())[@res.uapp ]))) + [@res.arity 1]), + ((Function$ (fun _ -> ((copyChecklistItemCB ())[@res.uapp ]))) + [@res.arity 1])) let y = `Constructore - ((fun _ -> copyChecklistItemCB ()), (fun _ -> copyChecklistItemCB ())) -let f list = list + 1 + (((Function$ (fun _ -> ((copyChecklistItemCB ())[@res.uapp ]))) + [@res.arity 1]), + ((Function$ (fun _ -> ((copyChecklistItemCB ())[@res.uapp ]))) + [@res.arity 1])) +let f = ((Function$ (fun list -> list + 1))[@res.arity 1]) let foo = (() : unit) type nonrec u = unit let un = (() : u) type nonrec ('a, 'b) d = ('a * 'b) -let c () = ((1, 2) : ('a, 'b) d) -let fn f = f -type nonrec f = int -> unit -let a = fn (fun _ -> () : f) \ No newline at end of file +let c = ((Function$ (fun () -> ((1, 2) : ('a, 'b) d)))[@res.arity 1]) +let fn = ((Function$ (fun f -> f))[@res.arity 1]) +type nonrec f = (int -> unit, [ `Has_arity1 ]) function$ +let a = ((fn (((Function$ (fun _ -> ()))[@res.arity 1]) : f))[@res.uapp ]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/async.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/async.res.txt index 585d61302e..cbdc5ae9ff 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/async.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/async.res.txt @@ -1,10 +1,12 @@ let greetUser = - ((fun userId -> - ((let name = ((getUserName userId)[@res.await ][@res.uapp ]) in - ({js|Hello |js} ^ name) ^ {js|!|js}) - [@res.braces ])) - [@res.async ]) -;;((fun () -> 123)[@res.async ]) + ((Function$ + ((fun userId -> + ((let name = ((getUserName userId)[@res.await ][@res.uapp ]) in + ({js|Hello |js} ^ name) ^ {js|!|js}) + [@res.braces ])) + [@res.async ])) + [@res.arity 1]) +;;((Function$ ((fun () -> 123)[@res.async ]))[@res.arity 1]) let fetch = ((Function$ ((fun url -> ((browserFetch url)[@res.uapp ]))[@res.async ])) [@res.braces ][@res.arity 1]) @@ -17,21 +19,30 @@ let fetch2 = [@res.arity 1])) [@res.braces ]) let async = - ((let f = async () in - () |. async; - async (); + ((let f = ((async ())[@res.uapp ]) in + () |.u async; + ((async ()) + [@res.uapp ]); async.async; { async = (async.(async)) }; - (result |. async) |. (mapAsync (fun a -> doStuff a))) + (result |.u async) |.u + ((mapAsync ((Function$ (fun a -> ((doStuff a)[@res.uapp ]))) + [@res.arity 1])) + [@res.uapp ])) [@res.braces ]) let f = ((if isPositive - then ((fun a -> fun b -> (a + b : int))[@res.async ]) - else (((fun c -> fun d -> (c - d : int)))[@res.async ])) + then ((Function$ ((fun a -> fun b -> (a + b : int))[@res.async ])) + [@res.arity 2]) + else ((Function$ (((fun c -> fun d -> (c - d : int)))[@res.async ])) + [@res.arity 2])) [@res.ternary ]) -let foo = async ~a:((34)[@res.namedArgLoc ]) -let bar = ((fun ~a:((a)[@res.namedArgLoc ]) -> a + 1)[@res.async ]) +let foo = ((async ~a:((34)[@res.namedArgLoc ]))[@res.uapp ]) +let bar = + ((Function$ ((fun ~a:((a)[@res.namedArgLoc ]) -> a + 1)[@res.async ])) + [@res.arity 1]) let ex1 = ((3)[@res.await ]) + ((4)[@res.await ]) let ex2 = ((3)[@res.await ]) ** ((4)[@res.await ]) -let ex3 = ((foo |. (bar ~arg:((arg)[@res.namedArgLoc ])))[@res.await ]) +let ex3 = ((foo |.u ((bar ~arg:((arg)[@res.namedArgLoc ]))[@res.uapp ])) + [@res.await ]) let ex4 = (((foo.bar).baz)[@res.await ]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/await.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/await.res.txt index 5dead70f97..dd69f8243d 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/await.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/await.res.txt @@ -1,33 +1,44 @@ -;;((wait 2)[@res.await ]) +;;((wait 2)[@res.await ][@res.uapp ]) let maybeSomeValue = - match ((fetchData url)[@res.await ]) with + match ((fetchData url)[@res.await ][@res.uapp ]) with | data -> Some data | exception JsError _ -> None let x = ((1)[@res.await ]) + 2 -let x = ((wait 1)[@res.await ]) + ((wait 2)[@res.await ]) +let x = + ((wait 1)[@res.await ][@res.uapp ]) + ((wait 2)[@res.await ][@res.uapp ]) let () = - ((let response = ((fetch {js|/users.json|js})[@res.await ]) in - let users = ((response.json ())[@res.await ]) in + ((let response = ((fetch {js|/users.json|js})[@res.await ][@res.uapp ]) in + let users = ((response.json ())[@res.await ][@res.uapp ]) in let comments = - ((((fetch {js|comment.json|js})[@res.await ]).json ()) - [@res.await ]).(0) in - Js.log2 users comments) + ((((fetch {js|comment.json|js})[@res.await ][@res.uapp ]).json ()) + [@res.await ][@res.uapp ]).(0) in + ((Js.log2 users comments)[@res.uapp ])) [@res.braces ]) -let () = ((delay 10)[@res.braces ][@res.await ]) -let () = ((((delay 10)[@res.await ]); ((delay 20)[@res.await ])) +let () = ((delay 10)[@res.braces ][@res.await ][@res.uapp ]) +let () = + ((((delay 10) + [@res.await ][@res.uapp ]); + ((delay 20) + [@res.await ][@res.uapp ])) [@res.braces ]) let forEach = ((Js.Import Belt.List.forEach)[@res.await ][@a ][@b ]) module M = ((Belt.List)[@res.await ][@a ][@b ]) -let f () = - ((let module M = ((Belt.List)[@res.await ][@a ][@b ]) in M.forEach) - [@res.braces ]) +let f = + ((Function$ + (fun () -> + ((let module M = ((Belt.List)[@res.await ][@a ][@b ]) in M.forEach) + [@res.braces ]))) + [@res.arity 1]) let () = ((let module M = ((Belt.List)[@res.await ][@a ][@b ]) in M.forEach) [@res.braces ]) module type BeltList = module type of Belt.List -let f () = - ((let module M = (((Belt.List : BeltList))[@res.await ][@a ][@b ]) in - M.forEach) - [@res.braces ]) +let f = + ((Function$ + (fun () -> + ((let module M = (((Belt.List : BeltList))[@res.await ][@a ] + [@b ]) in M.forEach) + [@res.braces ]))) + [@res.arity 1]) let () = ((let module M = (((Belt.List : BeltList))[@res.await ][@a ][@b ]) in M.forEach) diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/binary.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/binary.res.txt index 8d7dc689d3..d3c92c8505 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/binary.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/binary.res.txt @@ -1,16 +1,27 @@ -;;node := (if newBalance == 2 then avl |. (rotateRight node) else node) -;;node := ((if newBalance == 2 then avl |. (rotateRight node) else node) +;;node := + (if newBalance == 2 + then avl |.u ((rotateRight node)[@res.uapp ]) + else node) +;;node := + ((if newBalance == 2 + then avl |.u ((rotateRight node)[@res.uapp ]) + else node) [@attr ]) -let x = z |> (match z with | _ -> false) -let x = z |> ((match z with | _ -> false)[@attr ]) -let x = z |> (assert z) -let x = z |> ((assert z)[@attr ]) -let x = z |> (try sideEffect () with | _ -> f ()) -let x = z |> ((try sideEffect () with | _ -> f ())[@attr ]) -let x = z |> for i = 0 to 10 do () done -let x = z |> ((for i = 0 to 10 do () done)[@attr ]) -let x = z |> while condition do () done -let x = z |> ((while condition do () done)[@attr ]) +let x = (((match z with | _ -> false) z)[@res.uapp ]) +let x = ((((match z with | _ -> false)[@attr ]) z)[@res.uapp ]) +let x = (((assert z) z)[@res.uapp ]) +let x = ((((assert z)[@attr ]) z)[@res.uapp ]) +let x = + (((try ((sideEffect ())[@res.uapp ]) with | _ -> ((f ())[@res.uapp ])) z) + [@res.uapp ]) +let x = + ((((try ((sideEffect ())[@res.uapp ]) with | _ -> ((f ())[@res.uapp ])) + [@attr ]) z) + [@res.uapp ]) +let x = ((for i = 0 to 10 do () done z)[@res.uapp ]) +let x = ((((for i = 0 to 10 do () done)[@attr ]) z)[@res.uapp ]) +let x = ((while condition do () done z)[@res.uapp ]) +let x = ((((while condition do () done)[@attr ]) z)[@res.uapp ]) let x = (a + (-1)) + (-2) let x = (a + (((-1))[@attr ])) + (((-2))[@attr ]) let x = a - b @@ -18,5 +29,9 @@ let x = a -. b ;;Constructor (a, b) ;;`Constructor (a, b) let _ = ((Constructor (a, b); `Constructor (a, b))[@res.braces ]) -;;((library.getBalance account)[@res.uapp ]) |. - (Promise.Js.catch (fun _ -> ((Promise.resolved None)[@res.braces ]))) \ No newline at end of file +;;((library.getBalance account)[@res.uapp ]) |.u + ((Promise.Js.catch + ((Function$ + (fun _ -> ((Promise.resolved None)[@res.braces ][@res.uapp ]))) + [@res.arity 1])) + [@res.uapp ]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/binaryNoEs6Arrow.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/binaryNoEs6Arrow.res.txt index aa35b4d627..65a2c884b2 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/binaryNoEs6Arrow.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/binaryNoEs6Arrow.res.txt @@ -22,13 +22,17 @@ ((sibling == None) || (parent == None)) do () done ;;((div - ~onClick:((fun event -> - ((match videoContainerRect with - | Some videoContainerRect -> - let newChapter = - ({ startTime = (percent *. duration) } : Video.chapter) in - { a; b } |. onChange - | _ -> ()) - [@res.braces ]))[@res.namedArgLoc ][@res.braces ]) - ~children:[] ())[@JSX ]) -;;if inclusions.(index) <- (uid, url) then onChange inclusions \ No newline at end of file + ~onClick:((Function$ + (fun event -> + ((match videoContainerRect with + | Some videoContainerRect -> + let newChapter = + ({ startTime = (percent *. duration) } : + Video.chapter) in + { a; b } |.u onChange + | _ -> ()) + [@res.braces ]))) + [@res.namedArgLoc ][@res.braces ][@res.arity 1]) ~children:[] ()) + [@JSX ]) +;;if inclusions.(index) <- (uid, url) + then ((onChange inclusions)[@res.uapp ]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/block.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/block.res.txt index 6777f28579..ab8b06bc7f 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/block.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/block.res.txt @@ -1,16 +1,29 @@ let b = ((let module Array = Belt.Array in - ([|1;2|] |. (Array.map (fun x -> x + 1))) |. Js.log) + ([|1;2|] |.u ((Array.map ((Function$ (fun x -> x + 1))[@res.arity 1])) + [@res.uapp ])) + |.u Js.log) [@res.braces ]) let b = - ((let open Belt.Array in ([|1;2|] |. (map (fun x -> x + 1))) |. Js.log) + ((let open Belt.Array in + ([|1;2|] |.u ((map ((Function$ (fun x -> x + 1))[@res.arity 1])) + [@res.uapp ])) + |.u Js.log) + [@res.braces ]) +let b = ((let exception QuitEarly in ((raise QuitEarly)[@res.uapp ])) [@res.braces ]) -let b = ((let exception QuitEarly in raise QuitEarly)[@res.braces ]) let b = ((let a = 1 in let b = 2 in a + b)[@res.braces ]) -let b = ((let _ = sideEffect () in ())[@res.braces ]) -let b = ((let _ = sideEffect () in ())[@res.braces ]) -let b = ((a (); b (); c ())[@res.braces ]) -let b = ((a (); b (); (let a = 1 in f a))[@res.braces ]) +let b = ((let _ = ((sideEffect ())[@res.uapp ]) in ())[@res.braces ]) +let b = ((let _ = ((sideEffect ())[@res.uapp ]) in ())[@res.braces ]) +let b = ((((a ())[@res.uapp ]); ((b ())[@res.uapp ]); ((c ())[@res.uapp ])) + [@res.braces ]) +let b = + ((((a ()) + [@res.uapp ]); + ((b ()) + [@res.uapp ]); + (let a = 1 in ((f a)[@res.uapp ]))) + [@res.braces ]) let b = ((let a = 1 in let b = 2 in ())[@res.braces ]) let b = ((let module Array = Belt.Array in @@ -18,54 +31,99 @@ let b = let exception Terminate of int in let a = 1 in let b = 2 in - sideEffect (); - (let x = (1 + 2) |. (fun x -> x + 1) in raise (Terminate x))) + ((sideEffect ()) + [@res.uapp ]); + (let x = (1 + 2) |.u ((Function$ (fun x -> x + 1))[@res.arity 1]) in + ((raise (Terminate x))[@res.uapp ]))) + [@res.braces ]) +let b = + ((((f ()) + [@res.uapp ]); + ((g ()) + [@res.uapp ]); + ((h ()) + [@res.uapp ]); + (let arr = [|1;2;3|] in ())) [@res.braces ]) -let b = ((f (); g (); h (); (let arr = [|1;2;3|] in ()))[@res.braces ]) let res = ((let a = {js|a starts out as|js} in - (((print_string a; (let a = 20 in print_int a))) + (((((print_string a) + [@res.uapp ]); + (let a = 20 in ((print_int a)[@res.uapp ])))) [@res.braces ]); - print_string a) + ((print_string a) + [@res.uapp ])) [@res.braces ]) let res = ((let a = {js|first its a string|js} in - let a = 20 in print_int a; print_int a; print_int a) + let a = 20 in + ((print_int a) + [@res.uapp ]); + ((print_int a) + [@res.uapp ]); + ((print_int a) + [@res.uapp ])) [@res.braces ]) let res = ((let a = {js|a is always a string|js} in - print_string a; (let b = 30 in print_int b)) + ((print_string a) + [@res.uapp ]); + (let b = 30 in ((print_int b)[@res.uapp ]))) [@res.braces ]) let nestedLet = ((let _ = 1 in ())[@res.braces ]) let nestedLet = ((let _ = 1 in 2)[@res.braces ]) -let init () = ((foo (1 == 1); [%assert 1 == 2])[@res.braces ]) -let init () = (([%assert 1 == 2]; foo (1 == 1); [%assert 1 == 2]) - [@res.braces ]) -let f () = ((let x = 1 in fun _ -> ())[@res.braces ]) -let reifyStyle (type a) (x : 'a) = - (((let module Internal = - struct - type constructor - external canvasGradient : constructor = "CanvasGradient"[@@val ] - external canvasPattern : constructor = "CanvasPattern"[@@val ] - let instanceOf = - ([%raw - (({js|function(x,y) {return +(x instanceof y)}|js}) - [@res.template ])] : 'a -> constructor -> bool) - end in - ((if (Js.typeof x) = {js|string|js} - then Obj.magic String - else - if Internal.instanceOf x Internal.canvasGradient - then Obj.magic Gradient - else - if Internal.instanceOf x Internal.canvasPattern - then Obj.magic Pattern - else - raise - (Invalid_argument - {js|Unknown canvas style kind. Known values are: String, CanvasGradient, CanvasPattern|js})), - (Obj.magic x))) - [@res.braces ]) : (a style * a)) -let calc_fps t0 t1 = ((let delta = (t1 -. t0) /. 1000. in 1. /. delta) - [@res.braces ]) \ No newline at end of file +let init = + ((Function$ + (fun () -> ((((foo (1 == 1))[@res.uapp ]); [%assert 1 == 2]) + [@res.braces ]))) + [@res.arity 1]) +let init = + ((Function$ + (fun () -> + (([%assert 1 == 2]; ((foo (1 == 1))[@res.uapp ]); [%assert 1 == 2]) + [@res.braces ]))) + [@res.arity 1]) +let f = + ((Function$ + (fun () -> ((let x = 1 in ((Function$ (fun _ -> ()))[@res.arity 1])) + [@res.braces ]))) + [@res.arity 1]) +let reifyStyle (type a) = + ((Function$ + (fun (x : 'a) -> + (((let module Internal = + struct + type constructor + external canvasGradient : constructor = "CanvasGradient" + [@@val ] + external canvasPattern : constructor = "CanvasPattern" + [@@val ] + let instanceOf = + ([%raw + (({js|function(x,y) {return +(x instanceof y)}|js}) + [@res.template ])] : ('a -> constructor -> bool, + [ `Has_arity2 ]) function$) + end in + ((if ((Js.typeof x)[@res.uapp ]) = {js|string|js} + then ((Obj.magic String)[@res.uapp ]) + else + if ((Internal.instanceOf x Internal.canvasGradient) + [@res.uapp ]) + then ((Obj.magic Gradient)[@res.uapp ]) + else + if ((Internal.instanceOf x Internal.canvasPattern) + [@res.uapp ]) + then ((Obj.magic Pattern)[@res.uapp ]) + else + ((raise + (Invalid_argument + {js|Unknown canvas style kind. Known values are: String, CanvasGradient, CanvasPattern|js})) + [@res.uapp ])), ((Obj.magic x)[@res.uapp ]))) + [@res.braces ]) : (a style * a)))) + [@res.arity 1]) +let calc_fps = + ((Function$ + (fun t0 -> + fun t1 -> ((let delta = (t1 -. t0) /. 1000. in 1. /. delta) + [@res.braces ]))) + [@res.arity 2]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/bracedOrRecord.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/bracedOrRecord.res.txt index e84520ae8e..61a53bf4ed 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/bracedOrRecord.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/bracedOrRecord.res.txt @@ -3,26 +3,35 @@ let r = { a } let r = { a = expr } let r = { a = expr } let r = { a = expr; b = expr2 } -let r = { f = (fun x -> x + b) } +let r = { f = ((Function$ (fun x -> x + b))[@res.arity 1]) } let e = ((a)[@res.braces ]) let e = ((a)[@res.braces ]) -let e = ((a; b ())[@res.braces ]) +let e = ((a; ((b ())[@res.uapp ]))[@res.braces ]) let e = ((- a)[@res.braces ]) let e = ((a + b)[@res.braces ]) let e = ((if a then true else false)[@res.braces ][@res.ternary ]) -let e = ((if a |> computation then true else false) +let e = ((if ((computation a)[@res.uapp ]) then true else false) [@res.braces ][@res.ternary ]) let e = ((a.(0))[@res.braces ]) -let e = ((f b)[@res.braces ]) +let e = ((f b)[@res.braces ][@res.uapp ]) let e = (((a.b).c)[@res.braces ]) let e = ((arr.(x) <- 20)[@res.braces ]) -let e = ((fun x -> (x + 1) |> (doStuff config))[@res.braces ]) -let e = (((fun x -> x + 1) |> (doStuff config))[@res.braces ]) -let e = ((if fun x -> x + 1 then true else false) +let e = ((Function$ (fun x -> ((doStuff config (x + 1))[@res.uapp ]))) + [@res.braces ][@res.arity 1]) +let e = ((doStuff config ((Function$ (fun x -> x + 1))[@res.arity 1])) + [@res.braces ][@res.uapp ]) +let e = + ((if ((Function$ (fun x -> x + 1))[@res.arity 1]) then true else false) [@res.braces ][@res.ternary ]) -let e = (((fun x -> x + 1) |> sideEffect; logToAnalytics Shady.ml) +let e = + ((((sideEffect ((Function$ (fun x -> x + 1))[@res.arity 1])) + [@res.uapp ]); + ((logToAnalytics Shady.ml) + [@res.uapp ])) [@res.braces ]) -let f = ((fun event -> (event.target).value)[@res.braces ]) -let f = ((fun event -> ((event.target).value : string))[@res.braces ]) +let f = ((Function$ (fun event -> (event.target).value)) + [@res.braces ][@res.arity 1]) +let f = ((Function$ (fun event -> ((event.target).value : string))) + [@res.braces ][@res.arity 1]) let x = ((let a = 1 in let b = 2 in a + b)[@res.braces ]) -;;(([(({js|\n|js} |. React.string)[@res.braces ])])[@JSX ]) \ No newline at end of file +;;(([(({js|\n|js} |.u React.string)[@res.braces ])])[@JSX ]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/bsObject.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/bsObject.res.txt index ba0778d0b4..190921ce0a 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/bsObject.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/bsObject.res.txt @@ -7,9 +7,9 @@ let z = [%obj { \xff = 1; \u2212 = {js|two|js}; \0 = zero; \o123 = {js|o123|js} }] let x = (({js|age|js})[@res.braces ]) let x = (({js|age|js}.(0))[@res.braces ]) -let x = (({js|age|js} |. Js.log)[@res.braces ]) +let x = (({js|age|js} |.u Js.log)[@res.braces ]) let x = ((if {js|age|js} then true else false)[@res.braces ][@res.ternary ]) -let x = (({js|age|js} |. Js.log; (let foo = 1 in let bar = 2 in foo + bar)) +let x = (({js|age|js} |.u Js.log; (let foo = 1 in let bar = 2 in foo + bar)) [@res.braces ]) let x = ((((if {js|age|js} then true else false) diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/coerce.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/coerce.res.txt index fd68e3581a..8ad27dde31 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/coerce.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/coerce.res.txt @@ -1,2 +1,2 @@ -let foo (x : int) = (x :> int) -let foo x = ((x : t) :> int) \ No newline at end of file +let foo = ((Function$ (fun (x : int) -> (x :> int)))[@res.arity 1]) +let foo = ((Function$ (fun x -> ((x : t) :> int)))[@res.arity 1]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/constants.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/constants.res.txt index dac7ad468e..f380adfdbd 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/constants.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/constants.res.txt @@ -47,7 +47,7 @@ let x = '\b' let x = '\r' let x = ' ' let x = '\170' -let () = ((getResult (); (-10))[@res.braces ]) +let () = ((((getResult ())[@res.uapp ]); (-10))[@res.braces ]) let x = {js|foo\0bar|js} let x = {js|foo\x0Abar|js} let x = {js|\\abc|js} diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/extension.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/extension.res.txt index 21b88f9fcb..47bfa3d0f5 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/extension.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/extension.res.txt @@ -1,5 +1,6 @@ ;;[%expr ] ;;[%expr.extension ] ;;[%expr.extension.with.args {js|argument|js}] -;;[%expr.extension.with.args fun x -> f x] +;;[%expr.extension.with.args + ((Function$ (fun x -> ((f x)[@res.uapp ])))[@res.arity 1])] let x = ([%raw {js|1|js}]) + ([%raw {js|2|js}]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/firstClassModule.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/firstClassModule.res.txt index 478dfe378c..4f1fcd8934 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/firstClassModule.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/firstClassModule.res.txt @@ -1,8 +1,12 @@ -let makeSet (type s) cmp = - ((let module S = (Set.Make)(struct type nonrec t = s - let compare = cmp end) in ((module - S) : (module Set.S with type elt = s))) - [@res.braces ]) +let makeSet (type s) = + ((Function$ + (fun cmp -> + ((let module S = + (Set.Make)(struct type nonrec t = s + let compare = cmp end) in ((module + S) : (module Set.S with type elt = s))) + [@res.braces ]))) + [@res.arity 1]) let three = ((module Three) : (module X_int)) let numbers = [|three;(module Four)|] let numbers = (three, (module Four)) @@ -10,68 +14,99 @@ let numbers = [three; (module Four)] let numbers = [|three;(module struct let x = 4 end)|] let numbers = (three, (module struct let x = 4 end)) let numbers = [three; (module struct let x = 4 end)] -let plus m1 m2 = ((((module - struct let x = (to_int m1) + (to_int m2) end) : (module X_int))) - [@res.braces ]) -let plus m1 m2 = ((module - struct let x = (to_int m1) + (to_int m2) end) : (module X_int)) +let plus = + ((Function$ + (fun m1 -> + fun m2 -> ((((module + struct + let x = ((to_int m1)[@res.uapp ]) + ((to_int m2)[@res.uapp ]) + end) : (module X_int)))[@res.braces ]))) + [@res.arity 2]) +let plus = + ((Function$ + (fun m1 -> + fun m2 -> ((module + struct + let x = ((to_int m1)[@res.uapp ]) + ((to_int m2)[@res.uapp ]) + end) : (module X_int)))) + [@res.arity 2]) let unique_instance = ((module - struct module Query_handler = Unique - let this = Unique.create 0 end) : (module Query_handler_instance)) -let build_instance (type a) - ((module Q) : (module Query_handler with type config = a)) config = - ((module - struct module Query_handler = Q - let this = Q.create config end) : (module Query_handler_instance)) -let build_instance (type a) - ((module Q) : (module Query_handler with type config = a)) config = - ((((module - struct module Query_handler = Q - let this = Q.create config end) : (module Query_handler_instance))) - [@res.braces ]) -let unique_instance = build_instance (module Unique) 0 -let build_dispatch_table handlers = - ((let table = Hashtbl.create (module String) in - List.iter handlers - ~f:((fun (((module I) : (module Query_handler_instance)) as instance) - -> - Hashtbl.set table ~key:((I.Query_handler.name) - [@res.namedArgLoc ]) ~data:((instance)[@res.namedArgLoc ])) - [@res.namedArgLoc ]) table) - [@res.braces ]) + struct + module Query_handler = Unique + let this = ((Unique.create 0)[@res.uapp ]) + end) : (module Query_handler_instance)) +let build_instance (type a) = + ((Function$ + (fun ((module Q) : (module Query_handler with type config = a)) -> + fun config -> ((module + struct + module Query_handler = Q + let this = ((Q.create config)[@res.uapp ]) + end) : (module Query_handler_instance)))) + [@res.arity 2]) +let build_instance (type a) = + ((Function$ + (fun ((module Q) : (module Query_handler with type config = a)) -> + fun config -> ((((module + struct + module Query_handler = Q + let this = ((Q.create config)[@res.uapp ]) + end) : (module Query_handler_instance)))[@res.braces ]))) + [@res.arity 2]) +let unique_instance = ((build_instance (module Unique) 0)[@res.uapp ]) +let build_dispatch_table = + ((Function$ + (fun handlers -> + ((let table = ((Hashtbl.create (module String))[@res.uapp ]) in + ((List.iter handlers + ~f:((Function$ + (fun + (((module I) : (module Query_handler_instance)) as + instance) + -> + ((Hashtbl.set table ~key:((I.Query_handler.name) + [@res.namedArgLoc ]) ~data:((instance) + [@res.namedArgLoc ])) + [@res.uapp ])))[@res.namedArgLoc ][@res.arity 1]) + table) + [@res.uapp ])) + [@res.braces ]))) + [@res.arity 1]) ;;(module Three) ;;((module Three) : (module X_int)) ;;(module Teenager).(0) -;;((module Teenager) |. age) |. Js.log -;;((module Teenager).(0)) |. Js.log -;;((if ((module Teenager) |. age) |. isAdult - then Js.log {js|has responsibilities|js} - else Js.log {js|can play in the playground|js})[@res.ternary ]) -;;((if ((module Streets).(0)) |. isExpensive - then Js.log {js|big money|js} - else Js.log {js|affordable|js})[@res.ternary ]) -let () = ((((module Teenager) |. age) |. Js.log)[@res.braces ]) +;;((module Teenager) |.u age) |.u Js.log +;;((module Teenager).(0)) |.u Js.log +;;((if ((module Teenager) |.u age) |.u isAdult + then ((Js.log {js|has responsibilities|js})[@res.uapp ]) + else ((Js.log {js|can play in the playground|js})[@res.uapp ])) + [@res.ternary ]) +;;((if ((module Streets).(0)) |.u isExpensive + then ((Js.log {js|big money|js})[@res.uapp ]) + else ((Js.log {js|affordable|js})[@res.uapp ]))[@res.ternary ]) +let () = ((((module Teenager) |.u age) |.u Js.log)[@res.braces ]) let () = (((module Teenager).(0))[@res.braces ]) let () = - ((if ((module Teenager) |. age) |. isAdult - then Js.log {js|has responsibilities|js} - else Js.log {js|can play in the playground|js}) + ((if ((module Teenager) |.u age) |.u isAdult + then ((Js.log {js|has responsibilities|js})[@res.uapp ]) + else ((Js.log {js|can play in the playground|js})[@res.uapp ])) [@res.braces ][@res.ternary ]) let () = - ((if ((module Streets).(0)) |. isExpensive - then Js.log {js|big money|js} - else Js.log {js|affordable|js}) + ((if ((module Streets).(0)) |.u isExpensive + then ((Js.log {js|big money|js})[@res.uapp ]) + else ((Js.log {js|affordable|js})[@res.uapp ])) [@res.braces ][@res.ternary ]) let () = ((let a = 1 in - let b = 2 in (module Teenager).(0); ((module Teenager) |. age) |. Js.log) + let b = 2 in + (module Teenager).(0); ((module Teenager) |.u age) |.u Js.log) [@res.braces ]) let () = ((let a = 1 in let b = 2 in - ((module Teenager) |. age) |. Js.log; - ((if (((module Teenager).(0)) |. age) |. isAdult - then Js.log {js|has responsibilities|js} - else Js.log {js|can play in the playground|js}) + ((module Teenager) |.u age) |.u Js.log; + ((if (((module Teenager).(0)) |.u age) |.u isAdult + then ((Js.log {js|has responsibilities|js})[@res.uapp ]) + else ((Js.log {js|can play in the playground|js})[@res.uapp ])) [@res.ternary ])) [@res.braces ]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/if.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/if.res.txt index da4cf19819..90bbc64541 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/if.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/if.res.txt @@ -1,8 +1,11 @@ ;;if foo then true else false ;;if foo = 2 then let bar = 1 in let foo = 2 in bar + foo -let ifThenElse = if foo then lala else doStuff x y z +let ifThenElse = if foo then lala else ((doStuff x y z)[@res.uapp ]) let ifElseIfThen = if foo = bar - then f () - else if foo = bar2 then f1 () else if foo = bar3 then f2 () else f3 () + then ((f ())[@res.uapp ]) + else + if foo = bar2 + then ((f1 ())[@res.uapp ]) + else if foo = bar3 then ((f2 ())[@res.uapp ]) else ((f3 ())[@res.uapp ]) let x = (if true then 1 else 2) + (if false then 2 else 3) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/infix.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/infix.res.txt index 0d8bbd28c9..a3d446ca1b 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/infix.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/infix.res.txt @@ -1,4 +1,4 @@ -;;a |. (f b) +;;a |.u ((f b)[@res.uapp ]) ;;{js|string1|js} ^ {js|string2|js} ;;a <> b ;;a != b diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/jsx.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/jsx.res.txt index 908cbf768a..6057b97045 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/jsx.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/jsx.res.txt @@ -10,13 +10,13 @@ let _ = ((div ~className:(({js|menu|js})[@res.namedArgLoc ]) ~children:[] ()) [@JSX ]) let _ = ((div ~className:(({js|menu|js})[@res.namedArgLoc ]) - ~onClick:((fun _ -> Js.log {js|click|js}) - [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) + ~onClick:((Function$ (fun _ -> ((Js.log {js|click|js})[@res.uapp ]))) + [@res.namedArgLoc ][@res.braces ][@res.arity 1]) ~children:[] ()) [@JSX ]) let _ = ((div ~className:(({js|menu|js})[@res.namedArgLoc ]) - ~onClick:((fun _ -> Js.log {js|click|js}) - [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) + ~onClick:((Function$ (fun _ -> ((Js.log {js|click|js})[@res.uapp ]))) + [@res.namedArgLoc ][@res.braces ][@res.arity 1]) ~children:[] ()) [@JSX ]) let _ = ((Navbar.createElement ~children:[] ())[@JSX ]) let _ = ((Navbar.createElement ~children:[] ())[@JSX ]) @@ -82,7 +82,9 @@ let _ = [@JSX ])] ()) [@JSX ]) let _ = ((div ~children:child ())[@JSX ]) -let _ = ((Foo.createElement ~children:(fun a -> 1) ())[@JSX ]) +let _ = + ((Foo.createElement ~children:((Function$ (fun a -> 1))[@res.arity 1]) ()) + [@JSX ]) let _ = ((Foo.createElement ~children:((Foo2.createElement ~children:[] ()) [@JSX ]) ()) @@ -91,7 +93,12 @@ let _ = ((Foo.createElement ~children:[|a|] ())[@JSX ]) let _ = ((Foo.createElement ~children:(1, 2) ())[@JSX ]) let _ = ((Foo.createElement ~children:(1, 2) ())[@JSX ]) let _ = - ((div ~children:[ident; [|1;2;3|]; ((call a b)[@res.braces ]); (x.y).z] ()) + ((div + ~children:[ident; + [|1;2;3|]; + ((call a b) + [@res.braces ][@res.uapp ]); + (x.y).z] ()) [@JSX ]) let _ = ((Outer.createElement ~inner:((Inner.createElement ~children:[] ()) @@ -147,28 +154,38 @@ let _ = ((a ~children:[] ())[@JSX ]) < ((b ~children:[] ())[@JSX ]) let _ = ((a ~children:[] ())[@JSX ]) > ((b ~children:[] ())[@JSX ]) let y = ((Routes.createElement ~path:((Routes.stateToPath state) - [@res.namedArgLoc ]) ~isHistorical:((true)[@res.namedArgLoc ]) - ~onHashChange:((fun _oldPath -> - fun _oldUrl -> - fun newUrl -> - updater - (fun latestComponentBag -> - fun _ -> - ((let currentActualPath = - Routes.hashOfUri newUrl in - let pathFromState = - Routes.stateToPath - latestComponentBag.state in - ((if currentActualPath = pathFromState - then None - else - dispatchEventless - (State.UriNavigated - currentActualPath) - latestComponentBag ()) - [@res.ternary ])) - [@res.braces ])) ()) - [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) + [@res.namedArgLoc ][@res.uapp ]) ~isHistorical:((true) + [@res.namedArgLoc ]) + ~onHashChange:((Function$ + (fun _oldPath -> + fun _oldUrl -> + fun newUrl -> + ((updater + ((Function$ + (fun latestComponentBag -> + fun _ -> + ((let currentActualPath = + ((Routes.hashOfUri newUrl) + [@res.uapp ]) in + let pathFromState = + ((Routes.stateToPath + latestComponentBag.state) + [@res.uapp ]) in + ((if + currentActualPath = + pathFromState + then None + else + ((dispatchEventless + (State.UriNavigated + currentActualPath) + latestComponentBag ()) + [@res.uapp ])) + [@res.ternary ])) + [@res.braces ])))[@res.arity 2]) + ()) + [@res.uapp ]))) + [@res.namedArgLoc ][@res.braces ][@res.arity 3]) ~children:[] ()) [@JSX ]) let z = ((div @@ -180,8 +197,8 @@ let z = [@res.namedArgLoc ]) ~borderColor:((borderColor) [@res.namedArgLoc ]) ~someOtherAttribute:((someOtherAttribute) - [@res.namedArgLoc ]) ())[@res.namedArgLoc ]) - ~key:((string_of_int 1)[@res.namedArgLoc ]) ~children:[] ()) + [@res.namedArgLoc ]) ())[@res.namedArgLoc ][@res.uapp ]) + ~key:((string_of_int 1)[@res.namedArgLoc ][@res.uapp ]) ~children:[] ()) [@JSX ]) let omega = ((div @@ -194,20 +211,20 @@ let omega = border; borderColor; someOtherAttribute])[@res.namedArgLoc ]) - ~key:((string_of_int 1)[@res.namedArgLoc ]) ~children:[] ()) + ~key:((string_of_int 1)[@res.namedArgLoc ][@res.uapp ]) ~children:[] ()) [@JSX ]) let someArray = ((div ~anArray:(([|width;height;color;backgroundColor;margin;padding;border;borderColor;someOtherAttribute|]) - [@res.namedArgLoc ]) ~key:((string_of_int 1)[@res.namedArgLoc ]) - ~children:[] ()) + [@res.namedArgLoc ]) ~key:((string_of_int 1) + [@res.namedArgLoc ][@res.uapp ]) ~children:[] ()) [@JSX ]) let tuples = ((div ~aTuple:(((width, height, color, backgroundColor, margin, padding, border, borderColor, someOtherAttribute, definitelyBreakere))[@res.namedArgLoc ]) - ~key:((string_of_int 1)[@res.namedArgLoc ]) ~children:[] ()) + ~key:((string_of_int 1)[@res.namedArgLoc ][@res.uapp ]) ~children:[] ()) [@JSX ]) let icon = ((Icon.createElement @@ -221,7 +238,7 @@ let icon = let _ = ((MessengerSharedPhotosAlbumViewPhotoReact.createElement ?ref:((if foo#bar == baz - then Some (foooooooooooooooooooooooo setRefChild) + then Some ((foooooooooooooooooooooooo setRefChild)[@res.uapp ]) else None)[@res.namedArgLoc ][@res.ternary ]) ~key:((node#legacy_attachment_id)[@res.namedArgLoc ]) ~children:[] ()) [@JSX ]) @@ -261,12 +278,13 @@ let _ = ((Description.createElement ~term:((Text.createElement ~text:(({js|Age|js})[@res.namedArgLoc ]) ~children:(([||])[@res.namedArgLoc ]) ()) - [@res.namedArgLoc ][@res.braces ]) ~children:[child] ()) + [@res.namedArgLoc ][@res.braces ][@res.uapp ]) ~children:[child] ()) [@JSX ]) let _ = ((Description.createElement ~term:((Text.createElement ~text:(({js|Age|js})[@res.namedArgLoc ]) ()) - [@res.namedArgLoc ][@res.braces ][@JSX ]) ~children:[child] ()) + [@res.namedArgLoc ][@res.braces ][@JSX ][@res.uapp ]) ~children: + [child] ()) [@JSX ]) let _ = ((Description.createElement @@ -286,7 +304,9 @@ let _ = [@res.namedArgLoc ][@res.braces ][@JSX ]) ~children:[] ()) [@JSX ]) let _ = - ((div ~children:[((span ~children:[str {js|hello|js}] ())[@JSX ])] ()) + ((div + ~children:[((span ~children:[((str {js|hello|js})[@res.uapp ])] ()) + [@JSX ])] ()) [@JSX ]) let _ = ((description @@ -297,17 +317,19 @@ let _ = ((description ~term:((text ~text:(({js|Age|js})[@res.namedArgLoc ]) ~children:(( [||])[@res.namedArgLoc ]) ()) - [@res.namedArgLoc ][@res.braces ]) ~children:[child] ()) + [@res.namedArgLoc ][@res.braces ][@res.uapp ]) ~children:[child] ()) [@JSX ]) let _ = ((description ~term:((text ~text:(({js|Age|js})[@res.namedArgLoc ]) ~children:(( [||])[@res.namedArgLoc ])) - [@res.namedArgLoc ][@res.braces ][@JSX ]) ~children:[child] ()) + [@res.namedArgLoc ][@res.braces ][@JSX ][@res.uapp ]) ~children: + [child] ()) [@JSX ]) let _ = ((description ~term:((text ~text:(({js|Age|js})[@res.namedArgLoc ]) ()) - [@res.namedArgLoc ][@res.braces ][@JSX ]) ~children:[child] ()) + [@res.namedArgLoc ][@res.braces ][@JSX ][@res.uapp ]) ~children: + [child] ()) [@JSX ]) let _ = ((description @@ -319,86 +341,122 @@ let _ = ~children:[child] ()) [@JSX ]) let _ = - ((div ~onClick:((fun event -> handleChange event) - [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) + ((div + ~onClick:((Function$ (fun event -> ((handleChange event)[@res.uapp ]))) + [@res.namedArgLoc ][@res.braces ][@res.arity 1]) ~children:[] ()) [@JSX ]) let _ = - ((div ~onClick:((fun eventWithLongIdent -> handleChange eventWithLongIdent) - [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) + ((div + ~onClick:((Function$ + (fun eventWithLongIdent -> + ((handleChange eventWithLongIdent)[@res.uapp ]))) + [@res.namedArgLoc ][@res.braces ][@res.arity 1]) ~children:[] ()) [@JSX ]) let _ = ((div - ~onClick:((fun event -> ((Js.log event; handleChange event) - [@res.braces ]))[@res.namedArgLoc ][@res.braces ]) - ~children:[] ()) + ~onClick:((Function$ + (fun event -> + ((((Js.log event) + [@res.uapp ]); + ((handleChange event) + [@res.uapp ])) + [@res.braces ]))) + [@res.namedArgLoc ][@res.braces ][@res.arity 1]) ~children:[] ()) [@JSX ]) let _ = ((StaticDiv.createElement - ~onClick:((fun foo -> - fun bar -> - fun baz -> - fun lineBreak -> - fun identifier -> - ((doStuff foo bar baz; bar lineBreak identifier) - [@res.braces ]))[@res.namedArgLoc ][@res.braces ]) - ~children:[] ()) + ~onClick:((Function$ + (fun foo -> + fun bar -> + fun baz -> + fun lineBreak -> + fun identifier -> + ((((doStuff foo bar baz) + [@res.uapp ]); + ((bar lineBreak identifier) + [@res.uapp ])) + [@res.braces ]))) + [@res.namedArgLoc ][@res.braces ][@res.arity 5]) ~children:[] ()) [@JSX ]) let _ = - ((AttrDiv.createElement ~onClick:((fun event -> handleChange event) - [@res.namedArgLoc ][@res.braces ][@bar ]) ~children:[] ()) + ((AttrDiv.createElement + ~onClick:((Function$ (fun event -> ((handleChange event)[@res.uapp ]))) + [@res.namedArgLoc ][@res.braces ][@bar ][@res.arity 1]) ~children:[] ()) [@JSX ]) let _ = ((AttrDiv.createElement - ~onClick:((fun eventLongIdentifier -> handleChange eventLongIdentifier) - [@res.namedArgLoc ][@res.braces ][@bar ]) ~children:[] ()) + ~onClick:((Function$ + (fun eventLongIdentifier -> + ((handleChange eventLongIdentifier)[@res.uapp ]))) + [@res.namedArgLoc ][@res.braces ][@bar ][@res.arity 1]) ~children:[] ()) [@JSX ]) let _ = ((StaticDivNamed.createElement - ~onClick:((fun ~foo:((foo)[@res.namedArgLoc ]) -> - fun ~bar:((bar)[@res.namedArgLoc ]) -> - fun ~baz:((baz)[@res.namedArgLoc ]) -> - fun ~lineBreak:((lineBreak)[@res.namedArgLoc ]) -> - fun ~identifier:((identifier)[@res.namedArgLoc ]) -> - fun () -> bar lineBreak identifier) - [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) + ~onClick:((Function$ + (fun ~foo:((foo)[@res.namedArgLoc ]) -> + fun ~bar:((bar)[@res.namedArgLoc ]) -> + fun ~baz:((baz)[@res.namedArgLoc ]) -> + fun ~lineBreak:((lineBreak)[@res.namedArgLoc ]) -> + fun ~identifier:((identifier)[@res.namedArgLoc ]) + -> + fun () -> ((bar lineBreak identifier) + [@res.uapp ]))) + [@res.namedArgLoc ][@res.braces ][@res.arity 6]) ~children:[] ()) [@JSX ]) let _ = - ((div ~onClick:((fun e -> (((doStuff (); bar foo)[@res.braces ]) : event)) - [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) + ((div + ~onClick:((Function$ + (fun e -> + (((((doStuff ())[@res.uapp ]); ((bar foo)[@res.uapp ])) + [@res.braces ]) : event))) + [@res.namedArgLoc ][@res.braces ][@res.arity 1]) ~children:[] ()) [@JSX ]) let _ = ((div - ~onClick:((fun e -> - fun e2 -> (((doStuff (); bar foo)[@res.braces ]) : event)) - [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) + ~onClick:((Function$ + (fun e -> + fun e2 -> + (((((doStuff ()) + [@res.uapp ]); + ((bar foo) + [@res.uapp ])) + [@res.braces ]) : event))) + [@res.namedArgLoc ][@res.braces ][@res.arity 2]) ~children:[] ()) [@JSX ]) let _ = ((div - ~onClick:((fun foo -> - fun bar -> - fun baz -> - fun superLongIdent -> - fun breakLine -> (((doStuff (); bar foo) - [@res.braces ]) : (event * event2 * event3 * - event4 * event5))) - [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) + ~onClick:((Function$ + (fun foo -> + fun bar -> + fun baz -> + fun superLongIdent -> + fun breakLine -> + (((((doStuff ()) + [@res.uapp ]); + ((bar foo) + [@res.uapp ])) + [@res.braces ]) : (event * event2 * event3 * + event4 * event5)))) + [@res.namedArgLoc ][@res.braces ][@res.arity 5]) ~children:[] ()) [@JSX ]) let _ = ((div - ~onClick:((fun foo -> - fun bar -> - fun baz -> - fun superLongIdent -> - fun breakLine -> - (doStuff () : (event * event2 * event3 * event4 * - event5))) - [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) + ~onClick:((Function$ + (fun foo -> + fun bar -> + fun baz -> + fun superLongIdent -> + fun breakLine -> (((doStuff ()) + [@res.uapp ]) : (event * event2 * event3 * + event4 * event5)))) + [@res.namedArgLoc ][@res.braces ][@res.arity 5]) ~children:[] ()) [@JSX ]) let _ = ((div ~children:[(((match color with - | Black -> ReasonReact.string {js|black|js} - | Red -> ReasonReact.string {js|red|js})) + | Black -> ((ReasonReact.string {js|black|js}) + [@res.uapp ]) + | Red -> ((ReasonReact.string {js|red|js})[@res.uapp ]))) [@res.braces ])] ()) [@JSX ]) let _ = @@ -408,7 +466,7 @@ let _ = [@res.namedArgLoc ]) ~borderRadius:(({js|100%|js}) [@res.namedArgLoc ]) ~backgroundColor:(({js|red|js}) [@res.namedArgLoc ])) - [@res.namedArgLoc ][@res.braces ][@foo ]) ~children:[] ()) + [@res.namedArgLoc ][@res.braces ][@foo ][@res.uapp ]) ~children:[] ()) [@JSX ]) let _ = ((Animated.createElement ~initialValue:((0.0)[@res.namedArgLoc ]) @@ -417,120 +475,134 @@ let _ = [@res.namedArgLoc ]) ~height:(({js|20px|js}) [@res.namedArgLoc ]) ~borderRadius:(({js|100%|js}) [@res.namedArgLoc ]) ~backgroundColor:(({js|red|js}) - [@res.namedArgLoc ]))[@res.braces ]) ()) + [@res.namedArgLoc ]))[@res.braces ][@res.uapp ]) ()) [@JSX ]) let _ = ((Animated.createElement ~initialValue:((0.0)[@res.namedArgLoc ]) ~value:((value)[@res.namedArgLoc ]) - ~children:((fun value -> - ((div - ~style:((ReactDOMRe.Style.make ~width:(({js|20px|js}) - [@res.namedArgLoc ]) - ~height:(({js|20px|js}) - [@res.namedArgLoc ]) - ~borderRadius:(({js|100%|js}) - [@res.namedArgLoc ]) - ~backgroundColor:(({js|red|js}) - [@res.namedArgLoc ])) - [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) - [@JSX ]))[@res.braces ]) ()) + ~children:((Function$ + (fun value -> + ((div + ~style:((ReactDOMRe.Style.make + ~width:(({js|20px|js}) + [@res.namedArgLoc ]) + ~height:(({js|20px|js}) + [@res.namedArgLoc ]) + ~borderRadius:(({js|100%|js}) + [@res.namedArgLoc ]) + ~backgroundColor:(({js|red|js}) + [@res.namedArgLoc ])) + [@res.namedArgLoc ][@res.braces ][@res.uapp ]) + ~children:[] ()) + [@JSX ])))[@res.braces ][@res.arity 1]) ()) [@JSX ]) let _ = ((Animated.createElement ~initialValue:((0.0)[@res.namedArgLoc ]) ~value:((value)[@res.namedArgLoc ]) - ~children:((fun value -> - (((div - ~style:((ReactDOMRe.Style.make - ~width:(({js|20px|js}) - [@res.namedArgLoc ]) - ~height:(({js|20px|js}) - [@res.namedArgLoc ]) - ~borderRadius:(({js|100%|js}) - [@res.namedArgLoc ]) - ~backgroundColor:(({js|red|js}) - [@res.namedArgLoc ])) - [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) - [@JSX ]) : ReasonReact.element))[@res.braces ]) ()) + ~children:((Function$ + (fun value -> + (((div + ~style:((ReactDOMRe.Style.make + ~width:(({js|20px|js}) + [@res.namedArgLoc ]) + ~height:(({js|20px|js}) + [@res.namedArgLoc ]) + ~borderRadius:(({js|100%|js}) + [@res.namedArgLoc ]) + ~backgroundColor:(({js|red|js}) + [@res.namedArgLoc ])) + [@res.namedArgLoc ][@res.braces ][@res.uapp ]) + ~children:[] ()) + [@JSX ]) : ReasonReact.element))) + [@res.braces ][@res.arity 1]) ()) [@JSX ]) let _ = ((Animated.createElement ~initialValue:((0.0)[@res.namedArgLoc ]) ~value:((value)[@res.namedArgLoc ]) - ~children:((fun value -> - ((div - ~style:((ReactDOMRe.Style.make ~width:(({js|20px|js}) - [@res.namedArgLoc ]) - ~height:(({js|20px|js}) - [@res.namedArgLoc ]) - ~borderRadius:(({js|100%|js}) - [@res.namedArgLoc ]) - ~backgroundColor:(({js|red|js}) - [@res.namedArgLoc ])) - [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) - [@res.braces ][@JSX ]))[@res.braces ][@foo ]) ()) + ~children:((Function$ + (fun value -> + ((div + ~style:((ReactDOMRe.Style.make + ~width:(({js|20px|js}) + [@res.namedArgLoc ]) + ~height:(({js|20px|js}) + [@res.namedArgLoc ]) + ~borderRadius:(({js|100%|js}) + [@res.namedArgLoc ]) + ~backgroundColor:(({js|red|js}) + [@res.namedArgLoc ])) + [@res.namedArgLoc ][@res.braces ][@res.uapp ]) + ~children:[] ()) + [@res.braces ][@JSX ]))) + [@res.braces ][@foo ][@res.arity 1]) ()) [@JSX ]) let _ = ((Animated.createElement ~initialValue:((0.0)[@res.namedArgLoc ]) ~value:((value)[@res.namedArgLoc ]) - ~children:((fun value -> - ((let width = {js|20px|js} in - let height = {js|20px|js} in - ((div - ~style:((ReactDOMRe.Style.make ~width:((width) - [@res.namedArgLoc ]) ~height:((height) - [@res.namedArgLoc ]) - ~borderRadius:(({js|100%|js}) - [@res.namedArgLoc ]) - ~backgroundColor:(({js|red|js}) - [@res.namedArgLoc ])) - [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) - [@JSX ])) - [@res.braces ]))[@res.braces ]) ()) - [@JSX ]) -let _ = - ((div ~callback:((reduce (fun () -> not state)) - [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) + ~children:((Function$ + (fun value -> + ((let width = {js|20px|js} in + let height = {js|20px|js} in + ((div + ~style:((ReactDOMRe.Style.make ~width:((width) + [@res.namedArgLoc ]) + ~height:((height)[@res.namedArgLoc ]) + ~borderRadius:(({js|100%|js}) + [@res.namedArgLoc ]) + ~backgroundColor:(({js|red|js}) + [@res.namedArgLoc ])) + [@res.namedArgLoc ][@res.braces ][@res.uapp ]) + ~children:[] ()) + [@JSX ])) + [@res.braces ])))[@res.braces ][@res.arity 1]) ()) + [@JSX ]) +let _ = + ((div ~callback:((reduce ((Function$ (fun () -> not state))[@res.arity 1])) + [@res.namedArgLoc ][@res.braces ][@res.uapp ]) ~children:[] ()) [@JSX ]) let _ = ((button ?id:((id)[@res.namedArgLoc ]) ~className:((Cn.make [|{js|button|js};{js|is-fullwidth|js}|]) - [@res.namedArgLoc ][@res.braces ]) ~onClick:((onClick) + [@res.namedArgLoc ][@res.braces ][@res.uapp ]) ~onClick:((onClick) [@res.namedArgLoc ]) - ~children:[(({js|Submit|js} |> ste)[@res.braces ])] ()) + ~children:[((ste {js|Submit|js})[@res.braces ][@res.uapp ])] ()) [@JSX ]) let _ = ((button ?id:((id)[@res.namedArgLoc ]) ~className:((Cn.make [{js|button|js}; {js|is-fullwidth|js}]) - [@res.namedArgLoc ][@res.braces ]) ~onClick:((onClick) + [@res.namedArgLoc ][@res.braces ][@res.uapp ]) ~onClick:((onClick) [@res.namedArgLoc ]) - ~children:[(({js|Submit|js} |> ste)[@res.braces ])] ()) + ~children:[((ste {js|Submit|js})[@res.braces ][@res.uapp ])] ()) [@JSX ]) let _ = ((button ?id:((id)[@res.namedArgLoc ]) ~className:((Cn.make ({js|button|js}, {js|is-fullwidth|js})) - [@res.namedArgLoc ][@res.braces ]) ~onClick:((onClick) + [@res.namedArgLoc ][@res.braces ][@res.uapp ]) ~onClick:((onClick) [@res.namedArgLoc ]) - ~children:[(({js|Submit|js} |> ste)[@res.braces ])] ()) + ~children:[((ste {js|Submit|js})[@res.braces ][@res.uapp ])] ()) [@JSX ]) let _ = ((button ?id:((id)[@res.namedArgLoc ]) ~className:((Cn.make { a = b }) - [@res.namedArgLoc ][@res.braces ]) ~onClick:((onClick) + [@res.namedArgLoc ][@res.braces ][@res.uapp ]) ~onClick:((onClick) [@res.namedArgLoc ]) - ~children:[(({js|Submit|js} |> ste)[@res.braces ])] ()) + ~children:[((ste {js|Submit|js})[@res.braces ][@res.uapp ])] ()) [@JSX ]) let _ = - ((X.createElement ~y:((z |. (Belt.Option.getWithDefault {js||js})) + ((X.createElement + ~y:((z |.u ((Belt.Option.getWithDefault {js||js})[@res.uapp ])) [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) [@JSX ]) let _ = - ((div ~style:((getStyle ())[@res.namedArgLoc ][@res.braces ]) - ~children:[((ReasonReact.string {js|BugTest|js})[@res.braces ])] ()) + ((div ~style:((getStyle ())[@res.namedArgLoc ][@res.braces ][@res.uapp ]) + ~children:[((ReasonReact.string {js|BugTest|js}) + [@res.braces ][@res.uapp ])] ()) [@JSX ]) let _ = ((div - ~children:[(((let left = limit |. Int.toString in + ~children:[(((let left = limit |.u Int.toString in (((((({js||js})[@res.template ]) ^ left)[@res.template ]) ^ (({js| characters left|js})[@res.template ])) - [@res.template ]) |. React.string)) + [@res.template ]) |.u React.string)) [@res.braces ])] ()) [@JSX ]) let _ = @@ -545,48 +617,62 @@ let _ = [@res.braces ])] ()) [@JSX ]) ;;((div - ~children:[(((((possibleGradeValues |> - (List.filter (fun g -> g <= state.maxGrade))) - |> - (List.map - (fun possibleGradeValue -> - ((option - ~key:((possibleGradeValue |> string_of_int) - [@res.namedArgLoc ][@res.braces ]) - ~value:((possibleGradeValue |> string_of_int) - [@res.namedArgLoc ][@res.braces ]) - ~children:[(((possibleGradeValue |> - string_of_int) - |> str) - [@res.braces ])] ()) - [@JSX ])))) - |> Array.of_list) - |> ReasonReact.array) - [@res.braces ])] ())[@JSX ]) -;;((div ~children:[((Js.log (a <= 10))[@res.braces ])] ())[@JSX ]) + ~children:[((ReasonReact.array + ((Array.of_list + ((List.map + ((Function$ + (fun possibleGradeValue -> + ((option + ~key:((string_of_int + possibleGradeValue) + [@res.namedArgLoc ][@res.braces ] + [@res.uapp ]) + ~value:((string_of_int + possibleGradeValue) + [@res.namedArgLoc ][@res.braces ] + [@res.uapp ]) + ~children:[((str + ((string_of_int + possibleGradeValue) + [@res.uapp ])) + [@res.braces ][@res.uapp ])] + ()) + [@JSX ])))[@res.arity 1]) + ((List.filter + ((Function$ (fun g -> g <= state.maxGrade)) + [@res.arity 1]) possibleGradeValues) + [@res.uapp ]))[@res.uapp ]))[@res.uapp ])) + [@res.braces ][@res.uapp ])] ())[@JSX ]) +;;((div ~children:[((Js.log (a <= 10))[@res.braces ][@res.uapp ])] ()) + [@JSX ]) ;;((div - ~children:[((div ~children:[((Js.log (a <= 10))[@res.braces ])] ()) + ~children:[((div + ~children:[((Js.log (a <= 10)) + [@res.braces ][@res.uapp ])] ()) [@JSX ])] ())[@JSX ]) ;;((div - ~children:[((div ~onClick:((fun _ -> Js.log (a <= 10)) - [@res.namedArgLoc ][@res.braces ]) + ~children:[((div + ~onClick:((Function$ + (fun _ -> ((Js.log (a <= 10))[@res.uapp ]))) + [@res.namedArgLoc ][@res.braces ][@res.arity 1]) ~children:[((div ~children:[((Js.log (a <= 10)) - [@res.braces ])] ()) + [@res.braces ][@res.uapp ])] ()) [@JSX ])] ()) [@JSX ])] ())[@JSX ]) ;;((div ~children:element ())[@JSX ]) -;;((div ~children:((fun a -> 1)[@res.braces ]) ())[@JSX ]) +;;((div ~children:((Function$ (fun a -> 1))[@res.braces ][@res.arity 1]) ()) + [@JSX ]) ;;((div ~children:((span ~children:[] ())[@JSX ]) ())[@JSX ]) ;;((div ~children:[|a|] ())[@JSX ]) ;;((div ~children:(1, 2) ())[@JSX ]) -;;((div ~children:((array |. f)[@res.braces ]) ())[@JSX ]) +;;((div ~children:((array |.u f)[@res.braces ]) ())[@JSX ]) ;;(([element])[@JSX ]) -;;(([(((fun a -> 1))[@res.braces ])])[@JSX ]) +;;(([((Function$ ((fun a -> 1)))[@res.braces ][@res.arity 1])])[@JSX ]) ;;(([((span ~children:[] ())[@JSX ])])[@JSX ]) ;;(([[|a|]])[@JSX ]) ;;(([(1, 2)])[@JSX ]) -;;(([((array |. f)[@res.braces ])])[@JSX ]) +;;(([((array |.u f)[@res.braces ])])[@JSX ]) let _ = ((A.createElement ~x:(({js|y|js})[@res.namedArgLoc ]) ~_spreadProps:((str) [@res.namedArgLoc ]) ~children:[] ()) diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/locallyAbstractTypes.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/locallyAbstractTypes.res.txt index 836a783b3e..95bad3fb60 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/locallyAbstractTypes.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/locallyAbstractTypes.res.txt @@ -1,18 +1,29 @@ -let f (type t) (xs : t list) = () -let f (type t) (xs : t list) (type s) (ys : s list) = () -let f (type t) (type u) (type v) (xs : (t * u * v) list) = () -let f (type t) (type u) (type v) (xs : (t * u * v) list) (type s) (type w) - (type z) (ys : (s * w * z) list) = () +let f (type t) = ((Function$ (fun (xs : t list) -> ()))[@res.arity 1]) +let f (type t) = + ((Function$ (fun (xs : t list) -> fun (type s) -> fun (ys : s list) -> ())) + [@res.arity 2]) +let f (type t) (type u) (type v) = + ((Function$ (fun (xs : (t * u * v) list) -> ()))[@res.arity 1]) +let f (type t) (type u) (type v) = + ((Function$ + (fun (xs : (t * u * v) list) -> fun (type s) -> fun (type w) -> fun + (type z) -> fun (ys : (s * w * z) list) -> ())) + [@res.arity 2]) let f = ((fun (type t) -> fun (type u) -> fun (type v) -> - fun (xs : (t * u * v) list) -> ((fun (type s) -> fun (type w) -> fun (type - z) -> fun (ys : (s * w * z) list) -> ())[@attr2 ])) - [@attr ]) + ((Function$ + (fun (xs : (t * u * v) list) -> ((fun (type s) -> fun (type w) -> fun + (type z) -> fun (ys : (s * w * z) list) -> ())[@attr2 ]))) + [@res.arity 2]))[@attr ]) let f = ((fun (type t) -> ((fun (type s) -> - fun (xs : (t * s) list) -> ((fun (type u) -> ((fun (type v) -> fun (type w) - -> fun (ys : (u * v * w) list) -> ())[@attr ]))[@attr ])) - [@attr ]))[@attr ]) + ((Function$ + (fun (xs : (t * s) list) -> ((fun (type u) -> ((fun (type v) -> fun + (type w) -> fun (ys : (u * v * w) list) -> ())[@attr ]))[@attr ]))) + [@res.arity 2]))[@attr ]))[@attr ]) let cancel_and_collect_callbacks : 'a 'u 'c . - packed_callbacks list -> ('a, 'u, 'c) promise -> packed_callbacks list + (packed_callbacks list -> ('a, 'u, 'c) promise -> packed_callbacks list, + [ `Has_arity2 ]) function$ = fun (type x) -> - fun callbacks_accumulator -> fun (p : (_, _, c) promise) -> () \ No newline at end of file + ((Function$ + (fun callbacks_accumulator -> fun (p : (_, _, c) promise) -> ())) + [@res.arity 2]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/parenthesized.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/parenthesized.res.txt index 9507c0cfe4..572279a4cb 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/parenthesized.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/parenthesized.res.txt @@ -19,8 +19,9 @@ let assertSmthing = assert true let jsx = ((div ~className:(({js|cx|js})[@res.namedArgLoc ]) ~children:[foo] ()) [@JSX ]) -let ifExpr = if true then Js.log true else Js.log false +let ifExpr = + if true then ((Js.log true)[@res.uapp ]) else ((Js.log false)[@res.uapp ]) let forExpr = for p = 0 to 10 do () done -let whileExpr = while true do doSomeImperativeThing () done +let whileExpr = while true do ((doSomeImperativeThing ())[@res.uapp ]) done let switchExpr = match myVar with | Blue -> {js|blue|js} | Red -> {js|red|js} let constrainedExpr = (x : int) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/primary.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/primary.res.txt index f7aabdd001..f4979d060d 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/primary.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/primary.res.txt @@ -10,23 +10,24 @@ let x = arr.((x : int)) let x = (arr.(0)).(1) let x = (arr.((x : int))).((y : int)) ;;arr.(0) <- (a + b) -;;f () -;;(f ()) () -;;f a -;;(f a) a -;;f a -;;f (x : int) -;;f a b c -;;f a b c -;;f ~a:((a)[@res.namedArgLoc ]) ~b:((bArg)[@res.namedArgLoc ]) ?c:((c) - [@res.namedArgLoc ]) ?d:((expr)[@res.namedArgLoc ]) +;;((f ())[@res.uapp ]) +;;((((f ())[@res.uapp ]) ())[@res.uapp ]) +;;((f a)[@res.uapp ]) +;;((((f a)[@res.uapp ]) a)[@res.uapp ]) +;;((f a)[@res.uapp ]) +;;((f (x : int))[@res.uapp ]) +;;((f a b c)[@res.uapp ]) +;;((f a b c)[@res.uapp ]) ;;((f ~a:((a)[@res.namedArgLoc ]) ~b:((bArg)[@res.namedArgLoc ]) ?c:((c) - [@res.namedArgLoc ]) ?d:((expr)[@res.namedArgLoc ])) ~a:((a) - [@res.namedArgLoc ]) ~b:((bArg)[@res.namedArgLoc ]) ?c:((c) - [@res.namedArgLoc ]) ?d:((expr)[@res.namedArgLoc ])) ~a:((a) - [@res.namedArgLoc ]) ~b:((bArg)[@res.namedArgLoc ]) ?c:((c) - [@res.namedArgLoc ]) ?d:((expr)[@res.namedArgLoc ]) -;;f ~a:(((x : int))[@res.namedArgLoc ]) ?b:(((y : int))[@res.namedArgLoc ]) + [@res.namedArgLoc ]) ?d:((expr)[@res.namedArgLoc ]))[@res.uapp ]) +;;((((((f ~a:((a)[@res.namedArgLoc ]) ~b:((bArg)[@res.namedArgLoc ]) ?c:((c) + [@res.namedArgLoc ]) ?d:((expr)[@res.namedArgLoc ]))[@res.uapp ]) + ~a:((a)[@res.namedArgLoc ]) ~b:((bArg)[@res.namedArgLoc ]) ?c:((c) + [@res.namedArgLoc ]) ?d:((expr)[@res.namedArgLoc ]))[@res.uapp ]) + ~a:((a)[@res.namedArgLoc ]) ~b:((bArg)[@res.namedArgLoc ]) ?c:((c) + [@res.namedArgLoc ]) ?d:((expr)[@res.namedArgLoc ]))[@res.uapp ]) +;;((f ~a:(((x : int))[@res.namedArgLoc ]) ?b:(((y : int))[@res.namedArgLoc ])) + [@res.uapp ]) ;;connection#platformId ;;((connection#left)#account)#accountName ;;john#age #= 99 diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/record.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/record.res.txt index a15646a13d..fd2790aa77 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/record.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/record.res.txt @@ -10,18 +10,22 @@ let r = { a = (expr : int); b = (x : string) } let r = { expr with pexp_attributes = [||] } let r = { expr with pexp_attributes = [||]; pexp_loc = loc } let r = { expr with pexp_attributes = [||] } -let r = { (make () : myRecord) with foo = bar } -let r = { (make () : myRecord) with foo = bar } +let r = { (((make ())[@res.uapp ]) : myRecord) with foo = bar } +let r = { (((make ())[@res.uapp ]) : myRecord) with foo = bar } let r = { x = ((None)[@res.optional ]); y = ((None)[@res.optional ]); z = (((None : tt))[@res.optional ]) } -let z name = { name = ((name)[@res.optional ]); x = 3 } -let z name = { name = ((name)[@res.optional ]); x = 3 } -let z name = { name; x = ((x)[@res.optional ]) } -let zz name = { name; x = ((x)[@res.optional ]) } +let z = ((Function$ (fun name -> { name = ((name)[@res.optional ]); x = 3 })) + [@res.arity 1]) +let z = ((Function$ (fun name -> { name = ((name)[@res.optional ]); x = 3 })) + [@res.arity 1]) +let z = ((Function$ (fun name -> { name; x = ((x)[@res.optional ]) })) + [@res.arity 1]) +let zz = ((Function$ (fun name -> { name; x = ((x)[@res.optional ]) })) + [@res.arity 1]) let _ = match z with | { x = ((None)[@res.optional ]); y = ((None)[@res.optional ]); diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/sideEffects.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/sideEffects.res.txt index aaa9b7ee2a..690fd9e973 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/sideEffects.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/sideEffects.res.txt @@ -1,13 +1,27 @@ -;;foo () -;;bar () -let () = ((foo (); bar ())[@res.braces ]) +;;((foo ())[@res.uapp ]) +;;((bar ())[@res.uapp ]) +let () = ((((foo ())[@res.uapp ]); ((bar ())[@res.uapp ]))[@res.braces ]) let () = ((let x = 1 in - sideEffect (); - (let y = 2 in sideEffect2 (); (let z = 3 in sideEffect3 ()))) + ((sideEffect ()) + [@res.uapp ]); + (let y = 2 in + ((sideEffect2 ()) + [@res.uapp ]); + (let z = 3 in ((sideEffect3 ())[@res.uapp ])))) [@res.braces ]) ;;while true do - sideEffect1 (); - (let x = 1 in sideEffect2 (); (let y = 2 in sideEffect3 ())) done + ((sideEffect1 ()) + [@res.uapp ]); + (let x = 1 in + ((sideEffect2 ()) + [@res.uapp ]); + (let y = 2 in ((sideEffect3 ())[@res.uapp ]))) + done ;;match color with - | Blue -> (getResult (); sideEffect (); (let x = 1 in sideEffect2 ())) \ No newline at end of file + | Blue -> + (((getResult ()) + [@res.uapp ]); + ((sideEffect ()) + [@res.uapp ]); + (let x = 1 in ((sideEffect2 ())[@res.uapp ]))) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/switch.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/switch.res.txt index 520fe4fb01..abc17296f1 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/switch.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/switch.res.txt @@ -5,7 +5,7 @@ ;;match person1 with | Teacher _ -> () | Student { reportCard = { gpa } } when gpa < 0.5 -> - Js.log {js|What's happening|js} + ((Js.log {js|What's happening|js})[@res.uapp ]) | Student { reportCard = { gpa } } when gpa > 0.9 -> - Js.log {js|Take more free time, you study too much.|js} - | Student _ -> Js.log {js|Heyo|js} \ No newline at end of file + ((Js.log {js|Take more free time, you study too much.|js})[@res.uapp ]) + | Student _ -> ((Js.log {js|Heyo|js})[@res.uapp ]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/try.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/try.res.txt index 5516982c57..c941bc5db9 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/try.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/try.res.txt @@ -1,6 +1,10 @@ -;;try ((let x = 1 in let y = 2 in dangerousCall (x + y))[@res.braces ]) - with | Foo -> Js.log {js|catched Foo|js} - | Exit -> Js.log {js|catched exit|js} -;;try myDangerousFn () with | Foo -> Js.log {js|catched Foo|js}[@@attr ] -let x = ((let y = 1 in try ((apply y)[@res.braces ]) with | _ -> 2) +;;try + ((let x = 1 in let y = 2 in ((dangerousCall (x + y))[@res.uapp ])) + [@res.braces ]) + with | Foo -> ((Js.log {js|catched Foo|js})[@res.uapp ]) + | Exit -> ((Js.log {js|catched exit|js})[@res.uapp ]) +;;try ((myDangerousFn ())[@res.uapp ]) + with | Foo -> ((Js.log {js|catched Foo|js})[@res.uapp ])[@@attr ] +let x = + ((let y = 1 in try ((apply y)[@res.braces ][@res.uapp ]) with | _ -> 2) [@res.braces ]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/tupleVsDivision.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/tupleVsDivision.res.txt index 190198826e..d3dc173f3e 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/tupleVsDivision.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/tupleVsDivision.res.txt @@ -1,4 +1,12 @@ -;;(foo ()) / 1 -;;foo () -;;(1, 2) |. printTuple -let f () = (((foo ()) / 1; foo (); (1, 2) |. printTuple)[@res.braces ]) \ No newline at end of file +;;((foo ())[@res.uapp ]) / 1 +;;((foo ())[@res.uapp ]) +;;(1, 2) |.u printTuple +let f = + ((Function$ + (fun () -> + ((((foo ())[@res.uapp ]) / 1; + ((foo ()) + [@res.uapp ]); + (1, 2) |.u printTuple) + [@res.braces ]))) + [@res.arity 1]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/uncurried.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/uncurried.res.txt index 49f5b006cc..8937d3f80a 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/uncurried.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/uncurried.res.txt @@ -1,35 +1,30 @@ let f = ((Function$ (fun a -> fun b -> a + b))[@res.arity 2]) -let f = ((Function$ (fun a -> ((Function$ (fun b -> a + b))[@res.arity 1]))) - [@res.arity 1]) -let f = - ((Function$ - (fun a -> - fun b -> ((Function$ (fun c -> fun d -> ((a + b) + c) + d)) - [@res.arity 2]))) - [@res.arity 2]) +let f = ((Function$ (fun a -> fun b -> a + b))[@res.arity 2]) +let f = ((Function$ (fun a -> fun b -> fun c -> fun d -> ((a + b) + c) + d)) + [@res.arity 4]) let f = ((Function$ ((fun a -> - ((fun b -> - ((Function$ ((fun c -> ((fun d -> ())[@res.braces ][@attr4 ])) - [@attr3 ])) - [@res.arity 1])) - [@res.braces ][@attr2 ])) + ((Function$ + ((fun b -> + ((Function$ + ((fun c -> ((Function$ ((fun d -> ())[@attr4 ])) + [@res.arity 1])) + [@attr3 ])) + [@res.arity 1])) + [@attr2 ])) + [@res.arity 1])) [@attr ])) [@res.arity 1]) let f = ((Function$ (fun ((a)[@attr ]) -> - fun ((b)[@attr2 ]) -> - ((Function$ (fun ((c)[@attr3 ]) -> fun ((d)[@attr4 ]) -> ())) - [@res.arity 2]))) - [@res.arity 2]) + fun ((b)[@attr2 ]) -> fun ((c)[@attr3 ]) -> fun ((d)[@attr4 ]) -> ())) + [@res.arity 4]) let f = ((Function$ (fun ((a)[@attr ]) -> - fun ((b)[@attr2 ]) -> - ((Function$ (fun ((c)[@attr3 ]) -> fun ((d)[@attr4 ]) -> ())) - [@res.arity 2]))) - [@res.arity 2]) + fun ((b)[@attr2 ]) -> fun ((c)[@attr3 ]) -> fun ((d)[@attr4 ]) -> ())) + [@res.arity 4]) ;;((add 1 2)[@res.uapp ]) ;;((((((add 2 3 4)[@res.uapp ]) 5 6 7)[@res.uapp ]) 8 9 10)[@res.uapp ]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/underscoreApply.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/underscoreApply.res.txt index dc26968f69..846308f379 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/underscoreApply.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/underscoreApply.res.txt @@ -1,19 +1,58 @@ let l = - ([1; 2; 3] |. (fun __x -> List.map (fun i -> i + 1) __x)) |. - (fun __x -> List.filter (fun i -> i > 0) __x) -let l = (fun i -> i + 1) |. (fun __x -> List.map __x [1; 2; 3]) -let x __x = List.length __x -let nested x __x = List.length __x -let incr ~v:((v)[@res.namedArgLoc ]) = v + 1 -let l1 = ([1; 2; 3] |> (List.map (fun __x -> incr ~v:__x))) |> List.length -let l2 = ([1; 2; 3] |> (List.map (fun __x -> incr ~v:__x))) |> List.length -let optParam ?v:((v)[@res.namedArgLoc ]) () = ((if v = None then 0 else 1) - [@res.ternary ]) + ([1; 2; 3] |.u + ((Function$ + (fun __x -> + ((List.map ((Function$ (fun i -> i + 1))[@res.arity 1]) __x) + [@res.uapp ]))) + [@res.arity 1])) + |.u + ((Function$ + (fun __x -> + ((List.filter ((Function$ (fun i -> i > 0))[@res.arity 1]) __x) + [@res.uapp ]))) + [@res.arity 1]) +let l = + ((Function$ (fun i -> i + 1))[@res.arity 1]) |.u + ((Function$ (fun __x -> ((List.map __x [1; 2; 3])[@res.uapp ]))) + [@res.arity 1]) +let x = ((Function$ (fun __x -> ((List.length __x)[@res.uapp ]))) + [@res.arity 1]) +let nested = + ((Function$ + (fun x -> ((Function$ (fun __x -> ((List.length __x)[@res.uapp ]))) + [@res.arity 1]))) + [@res.arity 1]) +let incr = ((Function$ (fun ~v:((v)[@res.namedArgLoc ]) -> v + 1)) + [@res.arity 1]) +let l1 = + ((List.length + ((List.map ((Function$ (fun __x -> ((incr ~v:__x)[@res.uapp ]))) + [@res.arity 1]) [1; 2; 3])[@res.uapp ])) + [@res.uapp ]) +let l2 = + ((List.length + ((List.map ((Function$ (fun __x -> ((incr ~v:__x)[@res.uapp ]))) + [@res.arity 1]) [1; 2; 3])[@res.uapp ])) + [@res.uapp ]) +let optParam = + ((Function$ + (fun ?v:((v)[@res.namedArgLoc ]) -> + fun () -> ((if v = None then 0 else 1)[@res.ternary ]))) + [@res.arity 2]) let l1 = - ([Some 1; None; Some 2] |> (List.map (fun __x -> optParam ?v:__x ()))) |> - List.length + ((List.length + ((List.map ((Function$ (fun __x -> ((optParam ?v:__x ())[@res.uapp ]))) + [@res.arity 1]) [Some 1; None; Some 2])[@res.uapp ])) + [@res.uapp ]) let l2 = - ([Some 1; None; Some 2] |> (List.map (fun __x -> optParam ?v:__x ()))) |> - List.length -;;fun __x -> - underscoreWithComments (fun x -> ((something ())[@res.braces ])) __x \ No newline at end of file + ((List.length + ((List.map ((Function$ (fun __x -> ((optParam ?v:__x ())[@res.uapp ]))) + [@res.arity 1]) [Some 1; None; Some 2])[@res.uapp ])) + [@res.uapp ]) +;;((Function$ + (fun __x -> + ((underscoreWithComments + ((Function$ + (fun x -> ((something ())[@res.braces ][@res.uapp ]))) + [@res.arity 1]) __x) + [@res.uapp ])))[@res.arity 1]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/while.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/while.res.txt index bb1652c1e1..cd02e75d45 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/while.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/while.res.txt @@ -1,3 +1,5 @@ ;;while not eofReached do - let a = 1 in let b = 2 in Lexbuf.next (); (a + b) |. Js.log done -;;while (not (isLineEnding buf)) && true do foo (); next () done \ No newline at end of file + let a = 1 in + let b = 2 in ((Lexbuf.next ())[@res.uapp ]); (a + b) |.u Js.log done +;;while (not ((isLineEnding buf)[@res.uapp ])) && true do + ((foo ())[@res.uapp ]); ((next ())[@res.uapp ]) done \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/modexpr/expected/apply.res.txt b/jscomp/syntax/tests/parsing/grammar/modexpr/expected/apply.res.txt index b5320eed38..0de90cceb6 100644 --- a/jscomp/syntax/tests/parsing/grammar/modexpr/expected/apply.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/modexpr/expected/apply.res.txt @@ -11,5 +11,8 @@ module X = ((F)(struct end))(struct end) module X = (F)((A : SetLike)) module X = ((F)((A : SetLike)))((B : TreeLike)) module X = ((F)((A : SetLike)))((B : TreeLike)) -let someFunctorAsFunction (x : (module MT)) = ((module (SomeFunctor)((val - x))) : (module ResT)) \ No newline at end of file +let someFunctorAsFunction = + ((Function$ + (fun (x : (module MT)) -> ((module (SomeFunctor)((val + x))) : (module ResT)))) + [@res.arity 1]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/modexpr/expected/firstClassModules.res.txt b/jscomp/syntax/tests/parsing/grammar/modexpr/expected/firstClassModules.res.txt index e2f7de7fd2..3d8d5fb9f0 100644 --- a/jscomp/syntax/tests/parsing/grammar/modexpr/expected/firstClassModules.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/modexpr/expected/firstClassModules.res.txt @@ -1,12 +1,20 @@ module Device = (val - (((let deviceName = parseCmdline () in - try Hashtbl.find devices deviceName with | Not_found -> exit 2) + (((let deviceName = ((parseCmdline ())[@res.uapp ]) in + try ((Hashtbl.find devices deviceName)[@res.uapp ]) + with | Not_found -> ((exit 2)[@res.uapp ])) [@res.braces ]) : (module Device))) -let draw_using_device device_name picture = - ((let module Device = (val - (Hashtbl.find devices device_name : (module DEVICE))) in - Device.draw picture) - [@res.braces ]) +let draw_using_device = + ((Function$ + (fun device_name -> + fun picture -> + ((let module Device = (val (((Hashtbl.find devices device_name) + [@res.uapp ]) : (module DEVICE))) in ((Device.draw picture) + [@res.uapp ])) + [@res.braces ]))) + [@res.arity 2]) module New_three = (val (three : (module X_int))) -let to_int m = ((let module M = (val (m : (module X_int))) in M.x) - [@res.braces ]) \ No newline at end of file +let to_int = + ((Function$ + (fun m -> ((let module M = (val (m : (module X_int))) in M.x) + [@res.braces ]))) + [@res.arity 1]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/modexpr/expected/functor.res.txt b/jscomp/syntax/tests/parsing/grammar/modexpr/expected/functor.res.txt index b8c0280b59..9fd5785bd0 100644 --- a/jscomp/syntax/tests/parsing/grammar/modexpr/expected/functor.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/modexpr/expected/functor.res.txt @@ -14,28 +14,46 @@ module F() = Map module F = ((functor () -> Map)[@functorAttr ]) include functor () -> Map include ((functor () -> Map)[@functorAttr ]) -module Make(Cmp:sig type nonrec t val eq : t -> t -> bool end) : +module Make(Cmp:sig + type nonrec t + val eq : (t -> t -> bool, [ `Has_arity2 ]) function$ + end) : sig type nonrec key = Cmp.t type nonrec coll val empty : coll - val add : coll -> key -> coll + val add : (coll -> key -> coll, [ `Has_arity2 ]) function$ end = struct open Cmp type nonrec key = t type nonrec coll = key list let empty = [] - let add (y : coll) (e : key) = - if List.exists (fun x -> eq x e) y then y else e :: y + let add = + ((Function$ + (fun (y : coll) -> + fun (e : key) -> + if + ((List.exists ((Function$ (fun x -> ((eq x e)[@res.uapp ]))) + [@res.arity 1]) y) + [@res.uapp ]) + then y + else e :: y)) + [@res.arity 2]) end module Gen1(P:Primitive)() = - struct type nonrec t = P.t - type nonrec internal = P.t - let inject t = t end + struct + type nonrec t = P.t + type nonrec internal = P.t + let inject = ((Function$ (fun t -> t))[@res.arity 1]) + end module DistinctString() : StringBased = - struct type nonrec t = string - let inject t = t end + struct + type nonrec t = string + let inject = ((Function$ (fun t -> t))[@res.arity 1]) + end module DistinctString() : StringBased = - struct type nonrec t = string - let inject t = t end \ No newline at end of file + struct + type nonrec t = string + let inject = ((Function$ (fun t -> t))[@res.arity 1]) + end \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/modtype/expected/parenthesized.res.txt b/jscomp/syntax/tests/parsing/grammar/modtype/expected/parenthesized.res.txt index c74e031cea..462e4dd07a 100644 --- a/jscomp/syntax/tests/parsing/grammar/modtype/expected/parenthesized.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/modtype/expected/parenthesized.res.txt @@ -4,11 +4,11 @@ module type Bt = ((Btree)[@attrIdent ][@attrParens ]) module type MyHash = sig include module type of struct include Hashtbl end - val replace : ('a, 'b) t -> 'a -> 'b -> unit + val replace : (('a, 'b) t -> 'a -> 'b -> unit, [ `Has_arity3 ]) function$ end module type MyHash = sig include ((module type of struct include Hashtbl end)[@onModTypeOf ][@onParens ]) - val replace : ('a, 'b) t -> 'a -> 'b -> unit + val replace : (('a, 'b) t -> 'a -> 'b -> unit, [ `Has_arity3 ]) function$ end \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/modtype/expected/typeof.res.txt b/jscomp/syntax/tests/parsing/grammar/modtype/expected/typeof.res.txt index fd46150287..27b03d24e2 100644 --- a/jscomp/syntax/tests/parsing/grammar/modtype/expected/typeof.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/modtype/expected/typeof.res.txt @@ -1,10 +1,10 @@ module type MyHash = sig include module type of struct include Hashtbl end - val replace : ('a, 'b) t -> 'a -> 'b -> unit + val replace : (('a, 'b) t -> 'a -> 'b -> unit, [ `Has_arity3 ]) function$ end module type MyHash = sig include ((module type of struct include Hashtbl end)[@onModuleTypeOf ]) - val replace : ('a, 'b) t -> 'a -> 'b -> unit + val replace : (('a, 'b) t -> 'a -> 'b -> unit, [ `Has_arity3 ]) function$ end \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/modtype/expected/with.res.txt b/jscomp/syntax/tests/parsing/grammar/modtype/expected/with.res.txt index 535c2b6c3f..ad7b6d9b50 100644 --- a/jscomp/syntax/tests/parsing/grammar/modtype/expected/with.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/modtype/expected/with.res.txt @@ -29,7 +29,12 @@ module type A = (Foo with module X.Bar := Belt.Array and module X.Bar := Belt.Array and module X.Bar := Belt.Array) module type Printable = - sig type nonrec t val print : Format.formatter -> t -> unit end -module type Comparable = sig type nonrec t val compare : t -> t -> int end + sig + type nonrec t + val print : (Format.formatter -> t -> unit, [ `Has_arity2 ]) function$ + end +module type Comparable = + sig type nonrec t val compare : (t -> t -> int, [ `Has_arity2 ]) function$ + end module type PrintableComparable = sig include Printable include (Comparable with type t := t) end \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/pattern/expected/any.res.txt b/jscomp/syntax/tests/parsing/grammar/pattern/expected/any.res.txt index 158df882d5..a0d068e67d 100644 --- a/jscomp/syntax/tests/parsing/grammar/pattern/expected/any.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/pattern/expected/any.res.txt @@ -17,13 +17,13 @@ let _ as _y|_ as _x = 1 | _ as _x|_ as _x -> () | (_ : unit) -> () | (_ : unit)|(_ : unit) -> () -let f _ = () -let f (_ as _x) = () -let f (_ : unit) = () -let f (_ : unit) = () -let f ((_ : unit) as _x) = () -let g a _ = () -let g _ a = () +let f = ((Function$ (fun _ -> ()))[@res.arity 1]) +let f = ((Function$ (fun (_ as _x) -> ()))[@res.arity 1]) +let f = ((Function$ (fun (_ : unit) -> ()))[@res.arity 1]) +let f = ((Function$ (fun (_ : unit) -> ()))[@res.arity 1]) +let f = ((Function$ (fun ((_ : unit) as _x) -> ()))[@res.arity 1]) +let g = ((Function$ (fun a -> fun _ -> ()))[@res.arity 2]) +let g = ((Function$ (fun _ -> fun a -> ()))[@res.arity 2]) ;;for _ = 0 to 10 do () done ;;for _ as _x = 0 to 10 do () done ;;for _ = 0 to 10 do () done diff --git a/jscomp/syntax/tests/parsing/grammar/pattern/expected/array.res.txt b/jscomp/syntax/tests/parsing/grammar/pattern/expected/array.res.txt index 9ef29983d7..94ad52cb04 100644 --- a/jscomp/syntax/tests/parsing/grammar/pattern/expected/array.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/pattern/expected/array.res.txt @@ -9,11 +9,11 @@ let ([|(1 : int);(2 : int)|] : int array) = () | [|1;2|] -> () | [|(1 : int);(2 : int)|] -> () | ([|(1 : int);(2 : int)|] : int) -> () -let f [||] = () -let f [|x|] = () -let f [|x;y|] = x + y -let f ([|x|] : int) = () -let f ([|x|] : int) = () +let f = ((Function$ (fun [||] -> ()))[@res.arity 1]) +let f = ((Function$ (fun [|x|] -> ()))[@res.arity 1]) +let f = ((Function$ (fun [|x;y|] -> x + y))[@res.arity 1]) +let f = ((Function$ (fun ([|x|] : int) -> ()))[@res.arity 1]) +let f = ((Function$ (fun ([|x|] : int) -> ()))[@res.arity 1]) ;;for [||] = 0 to 10 do () done ;;for [||] = 0 to 10 do () done ;;for [||] = 0 to 10 do () done diff --git a/jscomp/syntax/tests/parsing/grammar/pattern/expected/constant.res.txt b/jscomp/syntax/tests/parsing/grammar/pattern/expected/constant.res.txt index bc30806ef9..8dad10cd68 100644 --- a/jscomp/syntax/tests/parsing/grammar/pattern/expected/constant.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/pattern/expected/constant.res.txt @@ -15,12 +15,15 @@ let ({js|stringPattern|js} : string) as s = () ;;for {js|stringPattern|js} = 0 to 10 do () done ;;for {js|stringPattern|js} as s = 0 to 10 do () done ;;for {js|stringPattern|js} as s = 0 to 10 do () done -let f {js|stringPattern|js} = () -let f ({js|stringPattern|js} as s) = () -let f ({js|stringPattern|js} as s) = () -let f ({js|stringPattern|js} : string) = () -let f (({js|stringPattern|js} : string) as s) = () -let f ({js|stringPattern|js} : string) = () +let f = ((Function$ (fun {js|stringPattern|js} -> ()))[@res.arity 1]) +let f = ((Function$ (fun ({js|stringPattern|js} as s) -> ()))[@res.arity 1]) +let f = ((Function$ (fun ({js|stringPattern|js} as s) -> ()))[@res.arity 1]) +let f = ((Function$ (fun ({js|stringPattern|js} : string) -> ())) + [@res.arity 1]) +let f = ((Function$ (fun (({js|stringPattern|js} : string) as s) -> ())) + [@res.arity 1]) +let f = ((Function$ (fun ({js|stringPattern|js} : string) -> ())) + [@res.arity 1]) let 1 = () let 1 as x = () let (1 : int) = () @@ -30,11 +33,11 @@ let (1 : int) as x = () | 1 as x -> () | (1 : int) -> () | (1 : int) as x -> () -let f 1 = () -let f (1 as x) = () -let f (1 : int) = () -let f ((1 : int) as x) = () -let f (1 : int) = () +let f = ((Function$ (fun 1 -> ()))[@res.arity 1]) +let f = ((Function$ (fun (1 as x) -> ()))[@res.arity 1]) +let f = ((Function$ (fun (1 : int) -> ()))[@res.arity 1]) +let f = ((Function$ (fun ((1 : int) as x) -> ()))[@res.arity 1]) +let f = ((Function$ (fun (1 : int) -> ()))[@res.arity 1]) ;;for i = 0 to 10 do () done ;;for i as x = 0 to 10 do () done ;;for i = 0 to 10 do () done @@ -42,19 +45,27 @@ let f (1 : int) = () ;;for i as x = 0 to 10 do () done ;;match listPatterns with | (true, pattern)::patterns -> - let patterns = (patterns |> (List.map filterSpread)) |> List.rev in - makeListPattern loc patterns (Some pattern) + let patterns = + ((List.rev ((List.map filterSpread patterns)[@res.uapp ])) + [@res.uapp ]) in + ((makeListPattern loc patterns (Some pattern))[@res.uapp ]) | patterns -> - let patterns = (patterns |> (List.map filterSpread)) |> List.rev in - makeListPattern loc patterns None + let patterns = + ((List.rev ((List.map filterSpread patterns)[@res.uapp ])) + [@res.uapp ]) in + ((makeListPattern loc patterns None)[@res.uapp ]) let _0 = 0x9A -let print ppf i = - match i.stamp with - | 0 -> fprintf ppf {js|%s!|js} i.name - | (-1) -> fprintf ppf {js|%s#|js} i.name - | 1 -> fprintf ppf {js|%s#|js} i.name - | (-1.) -> fprintf ppf {js|%s#|js} i.name - | 1. -> fprintf ppf {js|%s#|js} i.name +let print = + ((Function$ + (fun ppf -> + fun i -> + match i.stamp with + | 0 -> ((fprintf ppf {js|%s!|js} i.name)[@res.uapp ]) + | (-1) -> ((fprintf ppf {js|%s#|js} i.name)[@res.uapp ]) + | 1 -> ((fprintf ppf {js|%s#|js} i.name)[@res.uapp ]) + | (-1.) -> ((fprintf ppf {js|%s#|js} i.name)[@res.uapp ]) + | 1. -> ((fprintf ppf {js|%s#|js} i.name)[@res.uapp ]))) + [@res.arity 2]) let (-1)..(-1.) = x ;;match science with | (1.12, (-3.13)) -> true diff --git a/jscomp/syntax/tests/parsing/grammar/pattern/expected/constructor.res.txt b/jscomp/syntax/tests/parsing/grammar/pattern/expected/constructor.res.txt index 45783c9c97..ee8410a339 100644 --- a/jscomp/syntax/tests/parsing/grammar/pattern/expected/constructor.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/pattern/expected/constructor.res.txt @@ -34,21 +34,25 @@ let ((Instance (component : comp)) : React.t) = i | Instance (comp, tree) -> () | React.Instance (comp, tree) -> () | (Instance (comp : Component.t) : React.t) -> () -let f (Instance) = i -let f (Instance as i) = i -let f (React.Instance) = i -let f (React.Instance as x) = i -let f (Instance component) = i -let f (Instance component) = i -let f (Instance { render; subtree }) = i -let f (Instance ({ render; subtree }, inst)) = i -let f (Instance ({ render; subtree } : Instance.t)) = i -let f (Instance ({ render; subtree } : Instance.t)) = i -let f (Instance (component, tree)) = i -let f (Instance (component, tree)) = i -let f (Instance : React.t) = i -let f (Instance : React.t) = i -let f (Instance (comp : Component.t) : React.t) = () +let f = ((Function$ (fun (Instance) -> i))[@res.arity 1]) +let f = ((Function$ (fun (Instance as i) -> i))[@res.arity 1]) +let f = ((Function$ (fun (React.Instance) -> i))[@res.arity 1]) +let f = ((Function$ (fun (React.Instance as x) -> i))[@res.arity 1]) +let f = ((Function$ (fun (Instance component) -> i))[@res.arity 1]) +let f = ((Function$ (fun (Instance component) -> i))[@res.arity 1]) +let f = ((Function$ (fun (Instance { render; subtree }) -> i))[@res.arity 1]) +let f = ((Function$ (fun (Instance ({ render; subtree }, inst)) -> i)) + [@res.arity 1]) +let f = ((Function$ (fun (Instance ({ render; subtree } : Instance.t)) -> i)) + [@res.arity 1]) +let f = ((Function$ (fun (Instance ({ render; subtree } : Instance.t)) -> i)) + [@res.arity 1]) +let f = ((Function$ (fun (Instance (component, tree)) -> i))[@res.arity 1]) +let f = ((Function$ (fun (Instance (component, tree)) -> i))[@res.arity 1]) +let f = ((Function$ (fun (Instance : React.t) -> i))[@res.arity 1]) +let f = ((Function$ (fun (Instance : React.t) -> i))[@res.arity 1]) +let f = ((Function$ (fun (Instance (comp : Component.t) : React.t) -> ())) + [@res.arity 1]) ;;for Blue = x to y do () done ;;for Blue as c = x to y do () done ;;for Blue = x to y do () done @@ -70,5 +74,5 @@ let f (Instance (comp : Component.t) : React.t) = () ;;for Point { x; y; z } = x to y do () done ;;for Point { x; y; z } as p = x to y do () done ;;match truth with - | true -> Js.log {js|true|js} - | false -> Js.log {js|false|js} \ No newline at end of file + | true -> ((Js.log {js|true|js})[@res.uapp ]) + | false -> ((Js.log {js|false|js})[@res.uapp ]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/pattern/expected/exception.res.txt b/jscomp/syntax/tests/parsing/grammar/pattern/expected/exception.res.txt index f605551ffc..725cb04362 100644 --- a/jscomp/syntax/tests/parsing/grammar/pattern/expected/exception.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/pattern/expected/exception.res.txt @@ -25,14 +25,14 @@ let exception ((Foo : t exc) as e) = () | exception (Foo as e) -> () | exception Foo (a, b) -> () | (exception Foo : t exc) -> () -let f exception Foo = () -let f (exception Foo as e) = () -let f exception (Foo as e) = () -let f exception Foo (a, b) = () -let f exception Foo = () -let f (exception Foo as e) = () -let f exception Foo (a, b) = () -let f (exception Foo : t exc) = () +let f = ((Function$ (fun exception Foo -> ()))[@res.arity 1]) +let f = ((Function$ (fun (exception Foo as e) -> ()))[@res.arity 1]) +let f = ((Function$ (fun exception (Foo as e) -> ()))[@res.arity 1]) +let f = ((Function$ (fun exception Foo (a, b) -> ()))[@res.arity 1]) +let f = ((Function$ (fun exception Foo -> ()))[@res.arity 1]) +let f = ((Function$ (fun (exception Foo as e) -> ()))[@res.arity 1]) +let f = ((Function$ (fun exception Foo (a, b) -> ()))[@res.arity 1]) +let f = ((Function$ (fun (exception Foo : t exc) -> ()))[@res.arity 1]) ;;for exception Foo = 0 to 10 do () done ;;for exception Foo as e = 0 to 10 do () done ;;for exception Foo = 0 to 10 do () done diff --git a/jscomp/syntax/tests/parsing/grammar/pattern/expected/extension.res.txt b/jscomp/syntax/tests/parsing/grammar/pattern/expected/extension.res.txt index ca0ed6d49f..107533c8ed 100644 --- a/jscomp/syntax/tests/parsing/grammar/pattern/expected/extension.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/pattern/expected/extension.res.txt @@ -11,13 +11,14 @@ let [%patExt1 ]|[%patExt2 ] = () | [%pat.stuff test] as _x -> () | ([%pat.stuff test] : unit) -> () | [%patExt1 ]|[%patExt2 ] -> () -let f [%patternExtension ] = () -let f [%pattern.extension ] = () -let f [%raw {js|x|js}] = () -let f [%raw {js|x|js}] [%raw {js|y|js}] = () -let f ([%raw {js|x|js}] as _y) = () -let f ([%raw {js|x|js}] : unit) = () -let f ([%patExt1 ]|[%patExt2 ]) = () +let f = ((Function$ (fun [%patternExtension ] -> ()))[@res.arity 1]) +let f = ((Function$ (fun [%pattern.extension ] -> ()))[@res.arity 1]) +let f = ((Function$ (fun [%raw {js|x|js}] -> ()))[@res.arity 1]) +let f = ((Function$ (fun [%raw {js|x|js}] -> fun [%raw {js|y|js}] -> ())) + [@res.arity 2]) +let f = ((Function$ (fun ([%raw {js|x|js}] as _y) -> ()))[@res.arity 1]) +let f = ((Function$ (fun ([%raw {js|x|js}] : unit) -> ()))[@res.arity 1]) +let f = ((Function$ (fun ([%patExt1 ]|[%patExt2 ]) -> ()))[@res.arity 1]) ;;for [%ext ] = x to y do () done ;;for [%ext1 ]|[%ext2 ] = x to y do () done ;;for [%ext ] = x to y do () done diff --git a/jscomp/syntax/tests/parsing/grammar/pattern/expected/firstClassModules.res.txt b/jscomp/syntax/tests/parsing/grammar/pattern/expected/firstClassModules.res.txt index f09c04444b..142cb617dd 100644 --- a/jscomp/syntax/tests/parsing/grammar/pattern/expected/firstClassModules.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/pattern/expected/firstClassModules.res.txt @@ -1,10 +1,25 @@ -let sort (type s) (module Set) l = () -let sort (type s) ((module Set) : (module Set.S with type elt = s)) l = () -let sort (type s) - ((module Set) : (module Set.S with type elt = s and type elt2 = t)) l = () -let foo (module Foo) baz = Foo.bar baz -let bump_list (type a) ((module B) : (module Bumpable with type t = a)) - (l : a list) = List.map ~f:((B.bump l)[@res.namedArgLoc ]) +let sort (type s) = ((Function$ (fun (module Set) -> fun l -> ())) + [@res.arity 2]) +let sort (type s) = + ((Function$ + (fun ((module Set) : (module Set.S with type elt = s)) -> fun l -> ())) + [@res.arity 2]) +let sort (type s) = + ((Function$ + (fun + ((module Set) : (module Set.S with type elt = s and type elt2 = t)) + -> fun l -> ())) + [@res.arity 2]) +let foo = + ((Function$ (fun (module Foo) -> fun baz -> ((Foo.bar baz)[@res.uapp ]))) + [@res.arity 2]) +let bump_list (type a) = + ((Function$ + (fun ((module B) : (module Bumpable with type t = a)) -> + fun (l : a list) -> + ((List.map ~f:((B.bump l)[@res.namedArgLoc ][@res.uapp ])) + [@res.uapp ]))) + [@res.arity 2]) ;;match x with | (module Set) -> () | ((module Set) : (module Set.S with type elt = s)) -> () diff --git a/jscomp/syntax/tests/parsing/grammar/pattern/expected/list.res.txt b/jscomp/syntax/tests/parsing/grammar/pattern/expected/list.res.txt index f5b33cd4dd..83fe31d17f 100644 --- a/jscomp/syntax/tests/parsing/grammar/pattern/expected/list.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/pattern/expected/list.res.txt @@ -33,21 +33,24 @@ let ((x::xs : int list) : int list) = () | x::(y::ys)::xs -> () | (x as p1)::((y as p2)::(ys as tail1))::(xs as tail2) as l -> () | (x::xs : int list) -> () -let f [] = () -let f ([] as p) = () -let f (x::[]) = () -let f (((x : int) as p)::[]) = () -let f ((x as p)::[] as p2) = () -let f (x::xs) = () -let f (x::(xs as tail)) = () -let f (x::y::tail) = () -let f (x::y::[]) = () -let f (x::y::[]) = () -let f (x::xs) = () -let f (x::y::tail) = () -let f (x::(y::ys)::xs) = () -let f ((x as p1)::((y as p2)::(ys as tail1))::(xs as tail2) as l) = () -let f (x::xs : int list) = () +let f = ((Function$ (fun [] -> ()))[@res.arity 1]) +let f = ((Function$ (fun ([] as p) -> ()))[@res.arity 1]) +let f = ((Function$ (fun (x::[]) -> ()))[@res.arity 1]) +let f = ((Function$ (fun (((x : int) as p)::[]) -> ()))[@res.arity 1]) +let f = ((Function$ (fun ((x as p)::[] as p2) -> ()))[@res.arity 1]) +let f = ((Function$ (fun (x::xs) -> ()))[@res.arity 1]) +let f = ((Function$ (fun (x::(xs as tail)) -> ()))[@res.arity 1]) +let f = ((Function$ (fun (x::y::tail) -> ()))[@res.arity 1]) +let f = ((Function$ (fun (x::y::[]) -> ()))[@res.arity 1]) +let f = ((Function$ (fun (x::y::[]) -> ()))[@res.arity 1]) +let f = ((Function$ (fun (x::xs) -> ()))[@res.arity 1]) +let f = ((Function$ (fun (x::y::tail) -> ()))[@res.arity 1]) +let f = ((Function$ (fun (x::(y::ys)::xs) -> ()))[@res.arity 1]) +let f = + ((Function$ + (fun ((x as p1)::((y as p2)::(ys as tail1))::(xs as tail2) as l) -> ())) + [@res.arity 1]) +let f = ((Function$ (fun (x::xs : int list) -> ()))[@res.arity 1]) ;;for [] = x to y do () done ;;for [] as l = x to y do () done ;;for [] = x to y do () done diff --git a/jscomp/syntax/tests/parsing/grammar/pattern/expected/polyvariants.res.txt b/jscomp/syntax/tests/parsing/grammar/pattern/expected/polyvariants.res.txt index 553ad2cdf2..717f79bcca 100644 --- a/jscomp/syntax/tests/parsing/grammar/pattern/expected/polyvariants.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/pattern/expected/polyvariants.res.txt @@ -31,19 +31,26 @@ let ((`Instance (component : comp)) : React.t) = i | `Instance ({ render; subtree } : Instance.t) -> () | `Instance (comp, tree) -> () | (`Instance (comp : Component.t) : React.t) -> () -let f `Instance = i -let f (`Instance as i) = i -let f (`Instance component) = i -let f (`Instance component) = i -let f (`Instance { render; subtree }) = i -let f (`Instance ({ render; subtree }, inst)) = i -let f (`Instance ({ render; subtree } : Instance.t)) = i -let f (`Instance ({ render; subtree } : Instance.t)) = i -let f (`Instance (component, tree)) = i -let f (`Instance (component, tree)) = i -let f (`Instance : React.t) = i -let f (`Instance : React.t) = i -let f (`Instance (comp : Component.t) : React.t) = () +let f = ((Function$ (fun `Instance -> i))[@res.arity 1]) +let f = ((Function$ (fun (`Instance as i) -> i))[@res.arity 1]) +let f = ((Function$ (fun (`Instance component) -> i))[@res.arity 1]) +let f = ((Function$ (fun (`Instance component) -> i))[@res.arity 1]) +let f = ((Function$ (fun (`Instance { render; subtree }) -> i)) + [@res.arity 1]) +let f = ((Function$ (fun (`Instance ({ render; subtree }, inst)) -> i)) + [@res.arity 1]) +let f = + ((Function$ (fun (`Instance ({ render; subtree } : Instance.t)) -> i)) + [@res.arity 1]) +let f = + ((Function$ (fun (`Instance ({ render; subtree } : Instance.t)) -> i)) + [@res.arity 1]) +let f = ((Function$ (fun (`Instance (component, tree)) -> i))[@res.arity 1]) +let f = ((Function$ (fun (`Instance (component, tree)) -> i))[@res.arity 1]) +let f = ((Function$ (fun (`Instance : React.t) -> i))[@res.arity 1]) +let f = ((Function$ (fun (`Instance : React.t) -> i))[@res.arity 1]) +let f = ((Function$ (fun (`Instance (comp : Component.t) : React.t) -> ())) + [@res.arity 1]) ;;for `Blue = x to y do () done ;;for `Blue as c = x to y do () done ;;for `Blue = x to y do () done @@ -62,19 +69,23 @@ let f (`Instance (comp : Component.t) : React.t) = () ;;for `Point { x; y; z } = x to y do () done ;;for `Point { x; y; z } as p = x to y do () done ;;match x with | #typeVar -> () | `lowercase -> () -let cmp selectedChoice value = - match (selectedChoice, value) with - | (#a, #a) -> true - | [|#b;#b|] -> true - | #b::#b::[] -> true - | { x = #c; y = #c } -> true - | Constructor (#a, #a) -> true - | `Constuctor (#a, #a) -> true - | #a as x -> true - | #a|#b -> true - | (#a : typ) -> true - | exception #a -> true - | _ -> false +let cmp = + ((Function$ + (fun selectedChoice -> + fun value -> + match (selectedChoice, value) with + | (#a, #a) -> true + | [|#b;#b|] -> true + | #b::#b::[] -> true + | { x = #c; y = #c } -> true + | Constructor (#a, #a) -> true + | `Constuctor (#a, #a) -> true + | #a as x -> true + | #a|#b -> true + | (#a : typ) -> true + | exception #a -> true + | _ -> false)) + [@res.arity 2]) ;;match polyVar with | `ease-in -> () | `ease-out⛰ -> () diff --git a/jscomp/syntax/tests/parsing/grammar/pattern/expected/record.res.txt b/jscomp/syntax/tests/parsing/grammar/pattern/expected/record.res.txt index 646a08cb2f..85b7386cb7 100644 --- a/jscomp/syntax/tests/parsing/grammar/pattern/expected/record.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/pattern/expected/record.res.txt @@ -32,24 +32,27 @@ let ({ a } : myRecord) = x | { a;_} -> () | { a;_} -> () | ({ a } : myRecord) -> () -let f { a } = () -let f ({ a } as r) = () -let f { a } = () -let f { a; b } = () -let f { a; b } = () -let f { ReasonReact.state = state } = () -let f { ReasonReact.state = (state as prevState) } = () -let f { ReasonReact.state = theState } = () -let f { a = u } = () -let f { a = (u : int) } = () -let f { a = (((u as x) : int) as r) } = () -let f { a = { x; y } } = () -let f { a = { x = r; y = r2 } } = () -let f { a;_} = () -let f { a;_} = () -let f ({ a } : myRecord) = () -let f ({ a } : myRecord) = () -let f (({ a } : myRecord) as p) = () +let f = ((Function$ (fun { a } -> ()))[@res.arity 1]) +let f = ((Function$ (fun ({ a } as r) -> ()))[@res.arity 1]) +let f = ((Function$ (fun { a } -> ()))[@res.arity 1]) +let f = ((Function$ (fun { a; b } -> ()))[@res.arity 1]) +let f = ((Function$ (fun { a; b } -> ()))[@res.arity 1]) +let f = ((Function$ (fun { ReasonReact.state = state } -> ()))[@res.arity 1]) +let f = ((Function$ (fun { ReasonReact.state = (state as prevState) } -> ())) + [@res.arity 1]) +let f = ((Function$ (fun { ReasonReact.state = theState } -> ())) + [@res.arity 1]) +let f = ((Function$ (fun { a = u } -> ()))[@res.arity 1]) +let f = ((Function$ (fun { a = (u : int) } -> ()))[@res.arity 1]) +let f = ((Function$ (fun { a = (((u as x) : int) as r) } -> ())) + [@res.arity 1]) +let f = ((Function$ (fun { a = { x; y } } -> ()))[@res.arity 1]) +let f = ((Function$ (fun { a = { x = r; y = r2 } } -> ()))[@res.arity 1]) +let f = ((Function$ (fun { a;_} -> ()))[@res.arity 1]) +let f = ((Function$ (fun { a;_} -> ()))[@res.arity 1]) +let f = ((Function$ (fun ({ a } : myRecord) -> ()))[@res.arity 1]) +let f = ((Function$ (fun ({ a } : myRecord) -> ()))[@res.arity 1]) +let f = ((Function$ (fun (({ a } : myRecord) as p) -> ()))[@res.arity 1]) ;;for { a } = 0 to 10 do () done ;;for { a } as p = 0 to 10 do () done ;;for { a } = 0 to 10 do () done diff --git a/jscomp/syntax/tests/parsing/grammar/pattern/expected/tuple.res.txt b/jscomp/syntax/tests/parsing/grammar/pattern/expected/tuple.res.txt index a8f85eeb9f..076cb61d98 100644 --- a/jscomp/syntax/tests/parsing/grammar/pattern/expected/tuple.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/pattern/expected/tuple.res.txt @@ -15,13 +15,15 @@ let (((1 : int), (2 : int)) : (int * int)) as tup = () | (((1 as p1) : int), ((2 as p2) : int)) as tup -> () | (((1 : int), (2 : int)) : (int * int)) -> () | (((1 : int), (2 : int)) : (int * int)) as tup -> () -let f x = () -let f x = () -let f (x, y) = x + y -let f (((x as p1), (y as p2)) as tup) = x + y -let f ((x, y) : (int * int)) = () -let f ((x, y) : (int * int)) = () -let f ((((x, y) as tup1) : (int * int)) as tup) = () +let f = ((Function$ (fun x -> ()))[@res.arity 1]) +let f = ((Function$ (fun x -> ()))[@res.arity 1]) +let f = ((Function$ (fun (x, y) -> x + y))[@res.arity 1]) +let f = ((Function$ (fun (((x as p1), (y as p2)) as tup) -> x + y)) + [@res.arity 1]) +let f = ((Function$ (fun ((x, y) : (int * int)) -> ()))[@res.arity 1]) +let f = ((Function$ (fun ((x, y) : (int * int)) -> ()))[@res.arity 1]) +let f = ((Function$ (fun ((((x, y) as tup1) : (int * int)) as tup) -> ())) + [@res.arity 1]) ;;for (x, y) = 0 to 10 do () done ;;for (x, y) as tup = 0 to 10 do () done ;;for (x, y) = 0 to 10 do () done diff --git a/jscomp/syntax/tests/parsing/grammar/pattern/expected/unit.res.txt b/jscomp/syntax/tests/parsing/grammar/pattern/expected/unit.res.txt index 64895daa3e..2ecd0e444a 100644 --- a/jscomp/syntax/tests/parsing/grammar/pattern/expected/unit.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/pattern/expected/unit.res.txt @@ -26,13 +26,13 @@ let (() : unit) as x = () ;;for (() : unit) as _u = () to () do () done ;;for ((() as _u) : unit) = () to () do () done ;;for (() : unit) as _u = () to () do () done -let f () = () -let f () = () -let f (() as _u) = () -let f () () = () -let f (() as _u) (() as _u) = () -let f (() : unit) = () -let f ((() as _u) : unit) = () -let f ((() : unit) as _u) = () -let f (() : unit) = () -let f ((() : unit) as _u) = () \ No newline at end of file +let f = ((Function$ (fun () -> ()))[@res.arity 1]) +let f = ((Function$ (fun () -> ()))[@res.arity 1]) +let f = ((Function$ (fun (() as _u) -> ()))[@res.arity 1]) +let f = ((Function$ (fun () -> fun () -> ()))[@res.arity 2]) +let f = ((Function$ (fun (() as _u) -> fun (() as _u) -> ()))[@res.arity 2]) +let f = ((Function$ (fun (() : unit) -> ()))[@res.arity 1]) +let f = ((Function$ (fun ((() as _u) : unit) -> ()))[@res.arity 1]) +let f = ((Function$ (fun ((() : unit) as _u) -> ()))[@res.arity 1]) +let f = ((Function$ (fun (() : unit) -> ()))[@res.arity 1]) +let f = ((Function$ (fun ((() : unit) as _u) -> ()))[@res.arity 1]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/pattern/expected/variants.res.txt b/jscomp/syntax/tests/parsing/grammar/pattern/expected/variants.res.txt index d969f013ed..7f0b809f4c 100644 --- a/jscomp/syntax/tests/parsing/grammar/pattern/expected/variants.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/pattern/expected/variants.res.txt @@ -31,19 +31,26 @@ let ((`Instance (component : comp)) : React.t) = i | `Instance ({ render; subtree } : Instance.t) -> () | `Instance (comp, tree) -> () | (`Instance (comp : Component.t) : React.t) -> () -let f `Instance = i -let f (`Instance as i) = i -let f (`Instance component) = i -let f (`Instance component) = i -let f (`Instance { render; subtree }) = i -let f (`Instance ({ render; subtree }, inst)) = i -let f (`Instance ({ render; subtree } : Instance.t)) = i -let f (`Instance ({ render; subtree } : Instance.t)) = i -let f (`Instance (component, tree)) = i -let f (`Instance (component, tree)) = i -let f (`Instance : React.t) = i -let f (`Instance : React.t) = i -let f (`Instance (comp : Component.t) : React.t) = () +let f = ((Function$ (fun `Instance -> i))[@res.arity 1]) +let f = ((Function$ (fun (`Instance as i) -> i))[@res.arity 1]) +let f = ((Function$ (fun (`Instance component) -> i))[@res.arity 1]) +let f = ((Function$ (fun (`Instance component) -> i))[@res.arity 1]) +let f = ((Function$ (fun (`Instance { render; subtree }) -> i)) + [@res.arity 1]) +let f = ((Function$ (fun (`Instance ({ render; subtree }, inst)) -> i)) + [@res.arity 1]) +let f = + ((Function$ (fun (`Instance ({ render; subtree } : Instance.t)) -> i)) + [@res.arity 1]) +let f = + ((Function$ (fun (`Instance ({ render; subtree } : Instance.t)) -> i)) + [@res.arity 1]) +let f = ((Function$ (fun (`Instance (component, tree)) -> i))[@res.arity 1]) +let f = ((Function$ (fun (`Instance (component, tree)) -> i))[@res.arity 1]) +let f = ((Function$ (fun (`Instance : React.t) -> i))[@res.arity 1]) +let f = ((Function$ (fun (`Instance : React.t) -> i))[@res.arity 1]) +let f = ((Function$ (fun (`Instance (comp : Component.t) : React.t) -> ())) + [@res.arity 1]) ;;for `Blue = x to y do () done ;;for `Blue as c = x to y do () done ;;for `Blue = x to y do () done @@ -66,4 +73,4 @@ let f (`Instance (comp : Component.t) : React.t) = () | `1 -> () | `42 -> () | `42444 -> () - | `3 (x, y, z) -> Js.log3 x y z \ No newline at end of file + | `3 (x, y, z) -> ((Js.log3 x y z)[@res.uapp ]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/signature/expected/external.res.txt b/jscomp/syntax/tests/parsing/grammar/signature/expected/external.res.txt index b5dbcc6bc6..5a5e012aa2 100644 --- a/jscomp/syntax/tests/parsing/grammar/signature/expected/external.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/signature/expected/external.res.txt @@ -2,9 +2,11 @@ module type Signature = sig type nonrec t external linkProgram : - t -> program:((webGlProgram)[@res.namedArgLoc ]) -> unit = - "linkProgram"[@@send ] - external add_nat : nat -> int -> int -> int = "add_nat_bytecode" - external svg : unit -> React.element = "svg" - external svg : unit -> React.element = "svg" + (t -> program:((webGlProgram)[@res.namedArgLoc ]) -> unit, + [ `Has_arity2 ]) function$ = "linkProgram"[@@send ] + external add_nat : + (nat -> int -> int -> int, [ `Has_arity3 ]) function$ = + "add_nat_bytecode" + external svg : (unit -> React.element, [ `Has_arity1 ]) function$ = "svg" + external svg : (unit -> React.element, [ `Has_arity1 ]) function$ = "svg" end \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/signature/expected/itemExtension.res.txt b/jscomp/syntax/tests/parsing/grammar/signature/expected/itemExtension.res.txt index db4bcef926..83e4bc1a83 100644 --- a/jscomp/syntax/tests/parsing/grammar/signature/expected/itemExtension.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/signature/expected/itemExtension.res.txt @@ -2,6 +2,7 @@ module type Ext = sig [%%item.extension ] [%%item.extension.with.args {js|argument|js}] - [%%item.extension.with.args fun x -> f x] + [%%item.extension.with.args + ((Function$ (fun x -> ((f x)[@res.uapp ])))[@res.arity 1])] [%%item.extension ][@@withAttr ] end \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/signature/expected/recModule.res.txt b/jscomp/syntax/tests/parsing/grammar/signature/expected/recModule.res.txt index 9a5e7990c6..831702d0ba 100644 --- a/jscomp/syntax/tests/parsing/grammar/signature/expected/recModule.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/signature/expected/recModule.res.txt @@ -5,7 +5,7 @@ module type Signature = type nonrec t = | Leaf of string | Node of ASet.t - val compare : t -> t -> int + val compare : (t -> t -> int, [ `Has_arity2 ]) function$ end and ASet: (Set.S with type elt = A.t) and BTree: (Btree.S with type elt = A.t) @@ -14,7 +14,7 @@ module type Signature = type nonrec t = | Leaf of string | Node of ASet.t - val compare : t -> t -> int + val compare : (t -> t -> int, [ `Has_arity2 ]) function$ end[@@onFirstAttr ] and ASet: (Set.S with type elt = A.t)[@@onSecondAttr ] module rec A: Btree[@@parsableOnNext ] diff --git a/jscomp/syntax/tests/parsing/grammar/signature/expected/standAloneAttribute.res.txt b/jscomp/syntax/tests/parsing/grammar/signature/expected/standAloneAttribute.res.txt index fe0c03bb11..edf70877ed 100644 --- a/jscomp/syntax/tests/parsing/grammar/signature/expected/standAloneAttribute.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/signature/expected/standAloneAttribute.res.txt @@ -2,5 +2,5 @@ module type StandaloneAttribute = sig [@@@standaloneAttribute ] [@@@standaloneAttribute withPayload] - [@@@standaloneAttribute fun x -> x] + [@@@standaloneAttribute ((Function$ (fun x -> x))[@res.arity 1])] end \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/structure/expected/externalDefinition.res.txt b/jscomp/syntax/tests/parsing/grammar/structure/expected/externalDefinition.res.txt index dc0b4ef9ce..cd22652574 100644 --- a/jscomp/syntax/tests/parsing/grammar/structure/expected/externalDefinition.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/structure/expected/externalDefinition.res.txt @@ -1,11 +1,13 @@ -external clear : t -> int -> unit = "clear" -external add_nat : nat -> int = "add_nat_bytecode" +external clear : (t -> int -> unit, [ `Has_arity2 ]) function$ = "clear" +external add_nat : + (nat -> int, [ `Has_arity1 ]) function$ = "add_nat_bytecode" external attachShader : - t -> - program:((webGlProgram)[@res.namedArgLoc ]) -> - shader:((webGlShader)[@res.namedArgLoc ]) -> unit = "attachShader" -[@@send ] -external svg : unit -> React.element = "svg" -external svg : unit -> React.element = "svg" -external createDate : unit -> unit -> date = "Date"[@@new ] -let foobar = (createDate ()) () \ No newline at end of file + (t -> + program:((webGlProgram)[@res.namedArgLoc ]) -> + shader:((webGlShader)[@res.namedArgLoc ]) -> unit, + [ `Has_arity3 ]) function$ = "attachShader"[@@send ] +external svg : (unit -> React.element, [ `Has_arity1 ]) function$ = "svg" +external svg : (unit -> React.element, [ `Has_arity1 ]) function$ = "svg" +external createDate : + (unit -> unit -> date, [ `Has_arity2 ]) function$ = "Date"[@@new ] +let foobar = ((((createDate ())[@res.uapp ]) ())[@res.uapp ]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/structure/expected/itemExtension.res.txt b/jscomp/syntax/tests/parsing/grammar/structure/expected/itemExtension.res.txt index ae308fb47e..309411dc36 100644 --- a/jscomp/syntax/tests/parsing/grammar/structure/expected/itemExtension.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/structure/expected/itemExtension.res.txt @@ -1,5 +1,6 @@ [%%itemExtension ] [%%item.extension ] [%%item.extension.with.args {js|argument|js}] -[%%item.extension.with.args fun x -> f x] +[%%item.extension.with.args + ((Function$ (fun x -> ((f x)[@res.uapp ])))[@res.arity 1])] [%%itemExtension ][@@attrOnExtension ] \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/structure/expected/letBinding.res.txt b/jscomp/syntax/tests/parsing/grammar/structure/expected/letBinding.res.txt index 9e3dca646b..704106b96f 100644 --- a/jscomp/syntax/tests/parsing/grammar/structure/expected/letBinding.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/structure/expected/letBinding.res.txt @@ -3,8 +3,14 @@ let a = 1[@@onFirstBinding ] let a = 1[@@onFirstBinding ] and b = 2[@@onSecondBinding ] let f : type t. t foo = - fun sideEffect -> - ((let module M = struct exception E of t end in - sideEffect (); (fun x -> M.E x)) - [@res.braces ]) -let f : type t x u. (t * x * y) list = fun l -> f l \ No newline at end of file + ((Function$ + (fun sideEffect -> + ((let module M = struct exception E of t end in + ((sideEffect ()) + [@res.uapp ]); + ((Function$ ((fun x -> M.E x))) + [@res.arity 1])) + [@res.braces ]))) + [@res.arity 1]) +let f : type t x u. (t * x * y) list = + ((Function$ (fun l -> ((f l)[@res.uapp ])))[@res.arity 1]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/structure/expected/modExprExtension.res.txt b/jscomp/syntax/tests/parsing/grammar/structure/expected/modExprExtension.res.txt index 88d3404548..866d9e8514 100644 --- a/jscomp/syntax/tests/parsing/grammar/structure/expected/modExprExtension.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/structure/expected/modExprExtension.res.txt @@ -1,4 +1,6 @@ module A = [%modExprExtension ] module B = [%mod.expr.extension ] module C = [%mod.expr.extension.with.args {js|argument|js}] -module D = [%mod.expr.extension.with.args fun x -> f x] \ No newline at end of file +module D = + [%mod.expr.extension.with.args + ((Function$ (fun x -> ((f x)[@res.uapp ])))[@res.arity 1])] \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/structure/expected/moduleTypeExtension.res.txt b/jscomp/syntax/tests/parsing/grammar/structure/expected/moduleTypeExtension.res.txt index 7b0932f9d6..7b8a5db29d 100644 --- a/jscomp/syntax/tests/parsing/grammar/structure/expected/moduleTypeExtension.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/structure/expected/moduleTypeExtension.res.txt @@ -1,4 +1,6 @@ module type A = [%modTypeExtension ] module type B = [%mod.type.extension ] module type C = [%mod.type.extension.with.args {js|argument|js}] -module type D = [%mod.type.extension.with.args fun x -> f x] \ No newline at end of file +module type D = + [%mod.type.extension.with.args + ((Function$ (fun x -> ((f x)[@res.uapp ])))[@res.arity 1])] \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/structure/expected/standaloneAttribute.res.txt b/jscomp/syntax/tests/parsing/grammar/structure/expected/standaloneAttribute.res.txt index 53adcb3bd6..b14fa69434 100644 --- a/jscomp/syntax/tests/parsing/grammar/structure/expected/standaloneAttribute.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/structure/expected/standaloneAttribute.res.txt @@ -1,3 +1,3 @@ [@@@standaloneAttribute ] [@@@standaloneAttribute {js|with payload|js}] -[@@@standaloneAttribute fun x -> x + 1] \ No newline at end of file +[@@@standaloneAttribute ((Function$ (fun x -> x + 1))[@res.arity 1])] \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/typedefinition/expected/constructorDeclaration.res.txt b/jscomp/syntax/tests/parsing/grammar/typedefinition/expected/constructorDeclaration.res.txt index 4e9f67379b..05bf6b484f 100644 --- a/jscomp/syntax/tests/parsing/grammar/typedefinition/expected/constructorDeclaration.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/typedefinition/expected/constructorDeclaration.res.txt @@ -83,11 +83,12 @@ type nonrec (_, 'value) node = mutable cachedValue: 'value ; parent: (_, 'value) node ; root: (root, 'value) node ; - updateF: 'value -> 'value ; + updateF: ('value -> 'value, [ `Has_arity1 ]) function$ ; mutable updatedTime: float } -> (derived, 'value) node type nonrec delta = - | Compute of (< blocked_ids: unit > -> unit) + | Compute of (< blocked_ids: unit > -> unit, [ `Has_arity1 ]) function$ type nonrec queryDelta = - | Compute of (< blocked_ids: unit > -> unit) - | Compute of (< blocked_ids: unit > -> unit) * - (< allowed_ids: unit > -> unit) \ No newline at end of file + | Compute of (< blocked_ids: unit > -> unit, [ `Has_arity1 ]) function$ + + | Compute of (< blocked_ids: unit > -> unit, [ `Has_arity1 ]) function$ + * (< allowed_ids: unit > -> unit, [ `Has_arity1 ]) function$ \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/typedefinition/expected/polyvariant.res.txt b/jscomp/syntax/tests/parsing/grammar/typedefinition/expected/polyvariant.res.txt index 5a20ac2614..105e2a5dfe 100644 --- a/jscomp/syntax/tests/parsing/grammar/typedefinition/expected/polyvariant.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/typedefinition/expected/polyvariant.res.txt @@ -55,4 +55,4 @@ type nonrec t = [< `x [@a ]] type nonrec t = [< `a of ((int * int) * int) [@one ] | ((int)[@two ]) | `b of string [@three ]> `w `x `y] -let f (x : [ `b ]) = x \ No newline at end of file +let f = ((Function$ (fun (x : [ `b ]) -> x))[@res.arity 1]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/typedefinition/expected/privateTypeEquation.res.txt b/jscomp/syntax/tests/parsing/grammar/typedefinition/expected/privateTypeEquation.res.txt index 388fc21c92..c4c2a63df9 100644 --- a/jscomp/syntax/tests/parsing/grammar/typedefinition/expected/privateTypeEquation.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/typedefinition/expected/privateTypeEquation.res.txt @@ -2,11 +2,13 @@ type nonrec t = private 'a type nonrec t = private string type nonrec t = private _ type nonrec t = private int -type nonrec t = private int -> int -type nonrec t = private int -> int -type nonrec t = private int -> int -> int +type nonrec t = private (int -> int, [ `Has_arity1 ]) function$ +type nonrec t = private (int -> int, [ `Has_arity1 ]) function$ type nonrec t = private - int -> x:((string)[@res.namedArgLoc ]) -> float -> unit + (int -> (int -> int, [ `Has_arity1 ]) function$, [ `Has_arity1 ]) function$ +type nonrec t = private + (int -> x:((string)[@res.namedArgLoc ]) -> float -> unit, [ `Has_arity3 ]) + function$ type nonrec t = private string as 'x type nonrec t = private [%ext ] type nonrec t = private [%ext {js|console.log|js}] diff --git a/jscomp/syntax/tests/parsing/grammar/typedefinition/expected/typeInformation.res.txt b/jscomp/syntax/tests/parsing/grammar/typedefinition/expected/typeInformation.res.txt index c684368fb3..68fe626531 100644 --- a/jscomp/syntax/tests/parsing/grammar/typedefinition/expected/typeInformation.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/typedefinition/expected/typeInformation.res.txt @@ -70,6 +70,9 @@ type nonrec t = private type nonrec t = { x: int ; y: int } -type nonrec callback = (ReactEvent.Mouse.t -> unit) as 'callback -type nonrec callback = ReactEvent.Mouse.t -> unit as 'u -type nonrec callback = (ReactEvent.Mouse.t -> unit) as 'callback \ No newline at end of file +type nonrec callback = + (ReactEvent.Mouse.t -> unit, [ `Has_arity1 ]) function$ as 'callback +type nonrec callback = + (ReactEvent.Mouse.t -> unit as 'u, [ `Has_arity1 ]) function$ +type nonrec callback = + (ReactEvent.Mouse.t -> unit, [ `Has_arity1 ]) function$ as 'callback \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/typexpr/expected/alias.res.txt b/jscomp/syntax/tests/parsing/grammar/typexpr/expected/alias.res.txt index 7cfd69415a..6633a87691 100644 --- a/jscomp/syntax/tests/parsing/grammar/typexpr/expected/alias.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/typexpr/expected/alias.res.txt @@ -1,10 +1,12 @@ type nonrec t = string as 's type nonrec t = _ as 'underscore type nonrec t = parenthesizedType as 'parens -type nonrec t = (int -> unit) as 'arrow -type nonrec t = int -> unit as 'unitAlias -type nonrec t = (int -> float -> unit) as 'arrowAlias -type nonrec t = int -> float -> unit as 'unitAlias +type nonrec t = (int -> unit, [ `Has_arity1 ]) function$ as 'arrow +type nonrec t = (int -> unit as 'unitAlias, [ `Has_arity1 ]) function$ +type nonrec t = + (int -> float -> unit, [ `Has_arity2 ]) function$ as 'arrowAlias +type nonrec t = + (int -> float -> unit as 'unitAlias, [ `Has_arity2 ]) function$ type nonrec t = int as 'myNumber type nonrec t = Mod.Sub.t as 'longidentAlias type nonrec t = (int as 'r, int as 'g, int as 'b) color as 'rgb @@ -16,10 +18,12 @@ type nonrec tup = ((int as 'x) * (int as 'y)) as 'tupleAlias let (t : string as 's) = () let (t : _ as 'underscore) = () let (t : parenthesizedType as 'parens) = () -let (t : (int -> unit) as 'arrow) = () -let (t : int -> unit as 'unitAlias) = () -let (t : (int -> float -> unit) as 'arrowAlias) = () -let (t : int -> float -> unit as 'unitAlias) = () +let (t : (int -> unit, [ `Has_arity1 ]) function$ as 'arrow) = () +let (t : (int -> unit as 'unitAlias, [ `Has_arity1 ]) function$) = () +let (t : (int -> float -> unit, [ `Has_arity2 ]) function$ as 'arrowAlias) = + () +let (t : (int -> float -> unit as 'unitAlias, [ `Has_arity2 ]) function$) = + () let (t : int as 'myNumber) = () let (t : Mod.Sub.t as 'longidentAlias) = () let (t : (int as 'r, int as 'g, int as 'b) color as 'rgb) = () diff --git a/jscomp/syntax/tests/parsing/grammar/typexpr/expected/es6Arrow.res.txt b/jscomp/syntax/tests/parsing/grammar/typexpr/expected/es6Arrow.res.txt index f3f3b4b237..44c8a7b3ba 100644 --- a/jscomp/syntax/tests/parsing/grammar/typexpr/expected/es6Arrow.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/typexpr/expected/es6Arrow.res.txt @@ -1,46 +1,77 @@ -type nonrec t = x -> unit -type nonrec t = x -> unit -type nonrec t = int -> string -> unit +type nonrec t = (x -> unit, [ `Has_arity1 ]) function$ +type nonrec t = (x -> unit, [ `Has_arity1 ]) function$ +type nonrec t = (int -> string -> unit, [ `Has_arity2 ]) function$ type nonrec t = - a:((int)[@res.namedArgLoc ]) -> b:((int)[@res.namedArgLoc ]) -> int + (a:((int)[@res.namedArgLoc ]) -> b:((int)[@res.namedArgLoc ]) -> int, + [ `Has_arity2 ]) function$ type nonrec t = - ?a:((int)[@res.namedArgLoc ]) -> ?b:((int)[@res.namedArgLoc ]) -> int -type nonrec t = int -> int -> int -> int + (?a:((int)[@res.namedArgLoc ]) -> ?b:((int)[@res.namedArgLoc ]) -> int, + [ `Has_arity2 ]) function$ type nonrec t = - a:((int)[@res.namedArgLoc ]) -> - b:((int)[@res.namedArgLoc ]) -> c:((int)[@res.namedArgLoc ]) -> int -let (f : x -> unit) = xf -let (f : x -> unit) = xf -let (f : int -> string -> unit) = xf -let (t : a:((int)[@res.namedArgLoc ]) -> b:((int)[@res.namedArgLoc ]) -> int) + (int -> + (int -> (int -> int, [ `Has_arity1 ]) function$, [ `Has_arity1 ]) + function$, + [ `Has_arity1 ]) function$ +type nonrec t = + (a:((int)[@res.namedArgLoc ]) -> + (b:((int)[@res.namedArgLoc ]) -> + (c:((int)[@res.namedArgLoc ]) -> int, [ `Has_arity1 ]) function$, + [ `Has_arity1 ]) function$, + [ `Has_arity1 ]) function$ +let (f : (x -> unit, [ `Has_arity1 ]) function$) = xf +let (f : (x -> unit, [ `Has_arity1 ]) function$) = xf +let (f : (int -> string -> unit, [ `Has_arity2 ]) function$) = xf +let (t : + (a:((int)[@res.namedArgLoc ]) -> b:((int)[@res.namedArgLoc ]) -> int, + [ `Has_arity2 ]) function$) + = xf +let (t : + (?a:((int)[@res.namedArgLoc ]) -> ?b:((int)[@res.namedArgLoc ]) -> int, + [ `Has_arity2 ]) function$) = xf let (t : - ?a:((int)[@res.namedArgLoc ]) -> ?b:((int)[@res.namedArgLoc ]) -> int) = xf -let (t : int -> int -> int -> int) = xf + (int -> + (int -> (int -> int, [ `Has_arity1 ]) function$, [ `Has_arity1 ]) + function$, + [ `Has_arity1 ]) function$) + = xf let (t : - a:((int)[@res.namedArgLoc ]) -> - b:((int)[@res.namedArgLoc ]) -> c:((int)[@res.namedArgLoc ]) -> int) + (a:((int)[@res.namedArgLoc ]) -> + (b:((int)[@res.namedArgLoc ]) -> + (c:((int)[@res.namedArgLoc ]) -> int, [ `Has_arity1 ]) function$, + [ `Has_arity1 ]) function$, + [ `Has_arity1 ]) function$) = xf type nonrec t = f:((int)[@res.namedArgLoc ]) -> string type nonrec t = ?f:((int)[@res.namedArgLoc ]) -> string let (f : f:((int)[@res.namedArgLoc ]) -> string) = fx let (f : ?f:((int)[@res.namedArgLoc ]) -> string) = fx +type nonrec t = + (f:((int)[@res.namedArgLoc ]) -> string, [ `Has_arity1 ]) function$ type nonrec t = f:((int)[@res.namedArgLoc ]) -> string -type nonrec t = f:((int)[@res.namedArgLoc ]) -> string -type nonrec t = f:((int -> string)[@res.namedArgLoc ]) -> float -type nonrec t = f:((int -> string)[@res.namedArgLoc ]) -> float -type nonrec t = f:((int)[@res.namedArgLoc ]) -> string -> float type nonrec t = - ((a:((int)[@res.namedArgLoc ]) -> - ((b:((int)[@res.namedArgLoc ]) -> ((float)[@attr ]) -> unit)[@attrBeforeLblB - ])) - [@attrBeforeLblA ]) + (f:(((int -> string, [ `Has_arity1 ]) function$)[@res.namedArgLoc ]) -> + float, + [ `Has_arity1 ]) function$ +type nonrec t = + f:(((int -> string, [ `Has_arity1 ]) function$)[@res.namedArgLoc ]) -> + float type nonrec t = - ((a:((int)[@res.namedArgLoc ]) -> - ((b:((int)[@res.namedArgLoc ]) -> ((float)[@attr ]) -> unit)[@attrBeforeLblB + f:((int)[@res.namedArgLoc ]) -> + (string -> float, [ `Has_arity1 ]) function$ +type nonrec t = + (((a:((int)[@res.namedArgLoc ]) -> + ((b:((int)[@res.namedArgLoc ]) -> ((float)[@attr ]) -> unit)[@attrBeforeLblB ])) - [@attrBeforeLblA ]) + [@attrBeforeLblA ]), [ `Has_arity3 ]) function$ +type nonrec t = + (((a:((int)[@res.namedArgLoc ]) -> + (((b:((int)[@res.namedArgLoc ]) -> + (((float)[@attr ]) -> unit, [ `Has_arity1 ]) function$, + [ `Has_arity1 ]) function$)[@attrBeforeLblB ]), + [ `Has_arity1 ]) function$)[@attrBeforeLblA ]) type nonrec t = ((a:((int)[@res.namedArgLoc ]) -> unit)[@attr ]) type nonrec 'a getInitialPropsFn = - < query: string Js.Dict.t ;req: 'a Js.t Js.Nullable.t > -> - 'a Js.t Js.Promise.t \ No newline at end of file + (< query: string Js.Dict.t ;req: 'a Js.t Js.Nullable.t > -> + 'a Js.t Js.Promise.t, + [ `Has_arity1 ]) function$ \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/typexpr/expected/firstClassModules.res.txt b/jscomp/syntax/tests/parsing/grammar/typexpr/expected/firstClassModules.res.txt index 0c21329877..9349ef39a6 100644 --- a/jscomp/syntax/tests/parsing/grammar/typexpr/expected/firstClassModules.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/typexpr/expected/firstClassModules.res.txt @@ -2,7 +2,9 @@ type nonrec t = (module Hashmap) type nonrec t = (module Hashmap with type key = string) type nonrec t = (module Hashmap with type key = string and type value = int) type nonrec toValueLikeInstance = - 'a t -> (module RxValueLikeInstance.S with type a = 'a) + ('a t -> (module RxValueLikeInstance.S with type a = 'a), [ `Has_arity1 ]) + function$ type nonrec 'a t = (module Test with type a = 'a) type nonrec t = (module Console) ref -let (devices : (string, (module DEVICE)) Hastbl.t) = Hashtbl.creat 17 \ No newline at end of file +let (devices : (string, (module DEVICE)) Hastbl.t) = ((Hashtbl.creat 17) + [@res.uapp ]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/typexpr/expected/objectTypeSpreading.res.txt b/jscomp/syntax/tests/parsing/grammar/typexpr/expected/objectTypeSpreading.res.txt index 32c553f3bb..d022b4c704 100644 --- a/jscomp/syntax/tests/parsing/grammar/typexpr/expected/objectTypeSpreading.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/typexpr/expected/objectTypeSpreading.res.txt @@ -3,9 +3,10 @@ type nonrec u = < a ;u: int > type nonrec v = < v: int ;a > type nonrec w = < j: int ;a ;k: int ;v > type nonrec t = < a ;u: int > as 'a -type nonrec t = < a ;u: int > -> unit -type nonrec t = (< a ;u: int > as 'a) -> unit -type nonrec t = < a ;u: int > -> < a ;v: int > -> unit +type nonrec t = (< a ;u: int > -> unit, [ `Has_arity1 ]) function$ +type nonrec t = ((< a ;u: int > as 'a) -> unit, [ `Has_arity1 ]) function$ +type nonrec t = + (< a ;u: int > -> < a ;v: int > -> unit, [ `Has_arity2 ]) function$ type nonrec user = < name: string > let (steve : < user ;age: int > ) = [%obj { name = {js|Steve|js}; age = 30 }] @@ -14,16 +15,30 @@ let steve = let steve = ((([%obj { name = {js|Steve|js}; age = 30 }] : < user ;age: int > )) [@res.braces ]) -let printFullUser (steve : < user ;age: int > ) = Js.log steve -let printFullUser ~user:(((user : < user ;age: int > ))[@res.namedArgLoc ]) - = Js.log steve -let printFullUser ~user:(((user : < user ;age: int > ))[@res.namedArgLoc ]) - = Js.log steve -let printFullUser ?user:(((user)[@res.namedArgLoc ])= - (steve : < user ;age: int > )) = Js.log steve +let printFullUser = + ((Function$ + (fun (steve : < user ;age: int > ) -> ((Js.log steve)[@res.uapp ]))) + [@res.arity 1]) +let printFullUser = + ((Function$ + (fun ~user:(((user : < user ;age: int > ))[@res.namedArgLoc ]) -> + ((Js.log steve)[@res.uapp ]))) + [@res.arity 1]) +let printFullUser = + ((Function$ + (fun ~user:(((user : < user ;age: int > ))[@res.namedArgLoc ]) -> + ((Js.log steve)[@res.uapp ]))) + [@res.arity 1]) +let printFullUser = + ((Function$ + (fun ?user:(((user)[@res.namedArgLoc ])= + (steve : < user ;age: int > )) -> ((Js.log steve)[@res.uapp ]))) + [@res.arity 1]) external steve : < user ;age: int > = "steve"[@@val ] -let makeCeoOf30yearsOld name = - ([%obj { name; age = 30 }] : < user ;age: int > ) +let makeCeoOf30yearsOld = + ((Function$ + (fun name -> ([%obj { name; age = 30 }] : < user ;age: int > ))) + [@res.arity 1]) type nonrec optionalUser = < user ;age: int > option type nonrec optionalTupleUser = (< user ;age: int > * < user ;age: int > ) option diff --git a/jscomp/syntax/tests/parsing/grammar/typexpr/expected/parenthesized.res.txt b/jscomp/syntax/tests/parsing/grammar/typexpr/expected/parenthesized.res.txt index 4fc6efd381..8c63ded5b0 100644 --- a/jscomp/syntax/tests/parsing/grammar/typexpr/expected/parenthesized.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/typexpr/expected/parenthesized.res.txt @@ -1 +1,3 @@ -type nonrec t = ((a:((int)[@res.namedArgLoc ]) -> unit)[@attr ]) \ No newline at end of file +type nonrec t = + (((a:((int)[@res.namedArgLoc ]) -> unit, [ `Has_arity1 ]) function$) + [@attr ]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/typexpr/expected/poly.res.txt b/jscomp/syntax/tests/parsing/grammar/typexpr/expected/poly.res.txt index efa667ded0..541ac45227 100644 --- a/jscomp/syntax/tests/parsing/grammar/typexpr/expected/poly.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/typexpr/expected/poly.res.txt @@ -1,6 +1,10 @@ external getLogger : - unit -> - < - log: 'a -> unit ;log2: 'a . int -> int ;log3: 'a 'b . 'a -> 'b -> int - > = - "./src/logger.mock.js" \ No newline at end of file + (unit -> + < + log: ('a -> unit, [ `Has_arity1 ]) function$ ;log2: 'a . + (int -> int, + [ + `Has_arity1 ]) + function$ ; + log3: 'a 'b . ('a -> 'b -> int, [ `Has_arity2 ]) function$ > , + [ `Has_arity1 ]) function$ = "./src/logger.mock.js" \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/typexpr/expected/polyVariant.res.txt b/jscomp/syntax/tests/parsing/grammar/typexpr/expected/polyVariant.res.txt index 8d271258b5..d268ca5a8f 100644 --- a/jscomp/syntax/tests/parsing/grammar/typexpr/expected/polyVariant.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/typexpr/expected/polyVariant.res.txt @@ -3,11 +3,15 @@ module type Conjunctive = sig type nonrec u1 = [ `A | `B ] type nonrec u2 = [ `A | `B | `C ] - val f : [< `T of [< u2]&[< u2]&[< u1] ] -> unit - val g : [< `S of [< u2]&[< u2]&[< u1] ] -> unit + val f : + ([< `T of [< u2]&[< u2]&[< u1] ] -> unit, [ `Has_arity1 ]) function$ val g : - [< `Exotic-S+ of [< `Exotic-u2+ ]&[< `Exotic-u2- ]&[< `Exotic-u1+++ ] ] - -> unit + ([< `S of [< u2]&[< u2]&[< u1] ] -> unit, [ `Has_arity1 ]) function$ + val g : + ([< + `Exotic-S+ of [< `Exotic-u2+ ]&[< `Exotic-u2- ]&[< `Exotic-u1+++ ] ] + -> unit, + [ `Has_arity1 ]) function$ end type nonrec t = [ s] type nonrec t = [ ListStyleType.t] diff --git a/jscomp/syntax/tests/parsing/grammar/typexpr/expected/typeconstr.res.txt b/jscomp/syntax/tests/parsing/grammar/typexpr/expected/typeconstr.res.txt index 96ade729d5..7df7e5a953 100644 --- a/jscomp/syntax/tests/parsing/grammar/typexpr/expected/typeconstr.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/typexpr/expected/typeconstr.res.txt @@ -60,5 +60,5 @@ type nonrec ('T, 'E) id_6 = | Ok of 'T | Err of { payload: 'E } -let foo (x : int as 'X) = x +let foo = ((Function$ (fun (x : int as 'X) -> x))[@res.arity 1]) module type A = (Foo with type t = 'X constraint 'X = int) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/typexpr/expected/uncurried.res.txt b/jscomp/syntax/tests/parsing/grammar/typexpr/expected/uncurried.res.txt index 126cacdee2..bf6ecb648d 100644 --- a/jscomp/syntax/tests/parsing/grammar/typexpr/expected/uncurried.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/typexpr/expected/uncurried.res.txt @@ -4,25 +4,22 @@ type nonrec t = type nonrec t = (float -> int -> bool -> unit, [ `Has_arity3 ]) function$ type nonrec t = (((float)[@attr ]) -> - ((int)[@attr2 ]) -> - (((bool)[@attr3 ]) -> ((string)[@attr4 ]) -> unit, [ `Has_arity2 ]) - function$, - [ `Has_arity2 ]) function$ + ((int)[@attr2 ]) -> ((bool)[@attr3 ]) -> ((string)[@attr4 ]) -> unit, + [ `Has_arity4 ]) function$ type nonrec t = (((float -> - ((int)[@attr2 ]) -> - (((bool -> ((string)[@attr4 ]) -> unit, [ `Has_arity1 ]) function$) - [@attr3 ]), + (((int)[@attr2 ]) -> + (((bool -> (((string)[@attr4 ]) -> unit, [ `Has_arity1 ]) function$, + [ `Has_arity1 ]) function$)[@attr3 ]), + [ `Has_arity1 ]) function$, [ `Has_arity1 ]) function$)[@attr ]) type nonrec t = (((float)[@attr ]) -> - ((int)[@attr2 ]) -> - (((bool)[@attr3 ]) -> ((string)[@attr4 ]) -> unit, [ `Has_arity2 ]) - function$, - [ `Has_arity2 ]) function$ + ((int)[@attr2 ]) -> ((bool)[@attr3 ]) -> ((string)[@attr4 ]) -> unit, + [ `Has_arity4 ]) function$ external setTimeout : - (unit -> unit, [ `Has_arity1 ]) function$ -> int -> timerId = "setTimeout" -[@@val ] + ((unit -> unit, [ `Has_arity1 ]) function$ -> int -> timerId, + [ `Has_arity2 ]) function$ = "setTimeout"[@@val ] external setTimeout : - ((unit -> unit) -> int -> timerId, [ `Has_arity2 ]) function$ = - "setTimeout" \ No newline at end of file + ((unit -> unit, [ `Has_arity1 ]) function$ -> int -> timerId, + [ `Has_arity2 ]) function$ = "setTimeout" \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/typexpr/expected/unit.res.txt b/jscomp/syntax/tests/parsing/grammar/typexpr/expected/unit.res.txt index f7db235e63..ff4b761fe8 100644 --- a/jscomp/syntax/tests/parsing/grammar/typexpr/expected/unit.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/typexpr/expected/unit.res.txt @@ -1,9 +1,21 @@ type nonrec t = unit -type nonrec t = unit -> unit -type nonrec t = unit -> unit -> unit -type nonrec t = unit -> unit -let f (f : unit -> unit) = f () -let f (f : unit -> unit) = f () -let f (f : unit -> unit -> unit) = f () () -external svg : unit -> React.element = "svg" -external thing : unit -> unit = "svg" \ No newline at end of file +type nonrec t = (unit -> unit, [ `Has_arity1 ]) function$ +type nonrec t = (unit -> unit -> unit, [ `Has_arity2 ]) function$ +type nonrec t = (unit -> unit, [ `Has_arity1 ]) function$ +let f = + ((Function$ + (fun (f : (unit -> unit, [ `Has_arity1 ]) function$) -> ((f ()) + [@res.uapp ]))) + [@res.arity 1]) +let f = + ((Function$ + (fun (f : (unit -> unit, [ `Has_arity1 ]) function$) -> ((f ()) + [@res.uapp ]))) + [@res.arity 1]) +let f = + ((Function$ + (fun (f : (unit -> unit -> unit, [ `Has_arity2 ]) function$) -> + ((f () ())[@res.uapp ]))) + [@res.arity 1]) +external svg : (unit -> React.element, [ `Has_arity1 ]) function$ = "svg" +external thing : (unit -> unit, [ `Has_arity1 ]) function$ = "svg" \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/infiniteLoops/expected/equalAfterBinaryExpr.res.txt b/jscomp/syntax/tests/parsing/infiniteLoops/expected/equalAfterBinaryExpr.res.txt index c317935a47..aef1717ef0 100644 --- a/jscomp/syntax/tests/parsing/infiniteLoops/expected/equalAfterBinaryExpr.res.txt +++ b/jscomp/syntax/tests/parsing/infiniteLoops/expected/equalAfterBinaryExpr.res.txt @@ -10,147 +10,199 @@ Did you mean `==` here? -let rec _addLoop rbt currentNode = - ((if (Some currentNode) == (rbt |. root) - then currentNode.color <- Black - else - if (currentNode.parent |. castNotOption).color == Black - then () - else - if - (((let uncle = uncleOf currentNode in - (uncle != None) && ((uncle |. castNotOption).color == Red))) - [@res.braces ]) - then - ((currentNode.parent |. castNotOption).color <- Black; - ((uncleOf currentNode) |. castNotOption).color <- Black; - ((grandParentOf currentNode) |. castNotOption).color <- Red; - _addLoop rbt ((grandParentOf currentNode) |. castNotOption)) - else - (let currentNode = - if - (not (isLeft currentNode)) && - (isLeft (currentNode.parent |. castNotOption)) - then - (rotateLeft rbt (currentNode.parent |. castNotOption); - currentNode.left |. castNotOption) +let rec _addLoop = + ((Function$ + (fun rbt -> + fun currentNode -> + ((if (Some currentNode) == (rbt |.u root) + then currentNode.color <- Black else - if - (isLeft currentNode) && - (not (isLeft (currentNode.parent |. castNotOption))) - then - (rotateRight rbt (currentNode.parent |. castNotOption); - currentNode.right |. castNotOption) - else currentNode in - (currentNode.parent |. castNotOption).color <- Black; - ((grandParentOf currentNode) |. castNotOption).color <- Red; - if isLeft currentNode - then - rotateRight rbt ((grandParentOf currentNode) |. castNotOption) - else rotateLeft rbt ((grandParentOf currentNode) |. castNotOption))) - [@res.braces ]) -let removeNode rbt node = - ((if nodeToRemove.color == Black - then - (if successor.color == Red - then - (successor.color <- Black; - if successor.parent == None then rbt |. (rootSet (Some successor))) - else - (let break = ref false in - let successorRef = ref successor in - while not break.contents do - let successor = successorRef.contents in - match successor.parent with - | None -> - (rbt |. (rootSet (Some successor)); break.contents <- true) - | Some successorParent -> - let sibling = siblingOf successor in - (if - (sibling != None) && - ((sibling |. castNotOption).color == Red) + if (currentNode.parent |.u castNotOption).color == Black + then () + else + if + (((let uncle = ((uncleOf currentNode)[@res.uapp ]) in + (uncle != None) && + ((uncle |.u castNotOption).color == Red))) + [@res.braces ]) then - (successorParent.color <- Red; - (sibling |. castNotOption).color <- Black; - if isLeft successor - then rotateLeft rbt successorParent - else rotateRight rbt successorParent); - (let sibling = siblingOf successor in - let siblingNN = sibling |. castNotOption in - if - (successorParent.color == Black) && - ((sibling == None) || - (((siblingNN.color == Black) && - ((siblingNN.left == None) || - ((siblingNN.left |. castNotOption).color == - Black))) - && - ((siblingNN.right == None) || - ((siblingNN.right |. castNotOption).color == - Black)))) - then - (if sibling != None then siblingNN.color <- Red; - successorRef.contents <- successorParent) - else - if - (successorParent.color == Red) && - ((sibling == None) || - (((siblingNN.color == Black) && - ((siblingNN.left == None) || - ((siblingNN.left |. castNotOption).color == - Black))) - && - ((siblingNN.right == None) || - ((siblingNN.right |. castNotOption).color == - Black)))) - then - (if sibling != None then siblingNN.color <- Red; - successorParent.color <- Black; - break.contents <- true) - else + ((currentNode.parent |.u castNotOption).color <- Black; + (((uncleOf currentNode)[@res.uapp ]) |.u castNotOption).color + <- Black; + (((grandParentOf currentNode)[@res.uapp ]) |.u + castNotOption).color + <- Red; + ((_addLoop rbt + (((grandParentOf currentNode)[@res.uapp ]) |.u + castNotOption)) + [@res.uapp ])) + else + (let currentNode = if - (sibling != None) && - ((sibling |. castNotOption).color == Black) + (not ((isLeft currentNode)[@res.uapp ])) && + ((isLeft (currentNode.parent |.u castNotOption)) + [@res.uapp ]) then - (let sibling = sibling |. castNotOption in - if - (((isLeft successor) && - ((sibling.right == None) || - ((sibling.right |. castNotOption).color == - Black))) - && (sibling.left != None)) - && - ((sibling.left |. castNotOption).color == Red) - then - (sibling.color <- Red; - (sibling.left |. castNotOption).color <- Black; - rotateRight rbt sibling) - else + (((rotateLeft rbt + (currentNode.parent |.u castNotOption)) + [@res.uapp ]); + currentNode.left |.u castNotOption) + else + if + ((isLeft currentNode)[@res.uapp ]) && + (not + ((isLeft + (currentNode.parent |.u castNotOption)) + [@res.uapp ])) + then + (((rotateRight rbt + (currentNode.parent |.u castNotOption)) + [@res.uapp ]); + currentNode.right |.u castNotOption) + else currentNode in + (currentNode.parent |.u castNotOption).color <- Black; + (((grandParentOf currentNode)[@res.uapp ]) |.u + castNotOption).color + <- Red; + if ((isLeft currentNode)[@res.uapp ]) + then + ((rotateRight rbt + (((grandParentOf currentNode)[@res.uapp ]) |.u + castNotOption)) + [@res.uapp ]) + else + ((rotateLeft rbt + (((grandParentOf currentNode)[@res.uapp ]) |.u + castNotOption)) + [@res.uapp ]))) + [@res.braces ]))) + [@res.arity 2]) +let removeNode = + ((Function$ + (fun rbt -> + fun node -> + ((if nodeToRemove.color == Black + then + (if successor.color == Red + then + (successor.color <- Black; + if successor.parent == None + then rbt |.u ((rootSet (Some successor))[@res.uapp ])) + else + (let break = ((ref false)[@res.uapp ]) in + let successorRef = ((ref successor)[@res.uapp ]) in + while not break.contents do + let successor = successorRef.contents in + match successor.parent with + | None -> + (rbt |.u ((rootSet (Some successor))[@res.uapp ]); + break.contents <- true) + | Some successorParent -> + let sibling = ((siblingOf successor)[@res.uapp ]) in + (if + (sibling != None) && + ((sibling |.u castNotOption).color == Red) + then + (successorParent.color <- Red; + (sibling |.u castNotOption).color <- Black; + if ((isLeft successor)[@res.uapp ]) + then ((rotateLeft rbt successorParent) + [@res.uapp ]) + else ((rotateRight rbt successorParent) + [@res.uapp ])); + (let sibling = ((siblingOf successor)[@res.uapp ]) in + let siblingNN = sibling |.u castNotOption in if - (((not (isLeft successor)) && - ((sibling.left == None) || - ((sibling.left |. castNotOption).color == - Black))) - && (sibling.right != None)) - && - ((sibling.right |. castNotOption).color == Red) + (successorParent.color == Black) && + ((sibling == None) || + (((siblingNN.color == Black) && + ((siblingNN.left == None) || + ((siblingNN.left |.u castNotOption).color + == Black))) + && + ((siblingNN.right == None) || + ((siblingNN.right |.u castNotOption).color + == Black)))) then - (sibling.color <- Red; - (sibling.right |. castNotOption).color <- Black; - rotateLeft rbt sibling); - break.contents <- true) - else - (let sibling = siblingOf successor in - let sibling = sibling |. castNotOption in - sibling.color <- (successorParent.color); - if isLeft successor - then - ((sibling.right |. castNotOption).color <- Black; - rotateRight rbt successorParent) - else - ((sibling.left |. castNotOption).color <- Black; - rotateLeft rbt successorParent)))) - done)); - if ((isLeaf successor)[@res.uapp ]) - then (if (rbt |. root) == (Some successor) then (rbt |. root) = None)) - [@res.braces ]) \ No newline at end of file + (if sibling != None then siblingNN.color <- Red; + successorRef.contents <- successorParent) + else + if + (successorParent.color == Red) && + ((sibling == None) || + (((siblingNN.color == Black) && + ((siblingNN.left == None) || + ((siblingNN.left |.u castNotOption).color + == Black))) + && + ((siblingNN.right == None) || + ((siblingNN.right |.u castNotOption).color + == Black)))) + then + (if sibling != None + then siblingNN.color <- Red; + successorParent.color <- Black; + break.contents <- true) + else + if + (sibling != None) && + ((sibling |.u castNotOption).color == + Black) + then + (let sibling = sibling |.u castNotOption in + if + ((((isLeft successor)[@res.uapp ]) && + ((sibling.right == None) || + ((sibling.right |.u castNotOption).color + == Black))) + && (sibling.left != None)) + && + ((sibling.left |.u castNotOption).color + == Red) + then + (sibling.color <- Red; + (sibling.left |.u castNotOption).color + <- Black; + ((rotateRight rbt sibling) + [@res.uapp ])) + else + if + (((not ((isLeft successor)[@res.uapp ])) + && + ((sibling.left == None) || + ((sibling.left |.u castNotOption).color + == Black))) + && (sibling.right != None)) + && + ((sibling.right |.u castNotOption).color + == Red) + then + (sibling.color <- Red; + (sibling.right |.u castNotOption).color + <- Black; + ((rotateLeft rbt sibling) + [@res.uapp ])); + break.contents <- true) + else + (let sibling = ((siblingOf successor) + [@res.uapp ]) in + let sibling = sibling |.u castNotOption in + sibling.color <- (successorParent.color); + if ((isLeft successor)[@res.uapp ]) + then + ((sibling.right |.u castNotOption).color + <- Black; + ((rotateRight rbt successorParent) + [@res.uapp ])) + else + ((sibling.left |.u castNotOption).color + <- Black; + ((rotateLeft rbt successorParent) + [@res.uapp ]))))) + done)); + if ((isLeaf successor)[@res.uapp ]) + then + (if (rbt |.u root) == (Some successor) + then (rbt |.u root) = None)) + [@res.braces ]))) + [@res.arity 2]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/infiniteLoops/expected/nonRecTypes.res.txt b/jscomp/syntax/tests/parsing/infiniteLoops/expected/nonRecTypes.res.txt index 1db620ae15..f29702c160 100644 --- a/jscomp/syntax/tests/parsing/infiniteLoops/expected/nonRecTypes.res.txt +++ b/jscomp/syntax/tests/parsing/infiniteLoops/expected/nonRecTypes.res.txt @@ -86,33 +86,39 @@ include [@res.template ]) ;;Arity_2 (value, value) ;;int - ;;(t value) = {js||js} + ;;((t value)[@res.uapp ]) = {js||js} ;;{js|BS:6.0.1\x84\x95\xa6\xbe\0\0\0#\0\0\0\r\0\0\0&\0\0\0#\x91\xa0\xa0A\xa0$size@\xa0\xa0A\xa0$root@\xa0\xa0A\xa0'compare@@|js} - external sizeSet : 'value t -> int -> unit = "size" + external sizeSet : + ('value t -> int -> unit, [ `Has_arity2 ]) function$ = "size" ;;{js|BS:6.0.1\x84\x95\xa6\xbe\0\0\0\x15\0\0\0\t\0\0\0\x1a\0\0\0\x19\xb0\xa0\xa0A\x91@\xa0\xa0A\x04\x03@E\x97\xa0$size@|js} ;;[|(({js|use sizeGet instead or use {abstract = light} explicitly|js}) [@ocaml.deprecated ])|] ;;[|((1)[@internal.arity ])|] - external size : 'value t -> int = "" + external size : ('value t -> int, [ `Has_arity1 ]) function$ = "" ;;{js|BS:6.0.1\x84\x95\xa6\xbe\0\0\0\x10\0\0\0\x07\0\0\0\x14\0\0\0\x13\xb0\xa0\xa0A\x91@@A\x98\xa0$size@|js} ;;[|((1)[@internal.arity ])|] - external sizeGet : 'value t -> int = "" + external sizeGet : ('value t -> int, [ `Has_arity1 ]) function$ = "" ;;{js|BS:6.0.1\x84\x95\xa6\xbe\0\0\0\x10\0\0\0\x07\0\0\0\x14\0\0\0\x13\xb0\xa0\xa0A\x91@@A\x98\xa0$size@|js} - external rootSet : 'value t -> 'value node option -> unit = "root" + external rootSet : + ('value t -> 'value node option -> unit, [ `Has_arity2 ]) function$ + = "root" ;;{js|BS:6.0.1\x84\x95\xa6\xbe\0\0\0\x15\0\0\0\t\0\0\0\x1a\0\0\0\x19\xb0\xa0\xa0A\x91@\xa0\xa0A\x04\x03@E\x97\xa0$root@|js} ;;[|(({js|use rootGet instead or use {abstract = light} explicitly|js}) [@ocaml.deprecated ])|] ;;[|((1)[@internal.arity ])|] - external root : 'value t -> 'value node option = "" + external root : + ('value t -> 'value node option, [ `Has_arity1 ]) function$ = "" ;;{js|BS:6.0.1\x84\x95\xa6\xbe\0\0\0\x10\0\0\0\x07\0\0\0\x14\0\0\0\x13\xb0\xa0\xa0A\x91@@A\x98\xa0$root@|js} ;;[|((1)[@internal.arity ])|] - external rootGet : 'value t -> 'value node option = "" + external rootGet : + ('value t -> 'value node option, [ `Has_arity1 ]) function$ = "" ;;{js|BS:6.0.1\x84\x95\xa6\xbe\0\0\0\x10\0\0\0\x07\0\0\0\x14\0\0\0\x13\xb0\xa0\xa0A\x91@@A\x98\xa0$root@|js} ;;[|(({js|use compareGet instead or use {abstract = light} explicitly|js}) [@ocaml.deprecated ])|] ;;[|((1)[@internal.arity ])|] external compare : - 'value t -> [ [%rescript.typehole ]] Js.Internal.fn + ('value t -> [ [%rescript.typehole ]] Js.Internal.fn, + [ `Has_arity1 ]) function$ ;;(({js|Arity_2('value, 'value)], int) = "" "BS:6.0.1\x84\x95\xa6\xbe\0\0\0\x13\0\0\0\x07\0\0\0\x14\0\0\0\x13\xb0\xa0\xa0A\x91@@A\x98\xa0'compare@"; @@ -125,326 +131,614 @@ include ;;{js||js} ;;{js|BS:6.0.1\x84\x95\xa6\xbe\0\0\0\x13\0\0\0\x07\0\0\0\x14\0\0\0\x13\xb0\xa0\xa0A\x91@@A\x98\xa0'compare@|js} end - let has rbt value = (_findNode rbt (rootGet rbt) value) != None - let rec minNode node = [%rescript.exprhole ] - let findMin rbt = [%rescript.exprhole ] - let removeNode rbt node = - ((let nodeToRemove = - match ((leftGet node), (rightGet node)) with - | (Some _, Some _) -> - let successor = castNotOption (minNode (rightGet node)) in - (valueSet node (valueGet successor); - heightSet node (heightGet successor); - successor) - | _ -> node in - let successor = - match leftGet nodeToRemove with - | None -> rightGet nodeToRemove - | left -> left in - let (successor, isLeaf) = - match successor with - | None -> - let leaf = - createNode ~value:((Js.Internal.raw_expr {js|0|js}) - [@res.namedArgLoc ]) ~color:((Black)[@res.namedArgLoc ]) - ~height:((0.)[@res.namedArgLoc ]) in - let isLeaf = Js.Internal.fn_mk1 (fun x -> x == leaf) in - (leaf, isLeaf) - | Some successor -> - (successor, (Js.Internal.fn_mk1 (fun _ -> false))) in - let nodeParent = parentGet nodeToRemove in - parentSet successor nodeParent; - (match nodeParent with - | None -> () - | Some parent -> - leftOrRightSet parent ~node:((nodeToRemove)[@res.namedArgLoc ]) - (Some successor)); - updateSumRecursive rbt successor; - if (colorGet nodeToRemove) == Black - then - (if (colorGet successor) == Red - then - (colorSet successor Black; - if (parentGet successor) == None - then rootSet rbt (Some successor)) - else - (let break = ref false in - let successorRef = ref successor in - while not break.contents do - let successor = successorRef.contents in - match parentGet successor with - | None -> - (rootSet rbt (Some successor); break.contents <- true) - | Some successorParent -> - let sibling = siblingOf successor in - (if - (sibling != None) && - ((colorGet (castNotOption sibling)) == Red) - then - (colorSet successorParent Red; - colorSet (castNotOption sibling) Black; - if isLeft successor - then rotateLeft rbt successorParent - else rotateRight rbt successorParent); - (let sibling = siblingOf successor in - let siblingNN = castNotOption sibling in - if - ((colorGet successorParent) == Black) && - ((sibling == None) || - ((((colorGet siblingNN) == Black) && - (((leftGet siblingNN) == None) || - ((colorGet - (castNotOption (leftGet siblingNN))) - == Black))) - && - (((rightGet siblingNN) == None) || - ((colorGet - (castNotOption (rightGet siblingNN))) - == Black)))) - then - (if sibling != None then colorSet siblingNN Red; - successorRef.contents <- successorParent) - else - if - ((colorGet successorParent) == Red) && - ((sibling == None) || - ((((colorGet siblingNN) == Black) && - (((leftGet siblingNN) == None) || - ((colorGet - (castNotOption (leftGet siblingNN))) - == Black))) - && - (((rightGet siblingNN) == None) || - ((colorGet - (castNotOption (rightGet siblingNN))) - == Black)))) - then - (if sibling != None then colorSet siblingNN Red; - colorSet successorParent Black; - break.contents <- true) - else - if - (sibling != None) && - ((colorGet (castNotOption sibling)) == Black) - then - (let sibling = castNotOption sibling in - if - (((isLeft successor) && - (((rightGet sibling) == None) || - ((colorGet - (castNotOption (rightGet sibling))) - == Black))) - && ((leftGet sibling) != None)) - && - ((colorGet (castNotOption (leftGet sibling))) - == Red) - then - (colorSet sibling Red; - colorSet (castNotOption (leftGet sibling)) - Black; - rotateRight rbt sibling) - else + let has = + ((Function$ + (fun rbt -> + fun value -> + ((_findNode rbt ((rootGet rbt)[@res.uapp ]) value) + [@res.uapp ]) != None)) + [@res.arity 2]) + let rec minNode = ((Function$ (fun node -> [%rescript.exprhole ])) + [@res.arity 1]) + let findMin = ((Function$ (fun rbt -> [%rescript.exprhole ])) + [@res.arity 1]) + let removeNode = + ((Function$ + (fun rbt -> + fun node -> + ((let nodeToRemove = + match (((leftGet node)[@res.uapp ]), ((rightGet node) + [@res.uapp ])) + with + | (Some _, Some _) -> + let successor = + ((castNotOption + ((minNode ((rightGet node)[@res.uapp ])) + [@res.uapp ])) + [@res.uapp ]) in + (((valueSet node ((valueGet successor)[@res.uapp ])) + [@res.uapp ]); + ((heightSet node ((heightGet successor)[@res.uapp ])) + [@res.uapp ]); + successor) + | _ -> node in + let successor = + match ((leftGet nodeToRemove)[@res.uapp ]) with + | None -> ((rightGet nodeToRemove)[@res.uapp ]) + | left -> left in + let (successor, isLeaf) = + match successor with + | None -> + let leaf = + ((createNode + ~value:((Js.Internal.raw_expr {js|0|js}) + [@res.namedArgLoc ][@res.uapp ]) ~color:((Black) + [@res.namedArgLoc ]) ~height:((0.) + [@res.namedArgLoc ])) + [@res.uapp ]) in + let isLeaf = + ((Js.Internal.fn_mk1 + ((Function$ (fun x -> x == leaf))[@res.arity 1])) + [@res.uapp ]) in + (leaf, isLeaf) + | Some successor -> + (successor, + ((Js.Internal.fn_mk1 ((Function$ (fun _ -> false)) + [@res.arity 1]))[@res.uapp ])) in + let nodeParent = ((parentGet nodeToRemove)[@res.uapp ]) in + ((parentSet successor nodeParent) + [@res.uapp ]); + (match nodeParent with + | None -> () + | Some parent -> + ((leftOrRightSet parent ~node:((nodeToRemove) + [@res.namedArgLoc ]) (Some successor)) + [@res.uapp ])); + ((updateSumRecursive rbt successor) + [@res.uapp ]); + if ((colorGet nodeToRemove)[@res.uapp ]) == Black + then + (if ((colorGet successor)[@res.uapp ]) == Red + then + (((colorSet successor Black) + [@res.uapp ]); + if ((parentGet successor)[@res.uapp ]) == None + then ((rootSet rbt (Some successor))[@res.uapp ])) + else + (let break = ((ref false)[@res.uapp ]) in + let successorRef = ((ref successor)[@res.uapp ]) in + while not break.contents do + let successor = successorRef.contents in + match ((parentGet successor)[@res.uapp ]) with + | None -> + (((rootSet rbt (Some successor)) + [@res.uapp ]); + break.contents <- true) + | Some successorParent -> + let sibling = ((siblingOf successor) + [@res.uapp ]) in + (if + (sibling != None) && + (((colorGet ((castNotOption sibling) + [@res.uapp ])) + [@res.uapp ]) == Red) + then + (((colorSet successorParent Red) + [@res.uapp ]); + ((colorSet ((castNotOption sibling) + [@res.uapp ]) Black) + [@res.uapp ]); + if ((isLeft successor)[@res.uapp ]) + then ((rotateLeft rbt successorParent) + [@res.uapp ]) + else ((rotateRight rbt successorParent) + [@res.uapp ])); + (let sibling = ((siblingOf successor) + [@res.uapp ]) in + let siblingNN = ((castNotOption sibling) + [@res.uapp ]) in if - (((not (isLeft successor)) && - (((leftGet sibling) == None) || - ((colorGet - (castNotOption (leftGet sibling))) - == Black))) - && ((rightGet sibling) != None)) + (((colorGet successorParent)[@res.uapp ]) == + Black) && - ((colorGet - (castNotOption (rightGet sibling))) - == Red) + ((sibling == None) || + (((((colorGet siblingNN)[@res.uapp ]) + == Black) + && + ((((leftGet siblingNN)[@res.uapp ]) + == None) + || + (((colorGet + ((castNotOption + ((leftGet siblingNN) + [@res.uapp ])) + [@res.uapp ])) + [@res.uapp ]) == Black))) + && + ((((rightGet siblingNN)[@res.uapp ]) + == None) + || + (((colorGet + ((castNotOption + ((rightGet siblingNN) + [@res.uapp ])) + [@res.uapp ])) + [@res.uapp ]) == Black)))) then - (colorSet sibling Red; - colorSet (castNotOption (rightGet sibling)) - Black; - rotateLeft rbt sibling); - break.contents <- true) - else - (let sibling = siblingOf successor in - let sibling = castNotOption sibling in - colorSet sibling (colorGet successorParent); - if isLeft successor - then - (colorSet (castNotOption (rightGet sibling)) - Black; - rotateRight rbt successorParent) - else - (colorSet (castNotOption (leftGet sibling)) - Black; - rotateLeft rbt successorParent)))) - done)); - if Js.Internal.fn_run1 isLeaf successor - then - (if (rootGet rbt) == (Some successor) then rootSet rbt None; - (match parentGet successor with - | None -> () - | Some parent -> - leftOrRightSet parent ~node:((successor)[@res.namedArgLoc ]) - None))) - [@res.braces ]) - let remove rbt value = - match _findNode rbt (rootGet rbt) value with - | Some node -> - (removeNode rbt node; - sizeSet rbt ((sizeGet rbt) - 1); - Some (heightGet node)) - | None -> None - let findThroughCallback rbt cb = - ((let rec findThroughCallback rbt node cb = - match node with - | None -> None - | Some node -> - let cmp = Js.Internal.fn_run1 cb (valueGet node) in - if cmp == 0 - then Some node - else - if cmp < 0 - then findThroughCallback rbt (leftGet node) cb - else findThroughCallback rbt (rightGet node) cb in - match findThroughCallback rbt (rootGet rbt) cb with - | None -> None - | Some node -> Some (valueGet node)) - [@res.braces ]) - let make ~compare:((compare)[@res.namedArgLoc ]) = - t ~size:((0)[@res.namedArgLoc ]) ~root:((None)[@res.namedArgLoc ]) - ~compare:((compare)[@res.namedArgLoc ]) - let rec heightOfInterval rbt node lhs rhs = - match node with - | None -> 0. - | Some n -> - if (lhs == None) && (rhs == None) - then sumGet n - else - if - (lhs != None) && - ((Js.Internal.fn_run2 (compareGet rbt) (valueGet n) - (castNotOption lhs)) - < 0) - then heightOfInterval rbt (rightGet n) lhs rhs - else - if - (rhs != None) && - ((Js.Internal.fn_run2 (compareGet rbt) (valueGet n) - (castNotOption rhs)) - > 0) - then heightOfInterval rbt (leftGet n) lhs rhs - else - ((heightGet n) +. (heightOfInterval rbt (leftGet n) lhs None)) - +. (heightOfInterval rbt (rightGet n) None rhs) - let heightOfInterval rbt lhs rhs = - heightOfInterval rbt (rootGet rbt) lhs rhs - let rec firstVisibleNode node offset = - match node with - | None -> None - | Some node -> - if (sumGet node) <= offset - then None - else - (let nodeHeight = heightGet node in - let sumLeft = - match leftGet node with - | None -> 0.0 - | Some left -> sumGet left in - if sumLeft > offset - then firstVisibleNode (leftGet node) offset - else - if (sumLeft +. nodeHeight) > offset - then Some node - else - firstVisibleNode (rightGet node) - (offset -. (sumLeft +. nodeHeight))) - let lastVisibleNode node offset = - match firstVisibleNode node offset with - | None -> maxNode node - | first -> first - let firstVisible rbt ~offset:((offset)[@res.namedArgLoc ]) = - match firstVisibleNode (rootGet rbt) offset with - | None -> None - | Some node -> Some (valueGet node) - let rec leftmost node = - match leftGet node with | None -> node | Some node -> leftmost node - let rec firstRightParent node = - match parentGet node with - | None -> None - | Some parent -> - if isLeft node then Some parent else firstRightParent parent - let nextNode node = - match rightGet node with - | None -> firstRightParent node - | Some right -> Some (leftmost right) - let rec sumLeftSpine node - ~fromRightChild:((fromRightChild)[@res.namedArgLoc ]) = - ((let leftSpine = - match leftGet node with - | None -> heightGet node - | Some left -> - if fromRightChild - then (heightGet node) +. (sumGet left) - else 0.0 in - match parentGet node with - | None -> leftSpine - | Some parent -> - leftSpine +. - (sumLeftSpine parent - ~fromRightChild:(((rightGet parent) == (Some node)) - [@res.namedArgLoc ]))) - [@res.braces ]) - let getY node = - (sumLeftSpine node ~fromRightChild:((true)[@res.namedArgLoc ])) -. - (heightGet node) - let linearSearch rbt callback = - ((let rec find node callback = - if Js.Internal.fn_run1 callback (valueGet node) - then Some (valueGet node) - else - (match nextNode node with + (if sibling != None + then ((colorSet siblingNN Red)[@res.uapp ]); + successorRef.contents <- successorParent) + else + if + (((colorGet successorParent)[@res.uapp ]) + == Red) + && + ((sibling == None) || + (((((colorGet siblingNN)[@res.uapp ]) + == Black) + && + ((((leftGet siblingNN) + [@res.uapp ]) == None) + || + (((colorGet + ((castNotOption + ((leftGet siblingNN) + [@res.uapp ])) + [@res.uapp ])) + [@res.uapp ]) == Black))) + && + ((((rightGet siblingNN) + [@res.uapp ]) == None) + || + (((colorGet + ((castNotOption + ((rightGet siblingNN) + [@res.uapp ])) + [@res.uapp ])) + [@res.uapp ]) == Black)))) + then + (if sibling != None + then ((colorSet siblingNN Red) + [@res.uapp ]); + ((colorSet successorParent Black) + [@res.uapp ]); + break.contents <- true) + else + if + (sibling != None) && + (((colorGet ((castNotOption sibling) + [@res.uapp ])) + [@res.uapp ]) == Black) + then + (let sibling = ((castNotOption sibling) + [@res.uapp ]) in + if + ((((isLeft successor)[@res.uapp ]) && + ((((rightGet sibling) + [@res.uapp ]) == None) + || + (((colorGet + ((castNotOption + ((rightGet sibling) + [@res.uapp ])) + [@res.uapp ])) + [@res.uapp ]) == Black))) + && + (((leftGet sibling)[@res.uapp ]) + != None)) + && + (((colorGet + ((castNotOption + ((leftGet sibling) + [@res.uapp ])) + [@res.uapp ])) + [@res.uapp ]) == Red) + then + (((colorSet sibling Red) + [@res.uapp ]); + ((colorSet + ((castNotOption + ((leftGet sibling) + [@res.uapp ]))[@res.uapp ]) + Black) + [@res.uapp ]); + ((rotateRight rbt sibling) + [@res.uapp ])) + else + if + (((not ((isLeft successor) + [@res.uapp ])) + && + ((((leftGet sibling) + [@res.uapp ]) == None) + || + (((colorGet + ((castNotOption + ((leftGet sibling) + [@res.uapp ])) + [@res.uapp ])) + [@res.uapp ]) == Black))) + && + (((rightGet sibling) + [@res.uapp ]) != None)) + && + (((colorGet + ((castNotOption + ((rightGet sibling) + [@res.uapp ])) + [@res.uapp ])) + [@res.uapp ]) == Red) + then + (((colorSet sibling Red) + [@res.uapp ]); + ((colorSet + ((castNotOption + ((rightGet sibling) + [@res.uapp ])) + [@res.uapp ]) Black) + [@res.uapp ]); + ((rotateLeft rbt sibling) + [@res.uapp ])); + break.contents <- true) + else + (let sibling = ((siblingOf successor) + [@res.uapp ]) in + let sibling = ((castNotOption sibling) + [@res.uapp ]) in + ((colorSet sibling + ((colorGet successorParent) + [@res.uapp ])) + [@res.uapp ]); + if ((isLeft successor)[@res.uapp ]) + then + (((colorSet + ((castNotOption + ((rightGet sibling) + [@res.uapp ]))[@res.uapp ]) + Black) + [@res.uapp ]); + ((rotateRight rbt successorParent) + [@res.uapp ])) + else + (((colorSet + ((castNotOption + ((leftGet sibling) + [@res.uapp ]))[@res.uapp ]) + Black) + [@res.uapp ]); + ((rotateLeft rbt successorParent) + [@res.uapp ]))))) + done)); + if ((Js.Internal.fn_run1 isLeaf successor)[@res.uapp ]) + then + (if ((rootGet rbt)[@res.uapp ]) == (Some successor) + then ((rootSet rbt None)[@res.uapp ]); + (match ((parentGet successor)[@res.uapp ]) with + | None -> () + | Some parent -> + ((leftOrRightSet parent ~node:((successor) + [@res.namedArgLoc ]) None) + [@res.uapp ])))) + [@res.braces ]))) + [@res.arity 2]) + let remove = + ((Function$ + (fun rbt -> + fun value -> + match ((_findNode rbt ((rootGet rbt)[@res.uapp ]) value) + [@res.uapp ]) + with + | Some node -> + (((removeNode rbt node) + [@res.uapp ]); + ((sizeSet rbt (((sizeGet rbt)[@res.uapp ]) - 1)) + [@res.uapp ]); + Some ((heightGet node)[@res.uapp ])) + | None -> None)) + [@res.arity 2]) + let findThroughCallback = + ((Function$ + (fun rbt -> + fun cb -> + ((let rec findThroughCallback = + ((Function$ + (fun rbt -> + fun node -> + fun cb -> + match node with + | None -> None + | Some node -> + let cmp = + ((Js.Internal.fn_run1 cb ((valueGet node) + [@res.uapp ])) + [@res.uapp ]) in + if cmp == 0 + then Some node + else + if cmp < 0 + then + ((findThroughCallback rbt + ((leftGet node)[@res.uapp ]) cb) + [@res.uapp ]) + else + ((findThroughCallback rbt + ((rightGet node)[@res.uapp ]) cb) + [@res.uapp ]))) + [@res.arity 3]) in + match ((findThroughCallback rbt ((rootGet rbt)[@res.uapp ]) + cb) + [@res.uapp ]) + with + | None -> None + | Some node -> Some ((valueGet node)[@res.uapp ])) + [@res.braces ]))) + [@res.arity 2]) + let make = + ((Function$ + (fun ~compare:((compare)[@res.namedArgLoc ]) -> + ((t ~size:((0)[@res.namedArgLoc ]) ~root:((None) + [@res.namedArgLoc ]) ~compare:((compare)[@res.namedArgLoc ])) + [@res.uapp ]))) + [@res.arity 1]) + let rec heightOfInterval = + ((Function$ + (fun rbt -> + fun node -> + fun lhs -> + fun rhs -> + match node with + | None -> 0. + | Some n -> + if (lhs == None) && (rhs == None) + then ((sumGet n)[@res.uapp ]) + else + if + (lhs != None) && + (((Js.Internal.fn_run2 ((compareGet rbt) + [@res.uapp ]) ((valueGet n)[@res.uapp ]) + ((castNotOption lhs)[@res.uapp ])) + [@res.uapp ]) < 0) + then + ((heightOfInterval rbt ((rightGet n)[@res.uapp ]) + lhs rhs) + [@res.uapp ]) + else + if + (rhs != None) && + (((Js.Internal.fn_run2 ((compareGet rbt) + [@res.uapp ]) ((valueGet n)[@res.uapp ]) + ((castNotOption rhs)[@res.uapp ])) + [@res.uapp ]) > 0) + then + ((heightOfInterval rbt ((leftGet n)[@res.uapp ]) + lhs rhs) + [@res.uapp ]) + else + (((heightGet n)[@res.uapp ]) +. + ((heightOfInterval rbt ((leftGet n) + [@res.uapp ]) lhs None) + [@res.uapp ])) + +. + ((heightOfInterval rbt ((rightGet n) + [@res.uapp ]) None rhs) + [@res.uapp ]))) + [@res.arity 4]) + let heightOfInterval = + ((Function$ + (fun rbt -> + fun lhs -> + fun rhs -> + ((heightOfInterval rbt ((rootGet rbt)[@res.uapp ]) lhs rhs) + [@res.uapp ]))) + [@res.arity 3]) + let rec firstVisibleNode = + ((Function$ + (fun node -> + fun offset -> + match node with + | None -> None + | Some node -> + if ((sumGet node)[@res.uapp ]) <= offset + then None + else + (let nodeHeight = ((heightGet node)[@res.uapp ]) in + let sumLeft = + match ((leftGet node)[@res.uapp ]) with + | None -> 0.0 + | Some left -> ((sumGet left)[@res.uapp ]) in + if sumLeft > offset + then + ((firstVisibleNode ((leftGet node)[@res.uapp ]) + offset) + [@res.uapp ]) + else + if (sumLeft +. nodeHeight) > offset + then Some node + else + ((firstVisibleNode ((rightGet node)[@res.uapp ]) + (offset -. (sumLeft +. nodeHeight))) + [@res.uapp ])))) + [@res.arity 2]) + let lastVisibleNode = + ((Function$ + (fun node -> + fun offset -> + match ((firstVisibleNode node offset)[@res.uapp ]) with + | None -> ((maxNode node)[@res.uapp ]) + | first -> first)) + [@res.arity 2]) + let firstVisible = + ((Function$ + (fun rbt -> + fun ~offset:((offset)[@res.namedArgLoc ]) -> + match ((firstVisibleNode ((rootGet rbt)[@res.uapp ]) offset) + [@res.uapp ]) + with + | None -> None + | Some node -> Some ((valueGet node)[@res.uapp ]))) + [@res.arity 2]) + let rec leftmost = + ((Function$ + (fun node -> + match ((leftGet node)[@res.uapp ]) with + | None -> node + | Some node -> ((leftmost node)[@res.uapp ]))) + [@res.arity 1]) + let rec firstRightParent = + ((Function$ + (fun node -> + match ((parentGet node)[@res.uapp ]) with | None -> None - | Some node -> find node callback) in - match minNode (rootGet rbt) with - | None -> None - | Some node -> find node callback) - [@res.braces ]) - let rec iterate ~inclusive:((inclusive)[@res.namedArgLoc ]) firstNode - lastNode ~callback:((callback)[@res.namedArgLoc ]) = - match firstNode with - | None -> () - | Some node -> - (if inclusive then Js.Internal.fn_run1 callback node; - if firstNode != lastNode - then - (if not inclusive then Js.Internal.fn_run1 callback node; - iterate ~inclusive:((inclusive)[@res.namedArgLoc ]) - (nextNode node) lastNode ~callback:((callback) - [@res.namedArgLoc ]))) - let rec iterateWithY ?y:((y)[@res.namedArgLoc ]) - ~inclusive:((inclusive)[@res.namedArgLoc ]) firstNode lastNode - ~callback:((callback)[@res.namedArgLoc ]) = - match firstNode with - | None -> () - | Some node -> - let y = match y with | None -> getY node | Some y -> y in - (if inclusive then Js.Internal.fn_run2 callback node y; - if firstNode != lastNode - then - (if not inclusive then Js.Internal.fn_run2 callback node y; - iterateWithY ~y:((y +. (heightGet node))[@res.namedArgLoc ]) - ~inclusive:((inclusive)[@res.namedArgLoc ]) (nextNode node) - lastNode ~callback:((callback)[@res.namedArgLoc ]))) - let rec updateSum node ~delta:((delta)[@res.namedArgLoc ]) = - match node with - | None -> () - | Some node -> - (sumSet node ((sumGet node) +. delta); - updateSum (parentGet node) ~delta:((delta)[@res.namedArgLoc ])) - let setHeight rbt value ~height:((height)[@res.namedArgLoc ]) = - match _findNode rbt (rootGet rbt) value with - | None -> () - | Some node -> - let delta = height -. (heightGet node) in - (heightSet node height; - updateSum (Some node) ~delta:((delta)[@res.namedArgLoc ])) + | Some parent -> + if ((isLeft node)[@res.uapp ]) + then Some parent + else ((firstRightParent parent)[@res.uapp ]))) + [@res.arity 1]) + let nextNode = + ((Function$ + (fun node -> + match ((rightGet node)[@res.uapp ]) with + | None -> ((firstRightParent node)[@res.uapp ]) + | Some right -> Some ((leftmost right)[@res.uapp ]))) + [@res.arity 1]) + let rec sumLeftSpine = + ((Function$ + (fun node -> + fun ~fromRightChild:((fromRightChild)[@res.namedArgLoc ]) -> + ((let leftSpine = + match ((leftGet node)[@res.uapp ]) with + | None -> ((heightGet node)[@res.uapp ]) + | Some left -> + if fromRightChild + then + ((heightGet node)[@res.uapp ]) +. ((sumGet left) + [@res.uapp ]) + else 0.0 in + match ((parentGet node)[@res.uapp ]) with + | None -> leftSpine + | Some parent -> + leftSpine +. + ((sumLeftSpine parent + ~fromRightChild:((((rightGet parent)[@res.uapp ]) + == (Some node)) + [@res.namedArgLoc ])) + [@res.uapp ])) + [@res.braces ]))) + [@res.arity 2]) + let getY = + ((Function$ + (fun node -> + ((sumLeftSpine node ~fromRightChild:((true)[@res.namedArgLoc ])) + [@res.uapp ]) -. ((heightGet node)[@res.uapp ]))) + [@res.arity 1]) + let linearSearch = + ((Function$ + (fun rbt -> + fun callback -> + ((let rec find = + ((Function$ + (fun node -> + fun callback -> + if + ((Js.Internal.fn_run1 callback ((valueGet node) + [@res.uapp ])) + [@res.uapp ]) + then Some ((valueGet node)[@res.uapp ]) + else + (match ((nextNode node)[@res.uapp ]) with + | None -> None + | Some node -> ((find node callback) + [@res.uapp ])))) + [@res.arity 2]) in + match ((minNode ((rootGet rbt)[@res.uapp ]))[@res.uapp ]) + with + | None -> None + | Some node -> ((find node callback)[@res.uapp ])) + [@res.braces ]))) + [@res.arity 2]) + let rec iterate = + ((Function$ + (fun ~inclusive:((inclusive)[@res.namedArgLoc ]) -> + fun firstNode -> + fun lastNode -> + fun ~callback:((callback)[@res.namedArgLoc ]) -> + match firstNode with + | None -> () + | Some node -> + (if inclusive + then ((Js.Internal.fn_run1 callback node) + [@res.uapp ]); + if firstNode != lastNode + then + (if not inclusive + then ((Js.Internal.fn_run1 callback node) + [@res.uapp ]); + ((iterate ~inclusive:((inclusive) + [@res.namedArgLoc ]) ((nextNode node) + [@res.uapp ]) lastNode ~callback:((callback) + [@res.namedArgLoc ])) + [@res.uapp ]))))) + [@res.arity 4]) + let rec iterateWithY = + ((Function$ + (fun ?y:((y)[@res.namedArgLoc ]) -> + fun ~inclusive:((inclusive)[@res.namedArgLoc ]) -> + fun firstNode -> + fun lastNode -> + fun ~callback:((callback)[@res.namedArgLoc ]) -> + match firstNode with + | None -> () + | Some node -> + let y = + match y with + | None -> ((getY node)[@res.uapp ]) + | Some y -> y in + (if inclusive + then ((Js.Internal.fn_run2 callback node y) + [@res.uapp ]); + if firstNode != lastNode + then + (if not inclusive + then ((Js.Internal.fn_run2 callback node y) + [@res.uapp ]); + ((iterateWithY + ~y:((y +. ((heightGet node)[@res.uapp ])) + [@res.namedArgLoc ]) ~inclusive:((inclusive) + [@res.namedArgLoc ]) ((nextNode node) + [@res.uapp ]) lastNode ~callback:((callback) + [@res.namedArgLoc ])) + [@res.uapp ]))))) + [@res.arity 5]) + let rec updateSum = + ((Function$ + (fun node -> + fun ~delta:((delta)[@res.namedArgLoc ]) -> + match node with + | None -> () + | Some node -> + (((sumSet node (((sumGet node)[@res.uapp ]) +. delta)) + [@res.uapp ]); + ((updateSum ((parentGet node)[@res.uapp ]) + ~delta:((delta)[@res.namedArgLoc ])) + [@res.uapp ])))) + [@res.arity 2]) + let setHeight = + ((Function$ + (fun rbt -> + fun value -> + fun ~height:((height)[@res.namedArgLoc ]) -> + match ((_findNode rbt ((rootGet rbt)[@res.uapp ]) value) + [@res.uapp ]) + with + | None -> () + | Some node -> + let delta = height -. ((heightGet node)[@res.uapp ]) in + (((heightSet node height) + [@res.uapp ]); + ((updateSum (Some node) ~delta:((delta) + [@res.namedArgLoc ])) + [@res.uapp ])))) + [@res.arity 3]) type nonrec 'value oldNewVisibleNodes = { mutable old: 'value array ; diff --git a/jscomp/syntax/tests/parsing/infiniteLoops/expected/templateEof.res.txt b/jscomp/syntax/tests/parsing/infiniteLoops/expected/templateEof.res.txt index fc64a8d1e7..9e6269ffac 100644 --- a/jscomp/syntax/tests/parsing/infiniteLoops/expected/templateEof.res.txt +++ b/jscomp/syntax/tests/parsing/infiniteLoops/expected/templateEof.res.txt @@ -20,4 +20,7 @@ ;;et ;;foo = - (fun x -> match x with | (("")[@res.template ]) -> [%rescript.exprhole ]) \ No newline at end of file + ((Function$ + (fun x -> + match x with | (("")[@res.template ]) -> [%rescript.exprhole ])) + [@res.arity 1]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/other/expected/list.res.txt b/jscomp/syntax/tests/parsing/other/expected/list.res.txt index 0283da1149..737f92c358 100644 --- a/jscomp/syntax/tests/parsing/other/expected/list.res.txt +++ b/jscomp/syntax/tests/parsing/other/expected/list.res.txt @@ -3,5 +3,5 @@ let x = list + list let f = Foo.list let x = list.list let y = Ok.Bar.list -;;list a b +;;((list a b)[@res.uapp ]) ;;list.list <- list \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/other/expected/singleLineCommentWithoutNewline.res.txt b/jscomp/syntax/tests/parsing/other/expected/singleLineCommentWithoutNewline.res.txt index af7fe8e4a4..66e04e9834 100644 --- a/jscomp/syntax/tests/parsing/other/expected/singleLineCommentWithoutNewline.res.txt +++ b/jscomp/syntax/tests/parsing/other/expected/singleLineCommentWithoutNewline.res.txt @@ -1 +1 @@ -;;RootView.init () \ No newline at end of file +;;((RootView.init ())[@res.uapp ]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/recovery/expression/expected/emptyBlock.res.txt b/jscomp/syntax/tests/parsing/recovery/expression/expected/emptyBlock.res.txt index 36cfe2e4c1..545f257b92 100644 --- a/jscomp/syntax/tests/parsing/recovery/expression/expected/emptyBlock.res.txt +++ b/jscomp/syntax/tests/parsing/recovery/expression/expected/emptyBlock.res.txt @@ -1,2 +1,2 @@ let x = { } -let f a b = { } \ No newline at end of file +let f = ((Function$ (fun a -> fun b -> { }))[@res.arity 2]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/recovery/expression/expected/if.res.txt b/jscomp/syntax/tests/parsing/recovery/expression/expected/if.res.txt index 3e4d5bcb43..ad87666e75 100644 --- a/jscomp/syntax/tests/parsing/recovery/expression/expected/if.res.txt +++ b/jscomp/syntax/tests/parsing/recovery/expression/expected/if.res.txt @@ -16,4 +16,6 @@ Did you forget a `{` here? -;;if foo = bar then Js.log {js|if-branch|js} else Js.log {js|else-branch|js} \ No newline at end of file +;;if foo = bar + then ((Js.log {js|if-branch|js})[@res.uapp ]) + else ((Js.log {js|else-branch|js})[@res.uapp ]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/recovery/expression/expected/infinite.res.txt b/jscomp/syntax/tests/parsing/recovery/expression/expected/infinite.res.txt index ae2bb486a9..7ee261130c 100644 --- a/jscomp/syntax/tests/parsing/recovery/expression/expected/infinite.res.txt +++ b/jscomp/syntax/tests/parsing/recovery/expression/expected/infinite.res.txt @@ -1 +1 @@ -let smallest = ((heap.compare ())[@res.uapp ]) < (a |. (f b)) \ No newline at end of file +let smallest = ((heap.compare ())[@res.uapp ]) < (a |.u ((f b)[@res.uapp ])) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/recovery/expression/expected/list.res.txt b/jscomp/syntax/tests/parsing/recovery/expression/expected/list.res.txt index 2032ee076d..34fe2a4666 100644 --- a/jscomp/syntax/tests/parsing/recovery/expression/expected/list.res.txt +++ b/jscomp/syntax/tests/parsing/recovery/expression/expected/list.res.txt @@ -29,15 +29,20 @@ Solution: if it's to validate the first few elements, use a `when` clause + Arra let flags = ((if reasonFormat then - ((let parts = Utils.split_on_char ' ' flags in - let rec loop items = - ((match items with - | [|{js|-pp|js};_ppFlag;rest|] -> loop rest - | [|x;rest|] -> - ((Belt.Array.concatMany)[@res.spread ]) [|[|x|];(loop rest)|] - | [||] -> [||]) - [@res.braces ]) in - (loop parts) |> (String.concat {js| |js})) + ((let parts = ((Utils.split_on_char ' ' flags)[@res.uapp ]) in + let rec loop = + ((Function$ + (fun items -> + ((match items with + | [|{js|-pp|js};_ppFlag;rest|] -> ((loop rest) + [@res.uapp ]) + | [|x;rest|] -> + ((Belt.Array.concatMany)[@res.spread ]) + [|[|x|];((loop rest)[@res.uapp ])|] + | [||] -> [||]) + [@res.braces ]))) + [@res.arity 1]) in + ((String.concat {js| |js} ((loop parts)[@res.uapp ]))[@res.uapp ])) [@res.braces ]) else flags) [@res.ternary ]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/recovery/pattern/expected/constrained.res.txt b/jscomp/syntax/tests/parsing/recovery/pattern/expected/constrained.res.txt index 521c65712e..8acf5b787f 100644 --- a/jscomp/syntax/tests/parsing/recovery/pattern/expected/constrained.res.txt +++ b/jscomp/syntax/tests/parsing/recovery/pattern/expected/constrained.res.txt @@ -10,4 +10,5 @@ Did you forget a `)` here? -;;match x with | (a : int -> unit) -> [%rescript.exprhole ] \ No newline at end of file +;;match x with + | (a : (int -> unit, [ `Has_arity1 ]) function$) -> [%rescript.exprhole ] \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/recovery/structure/expected/letBinding.res.txt b/jscomp/syntax/tests/parsing/recovery/structure/expected/letBinding.res.txt index 2f07041c32..08ffa1f01c 100644 --- a/jscomp/syntax/tests/parsing/recovery/structure/expected/letBinding.res.txt +++ b/jscomp/syntax/tests/parsing/recovery/structure/expected/letBinding.res.txt @@ -7,4 +7,4 @@ This let-binding misses an expression -let x = doStuff y \ No newline at end of file +let x = ((doStuff y)[@res.uapp ]) \ No newline at end of file diff --git a/jscomp/syntax/tests/ppx/react/expected/firstClassModules.res.txt b/jscomp/syntax/tests/ppx/react/expected/firstClassModules.res.txt index d3dd016e74..44a9545886 100644 --- a/jscomp/syntax/tests/ppx/react/expected/firstClassModules.res.txt +++ b/jscomp/syntax/tests/ppx/react/expected/firstClassModules.res.txt @@ -101,7 +101,7 @@ module External = { props< module(T with type t = 'a and type key = 'key), option<'key>, - (option<'key> => unit), + option<'key> => unit, array<'a>, >, React.element, diff --git a/jscomp/syntax/tests/ppx/react/expected/firstClassModules.resi.txt b/jscomp/syntax/tests/ppx/react/expected/firstClassModules.resi.txt index e5ec53af6c..4c0e30f781 100644 --- a/jscomp/syntax/tests/ppx/react/expected/firstClassModules.resi.txt +++ b/jscomp/syntax/tests/ppx/react/expected/firstClassModules.resi.txt @@ -17,14 +17,14 @@ module Select: { ) => { "model": module(T with type t = 'a and type key = 'key), "selected": option<'key>, - "onChange": (option<'key> => unit), + "onChange": option<'key> => unit, "items": array<'a>, } = "" let make: React.componentLike< { "model": module(T with type t = 'a and type key = 'key), "selected": option<'key>, - "onChange": (option<'key> => unit), + "onChange": option<'key> => unit, "items": array<'a>, }, React.element, @@ -49,7 +49,7 @@ module Select: { props< module(T with type t = 'a and type key = 'key), option<'key>, - (option<'key> => unit), + option<'key> => unit, array<'a>, >, React.element, diff --git a/jscomp/syntax/tests/ppx/react/expected/typeConstraint.res.txt b/jscomp/syntax/tests/ppx/react/expected/typeConstraint.res.txt index 9cb9635324..6196ae1df3 100644 --- a/jscomp/syntax/tests/ppx/react/expected/typeConstraint.res.txt +++ b/jscomp/syntax/tests/ppx/react/expected/typeConstraint.res.txt @@ -1,15 +1,14 @@ @@jsxConfig({version: 3}) module V3 = { - @obj external makeProps: (~a: 'a, ~b: 'b, ~key: string=?, unit) => {"a": 'a, "b": 'b} = "" + @obj external makeProps: (~key: string=?, unit) => {.} = "" @react.component let make: type a. (~a: a, ~b: a, a) => React.element = (~a, ~b, _) => ReactDOMRe.createDOMElementVariadic("div", []) let make = { - let \"TypeConstraint$V3" = (\"Props": {"a": 'a, "b": 'b}) => - make(~b=\"Props"["b"], ~a=\"Props"["a"]) + let \"TypeConstraint$V3" = (\"Props": {.}) => make() \"TypeConstraint$V3" } } @@ -17,11 +16,11 @@ module V3 = { @@jsxConfig({version: 4, mode: "classic"}) module V4C = { - type props<'a, 'b> = {a: 'a, b: 'b} + type props = {} - let make = (type a, {a, b, _}: props<_, _>) => ReactDOM.createDOMElementVariadic("div", []) + let make = (type a, _: props) => (~a, ~b, _) => ReactDOM.createDOMElementVariadic("div", []) let make = { - let \"TypeConstraint$V4C" = (props: props<_>) => make(props) + let \"TypeConstraint$V4C" = props => make(props) \"TypeConstraint$V4C" } @@ -30,11 +29,11 @@ module V4C = { @@jsxConfig({version: 4, mode: "automatic"}) module V4A = { - type props<'a, 'b> = {a: 'a, b: 'b} + type props = {} - let make = (type a, {a, b, _}: props<_, _>) => ReactDOM.jsx("div", {}) + let make = (type a, _: props) => (~a, ~b, _) => ReactDOM.jsx("div", {}) let make = { - let \"TypeConstraint$V4A" = (props: props<_>) => make(props) + let \"TypeConstraint$V4A" = props => make(props) \"TypeConstraint$V4A" } diff --git a/jscomp/syntax/tests/ppx/react/expected/uncurriedProps.res.txt b/jscomp/syntax/tests/ppx/react/expected/uncurriedProps.res.txt index a08fc2170a..7e3dae8434 100644 --- a/jscomp/syntax/tests/ppx/react/expected/uncurriedProps.res.txt +++ b/jscomp/syntax/tests/ppx/react/expected/uncurriedProps.res.txt @@ -1,10 +1,10 @@ @@jsxConfig({version: 4}) type props<'a> = {a?: 'a} -let make = ({a: ?__a, _}: props<(. unit) => unit>) => { +let make = ({a: ?__a, _}: props unit>) => { let a = switch __a { | Some(a) => a - | None => (. ()) => () + | None => () => () } React.null @@ -15,11 +15,11 @@ let make = { \"UncurriedProps" } -let func = (~callback: (. string, bool, bool) => unit=(. _, _, _) => (), ()) => { +let func = (~callback: (string, bool, bool) => unit=(_, _, _) => (), ()) => { let _ = callback } -func(~callback=(. str, a, b) => { +func(~callback=(str, a, b) => { let _ = str let _ = a let _ = b @@ -28,10 +28,10 @@ func(~callback=(. str, a, b) => { module Foo = { type props<'callback> = {callback?: 'callback} - let make = ({callback: ?__callback, _}: props<(. string, bool, bool) => unit>) => { + let make = ({callback: ?__callback, _}: props<(string, bool, bool) => unit>) => { let callback = switch __callback { | Some(callback) => callback - | None => (. _, _, _) => () + | None => (_, _, _) => () } { @@ -48,7 +48,7 @@ module Foo = { module Bar = { type props = {} - let make = (_: props) => React.jsx(Foo.make, {callback: (. _, _, _) => ()}) + let make = (_: props) => React.jsx(Foo.make, {callback: (_, _, _) => ()}) let make = { let \"UncurriedProps$Bar" = props => make(props) diff --git a/jscomp/syntax/tests/printer/comments/expected/binaryExpr.res.txt b/jscomp/syntax/tests/printer/comments/expected/binaryExpr.res.txt index 3f5336586a..3f8d67d35c 100644 --- a/jscomp/syntax/tests/printer/comments/expected/binaryExpr.res.txt +++ b/jscomp/syntax/tests/printer/comments/expected/binaryExpr.res.txt @@ -75,20 +75,21 @@ promise Js.Promise.resolve(""->Obj.magic) }) -promise // TODO: This comment needs to be here -|> Js.Promise.then(payload => { +Js.Promise.then(payload => { Js.log2("this payload was received", payload) Js.Promise.resolve(""->Obj.magic) -}) +}, promise) -promise // comment -|> Js.Promise.then(payload => { - Js.Promise.resolve(""->Obj.magic) -}) + // comment 2 -|> Js.Promise.catch(err => { - Js.log2("this error was caught", err) - Js.Promise.resolve(""->Obj.magic) -}) +Js.Promise.catch( + err => { + Js.log2("this error was caught", err) + Js.Promise.resolve(""->Obj.magic) + }, + Js.Promise.then(payload => { + Js.Promise.resolve(""->Obj.magic) + }, promise), +) diff --git a/jscomp/syntax/tests/printer/comments/expected/case.res.txt b/jscomp/syntax/tests/printer/comments/expected/case.res.txt index 469af84df8..cdd0d1ea9f 100644 --- a/jscomp/syntax/tests/printer/comments/expected/case.res.txt +++ b/jscomp/syntax/tests/printer/comments/expected/case.res.txt @@ -18,13 +18,13 @@ let rec mergeU = (s1, s2, f) => (leftGet(n), keyGet(n), valueGet(n), rightGet(n)) } let (l2, d2, r2) = split(v1, s2) - N.concatOrJoin(mergeU(l1, l2, f), v1, f(. v1, Some(d1), d2), mergeU(r1, r2, f)) + N.concatOrJoin(mergeU(l1, l2, f), v1, f(v1, Some(d1), d2), mergeU(r1, r2, f)) | (_, Some(n)) /* Node (l2, v2, d2, r2, h2) */ => let (l2, v2, d2, r2) = { open N (leftGet(n), keyGet(n), valueGet(n), rightGet(n)) } let (l1, d1, r1) = split(v2, s1) - N.concatOrJoin(mergeU(l1, l2, f), v2, f(. v2, d1, Some(d2)), mergeU(r1, r2, f)) + N.concatOrJoin(mergeU(l1, l2, f), v2, f(v2, d1, Some(d2)), mergeU(r1, r2, f)) | _ => assert(false) } diff --git a/jscomp/syntax/tests/printer/comments/expected/expr.res.txt b/jscomp/syntax/tests/printer/comments/expected/expr.res.txt index 8fc8f09702..cd3d56bfa6 100644 --- a/jscomp/syntax/tests/printer/comments/expected/expr.res.txt +++ b/jscomp/syntax/tests/printer/comments/expected/expr.res.txt @@ -226,10 +226,10 @@ let f = ( /* c6 */ ~x=?, ) => /* c7 */ () -let multiply = (type /* c-2 */ t /* c-1 */, /* c0 */ m1 /* c1 */, /* c2 */ m2 /* c3 */) => () +let multiply = (type /* c-2 */ t /* c-1 */, m1 /* c1 */, /* c2 */ m2 /* c3 */) => () let multiply = ( type /* c-4 */ t /* c-3 */, - /* c0 */ m1 /* c1 */, + m1 /* c1 */, type /* c-2 */ s /* c-1 */, /* c2 */ m2 /* c3 */, ) => () diff --git a/jscomp/syntax/tests/printer/comments/expected/typexpr.res.txt b/jscomp/syntax/tests/printer/comments/expected/typexpr.res.txt index 5741dde63c..e3a39acf24 100644 --- a/jscomp/syntax/tests/printer/comments/expected/typexpr.res.txt +++ b/jscomp/syntax/tests/printer/comments/expected/typexpr.res.txt @@ -69,8 +69,8 @@ type make = ( ~getAnother: unit => unit=?, ) => React.element -type f = /* c0 */ (~a: /* c1 */ int /* c2 */) => /* c3 */ int /* c4 */ -type f = (/* c0 */ ~a: /* c1 */ int /* c2 */) => /* c3 */ int /* c4 */ +//type f = /* c0 */ ~a: /* c1 */ int /* c2 */ => /* c3 */ int /* c4 */ +//type f = (/* c0 */ ~a: /* c1 */ int /* c2 */) => /* c3 */ int /* c4 */ // Ptyp_object type jsUser = /* before */ { diff --git a/jscomp/syntax/tests/printer/comments/typexpr.res b/jscomp/syntax/tests/printer/comments/typexpr.res index 9cb8c16134..fd27fb3462 100644 --- a/jscomp/syntax/tests/printer/comments/typexpr.res +++ b/jscomp/syntax/tests/printer/comments/typexpr.res @@ -54,8 +54,8 @@ type make = ( ~getAnother: unit => unit=?, ) => React.element -type f = /* c0 */ ~a: /* c1 */ int /* c2 */ => /* c3 */ int /* c4 */ -type f = (/* c0 */ ~a: /* c1 */ int /* c2 */) => /* c3 */ int /* c4 */ +//type f = /* c0 */ ~a: /* c1 */ int /* c2 */ => /* c3 */ int /* c4 */ +//type f = (/* c0 */ ~a: /* c1 */ int /* c2 */) => /* c3 */ int /* c4 */ // Ptyp_object type jsUser = /* before */ { diff --git a/jscomp/syntax/tests/printer/expr/expected/UncurriedByDefault.res.txt b/jscomp/syntax/tests/printer/expr/expected/UncurriedByDefault.res.txt index 047bb6a858..dd3e211701 100644 --- a/jscomp/syntax/tests/printer/expr/expected/UncurriedByDefault.res.txt +++ b/jscomp/syntax/tests/printer/expr/expected/UncurriedByDefault.res.txt @@ -1,119 +1,119 @@ let cApp = foo(3) -let uApp = foo(. 3) +let uApp = foo(3) let cFun = x => 3 -let uFun = (. x) => 3 -let mixFun = a => (. b, c) => {(d, e, f, g) => (. h) => 4} -let bracesFun = (. x) => {y => x + y} +let uFun = x => 3 +let mixFun = (a, b, c) => (d, e, f) => (g, h) => 4 +let bracesFun = x => y => x + y let cFun2 = (x, y) => 3 -let uFun2 = (. x, y) => 3 +let uFun2 = (x, y) => 3 type cTyp = string => int -type uTyp = (. string) => int -type mixTyp = string => (. string, string) => (string, string, string, string) => (. string) => int -type bTyp = (. string) => string => int +type uTyp = string => int +type mixTyp = (string, string, string) => (string, string, string) => (string, string) => int +type bTyp = string => string => int type cTyp2 = (string, string) => int -type uTyp2 = (. string, string) => int +type uTyp2 = (string, string) => int type cu = unit => int type cp = unit => int -type cuu = (unit, unit) => int -type cpu = (unit, unit) => int -type cup = (unit, unit) => int -type cpp = (unit, unit) => int +type cuu = unit => unit => int +type cpu = unit => unit => int +type cup = unit => unit => int +type cpp = unit => unit => int type cu2 = (unit, unit) => unit type cp2 = (unit, unit) => unit -type uu = (. unit) => int -type up = (. unit) => int -type uuu = (. unit) => (. unit) => int -type upu = (. unit) => (. unit) => int -type uup = (. unit) => (. unit) => int -type upp = (. unit) => (. unit) => int -type uu2 = (. unit, unit) => unit -type up2 = (. unit, unit) => unit +type uu = unit => int +type up = unit => int +type uuu = unit => unit => int +type upu = unit => unit => int +type uup = unit => unit => int +type upp = unit => unit => int +type uu2 = (unit, unit) => unit +type up2 = (unit, unit) => unit type cnested = (string => unit) => unit -type unested = (. (. string) => unit) => unit +type unested = (string => unit) => unit -let pipe = a->foo(. b, c) +let pipe = a->foo(b, c) -let _ = setTimeout(. (. ()) => { - resolve(. 1) +let _ = setTimeout(() => { + resolve(1) }, 100) let _ = setTimeout(() => { resolve(1) }, 100) -let _ = @att (. x) => 34 -let _ = @att async (. x) => 34 -let _ = preserveAttr(@att (. x) => 34) -let _ = preserveAttr(@att async (. x) => 34) +let _ = @att x => 34 +let _ = @att async x => 34 +let _ = preserveAttr(@att x => 34) +let _ = preserveAttr(@att async x => 34) let t0 = (type a b, l: list, x: a) => list{x, ...l} -let t1 = (. type a b, l: list, x: a) => list{x, ...l} -let t2 = (. type a b, l: list, x: a) => list{x, ...l} -let t3 = (. type a b, l: list, x: a) => list{x, ...l} +let t1 = (type a b, l: list, x: a) => list{x, ...l} +let t2 = (type a b, l: list, x: a) => list{x, ...l} +let t3 = (type a b, l: list, x: a) => list{x, ...l} let t4 = (type a b, l: list, x: a) => list{x, ...l} -let t5 = (. type a b, l: list, x: a) => list{x, ...l} -let t6 = (. type a b, l: list, x: a) => list{x, ...l} +let t5 = (type a b, l: list, x: a) => list{x, ...l} +let t6 = (type a b, l: list, x: a) => list{x, ...l} let () = (x => ignore(x))(3) -let () = ((. x) => ignore(x))(. 3) +let () = (x => ignore(x))(3) -type arrowPath1 = (. int) => string -type arrowPath2 = (. I.t) => string +type arrowPath1 = int => string +type arrowPath2 = I.t => string type arrowPath3 = int => string type arrowPath4 = I.t => string type callback1 = (ReactEvent.Mouse.t => unit) as 'callback type callback2 = ReactEvent.Mouse.t => (unit as 'u) type callback3 = (ReactEvent.Mouse.t => unit) as 'callback -type callback4 = ((. ReactEvent.Mouse.t) => unit) as 'callback -type callback5 = (. ReactEvent.Mouse.t) => (unit as 'u) -type callback6 = ((. ReactEvent.Mouse.t) => unit) as 'callback +type callback4 = (ReactEvent.Mouse.t => unit) as 'callback +type callback5 = ReactEvent.Mouse.t => (unit as 'u) +type callback6 = (ReactEvent.Mouse.t => unit) as 'callback -let foo = (. ()) => () -let fn = (_x): ((. unit) => unit) => foo +let foo = () => () +let fn = (_x): (unit => unit) => foo let fooC = () => () let fnC = (_x): (unit => unit) => fooC -let a = ((. ()) => "foo")->Ok +let a = (() => "foo")->Ok let aC = (() => "foo")->Ok -let cApp = foo(. 3) +let cApp = foo(3) let uApp = foo(3) -let cFun = (. x) => 3 +let cFun = x => 3 let uFun = x => 3 -let mixFun = (. a) => {(b, c) => (. d, e, f) => (. g) => {h => 4}} -let bracesFun = x => (. y) => x + y -let cFun2 = (. x, y) => 3 +let mixFun = a => (b, c) => (d, e, f) => g => h => 4 +let bracesFun = x => y => x + y +let cFun2 = (x, y) => 3 let uFun2 = (x, y) => 3 -let cFun2Dots = (. x) => (. y) => 3 // redundant dot on y +let cFun2Dots = (x, y) => 3 // redundant dot on y -type cTyp = (. string) => int +type cTyp = string => int type uTyp = string => int -type mixTyp = (. string) => (string, string) => (. string, string, string, string) => string => int -type bTyp = string => (. string) => int -type cTyp2 = (. string, string) => int +type mixTyp = string => (string, string) => (string, string, string, string) => string => int +type bTyp = string => string => int +type cTyp2 = (string, string) => int type uTyp2 = (string, string) => int -type cu = (. unit) => int -type cp = (. unit) => int -type cuu = (. unit) => (. unit) => int -type cpu = (. unit) => (. unit) => int -type cup = (. unit) => (. unit) => int -type cpp = (. unit) => (. unit) => int -type cu2 = (. unit, unit) => unit -type cp2 = (. unit, unit) => unit +type cu = unit => int +type cp = unit => int +type cuu = unit => unit => int +type cpu = unit => unit => int +type cup = unit => unit => int +type cpp = unit => unit => int +type cu2 = (unit, unit) => unit +type cp2 = (unit, unit) => unit type uu = unit => int type up = unit => int -type uuu = (unit, unit) => int -type upu = (unit, unit) => int -type uup = (unit, unit) => int -type upp = (unit, unit) => int +type uuu = unit => unit => int +type upu = unit => unit => int +type uup = unit => unit => int +type upp = unit => unit => int type uu2 = (unit, unit) => unit type up2 = (unit, unit) => unit -type cnested = (. (. string) => unit) => unit +type cnested = (string => unit) => unit type unested = (string => unit) => unit let pipe = a->foo(b, c) @@ -122,8 +122,8 @@ let _ = setTimeout(() => { resolve(1) }, 100) -let _ = setTimeout(. (. ()) => { - resolve(. 1) +let _ = setTimeout(() => { + resolve(1) }, 100) let _ = @att x => 34 @@ -132,20 +132,20 @@ let _ = preserveAttr(@att x => 34) let _ = preserveAttr(@att async x => 34) let t0 = (type a b, l: list, x: a) => list{x, ...l} -let t1 = (. type a b, l: list, x: a) => list{x, ...l} -let t2 = (. type a b, l: list, x: a) => list{x, ...l} -let t3 = (. type a b, l: list, x: a) => list{x, ...l} +let t1 = (type a b, l: list, x: a) => list{x, ...l} +let t2 = (type a b, l: list, x: a) => list{x, ...l} +let t3 = (type a b, l: list, x: a) => list{x, ...l} let () = (x => ignore(x))(3) -let () = ((. x) => ignore(x))(. 3) +let () = (x => ignore(x))(3) -type arrowPath1 = (. int) => string -type arrowPath2 = (. I.t) => string +type arrowPath1 = int => string +type arrowPath2 = I.t => string type arrowPath3 = int => string type arrowPath4 = I.t => string -type callback1 = ((. ReactEvent.Mouse.t) => unit) as 'callback -type callback2 = (. ReactEvent.Mouse.t) => (unit as 'u) -type callback3 = ((. ReactEvent.Mouse.t) => unit) as 'callback +type callback1 = (ReactEvent.Mouse.t => unit) as 'callback +type callback2 = ReactEvent.Mouse.t => (unit as 'u) +type callback3 = (ReactEvent.Mouse.t => unit) as 'callback type callback4 = (ReactEvent.Mouse.t => unit) as 'callback type callback5 = ReactEvent.Mouse.t => (unit as 'u) type callback6 = (ReactEvent.Mouse.t => unit) as 'callback diff --git a/jscomp/syntax/tests/printer/expr/expected/apply.res.txt b/jscomp/syntax/tests/printer/expr/expected/apply.res.txt index 1cccb8a20b..c04b627ad2 100644 --- a/jscomp/syntax/tests/printer/expr/expected/apply.res.txt +++ b/jscomp/syntax/tests/printer/expr/expected/apply.res.txt @@ -13,9 +13,9 @@ let () = applyFunctionToArguments( superLongIdentifierWooooooowThisIsSuchLong, ) -let cmp = rbt.compare(. Js.Array2.unsafe_get(old, oldIter.contents), node.value) -let cmp = rbt.compare2(. Js.Array2.unsafe_get(old, oldIter.contents), longerNode.longValue) -let uncurriedUnit = apply(.) +let cmp = rbt.compare(Js.Array2.unsafe_get(old, oldIter.contents), node.value) +let cmp = rbt.compare2(Js.Array2.unsafe_get(old, oldIter.contents), longerNode.longValue) +let uncurriedUnit = apply() let coordinate = make2dCoordinate({x: 1, y: 2}) let coordinate = make3dCoordinate({ @@ -56,40 +56,40 @@ let user = makeJsUser({ let x = @attr callFunction() let x = @attrWithLongName @attrWithLongName @attrWithLongName @attrWithLongName callFunction() -(a |> f)(b, c) +f(a)(b, c) call(~a: int) call(~\"let": int) -document.createElementWithOptions(. "div", elementProps(~onClick=_ => Js.log("hello world"))) +document.createElementWithOptions("div", elementProps(~onClick=_ => Js.log("hello world"))) -f(. 1) -f(. [1, 2, 3]) -f(. [ +f(1) +f([1, 2, 3]) +f([ suuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuperLong, suuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuperLong, suuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuperLong, ]) -f(. (1, 2, 3)) -f(. {"a": 1}) -f(. list{1}) -f(. ` +f((1, 2, 3)) +f({"a": 1}) +f(list{1}) +f(` template string `) -f(. `single line`) -f(. " +f(`single line`) +f(" template string ") -f(. { +f({ expr }) -f(. {expr}) -f(. { +f({expr}) +f({ exception Exit raise(Exit) }) -resolve(.) -resolve(. ()) +resolve() +resolve() diff --git a/jscomp/syntax/tests/printer/expr/expected/assert.res.txt b/jscomp/syntax/tests/printer/expr/expected/assert.res.txt index 15fba13316..93d7d60d5c 100644 --- a/jscomp/syntax/tests/printer/expr/expected/assert.res.txt +++ b/jscomp/syntax/tests/printer/expr/expected/assert.res.txt @@ -17,7 +17,7 @@ let x = assert(%extension) let x = assert(user.name) let x = assert(streets[0]) let x = assert(apply(arg1, arg2)) -let x = assert(apply(. arg1, arg2)) +let x = assert(apply(arg1, arg2)) let x = assert(-1) let x = assert(!true) let x = assert(x => print(x)) diff --git a/jscomp/syntax/tests/printer/expr/expected/asyncAwait.res.txt b/jscomp/syntax/tests/printer/expr/expected/asyncAwait.res.txt index 69b231ced2..41435587ce 100644 --- a/jscomp/syntax/tests/printer/expr/expected/asyncAwait.res.txt +++ b/jscomp/syntax/tests/printer/expr/expected/asyncAwait.res.txt @@ -7,10 +7,10 @@ let sequentialAwait = async () => { } let f = async () => () -let f = async (. ()) => () +let f = async () => () let f = async f => f() let f = async (a, b) => a + b -let f = async (. a, b) => a + b +let f = async (a, b) => a + b let maybeSomeValue = switch await fetchData(url) { | data => Some(data) @@ -32,8 +32,8 @@ user.data = await fetch() let inBinaryExpression = await x->Js.Promise.resolve + 1 let inBinaryExpression = await x->Js.Promise.resolve + await y->Js.Promise.resolve -let withCallback = async (. ()) => { - async (. x) => await x->Js.promise.resolve + 1 +let withCallback = async () => { + async x => await x->Js.promise.resolve + 1 } let () = await (await fetch(url))->(await resolve) @@ -46,8 +46,8 @@ let _ = await !ref let _ = await f let _ = await %extension let _ = await "test" -let _ = await ((a, b) => a + b) -let _ = await (async (a, b) => a + b) +let _ = await (a, b) => a + b +let _ = await async (a, b) => a + b let _ = await ( switch x { | A => () @@ -67,7 +67,7 @@ let _ = await ( ) let _ = await (condition() ? true : false) let _ = await f(x) -let _ = await f(. x) +let _ = await f(x) let _ = (await (f(x): Js.Promise.t)) let _ = await ( while true { @@ -112,7 +112,7 @@ let f7 = async x => async (~y) => 3 let f8 = async (~x1, ~x2) => async (~y) => 3 let f9 = x => async (~y) => 3 let f10 = x => async y => 3 -let f11 = (. ~x) => (. ~y) => 3 +let f11 = (~x) => (~y) => 3 let f12 = @a (@b x) => 3 let f13 = @a @b (~x) => 3 @@ -135,11 +135,11 @@ let b3 = await foo->bar(~arg) let b4 = await foo.bar.baz let c1 = @foo x => @bar y => x + y -let c2 = (. x) => {y => x + y} -let c3 = (. x) => {@foo y => x + y} +let c2 = x => y => x + y +let c3 = x => @foo y => x + y -type t1 = (. int) => string => bool -type t2 = (. int, string) => bool +type t1 = int => string => bool +type t2 = (int, string) => bool let f = async (type a, ()) => { await Js.Promise.resolve() diff --git a/jscomp/syntax/tests/printer/expr/expected/binary.res.txt b/jscomp/syntax/tests/printer/expr/expected/binary.res.txt index db53bc0fc3..24dfb51c05 100644 --- a/jscomp/syntax/tests/printer/expr/expected/binary.res.txt +++ b/jscomp/syntax/tests/printer/expr/expected/binary.res.txt @@ -12,7 +12,7 @@ while continuePrefix.contents && aPrefixLen.contents && bPrefixLen.contents && f } // uncurried attribute shouldn't result in parens -while rbt.compare(. Js.Array2.unsafe_get(old, oldIter.contents), node.value) < 0 { +while rbt.compare(Js.Array2.unsafe_get(old, oldIter.contents), node.value) < 0 { () } @@ -31,16 +31,24 @@ let x = foo ++ bar let x = 1 + 1 let x = (a => a + 1) + (b => b + 2) let x = -1 + -1 -let x = switch z { -| Red => 1 -} |> switch y { -| Blue => 2 -} -let x = try z catch { -| Exit => 1 -} |> try y catch { -| Blue => 2 -} +let x = ( + switch y { + | Blue => 2 + } +)( + switch z { + | Red => 1 + }, +) +let x = ( + try y catch { + | Blue => 2 + } +)( + try z catch { + | Exit => 1 + }, +) let x = if true { 1 @@ -51,23 +59,27 @@ let x = } else { 3 } -let x = for i in 0 to 10 { - () -} |> for i in 0 to 10 { - () -} +let x = ( + for i in 0 to 10 { + () + } +)( + for i in 0 to 10 { + () + }, +) let x = (a, b) + (b, c) let x = Vec3(a, b, c) + Vec4(a, b, c, d) let x = {x: 1, y: 2} + {x: 2, y: 3} let x = user.firstName ++ user.lastName -let x = x.left = value |> x.right = value -let x = (x.left = value) |> x.right = value -let x = (x.left = value) |> x.right = value -let () = (x.left = value) |> logMutation -let () = x.left = value |> logMutation -let () = x.left = value |> process |> x.right = value |> process -let () = (x: int) |> (print_int: int => unit) +let x = x.left = (x.right = value)(value) +let x = (x.right = value)(x.left = value) +let x = (x.right = value)(x.left = value) +let () = logMutation(x.left = value) +let () = x.left = logMutation(value) +let () = x.left = (x.right = process(value))(process(value)) +let () = (print_int: int => unit)((x: int)) // math x + y / z @@ -192,8 +204,8 @@ let x = (@attr a) && (@attr b) && (@attr c) let x = a && @attr (b && c) let x = a && (@attr (b && c)) && @attr (d && e) -let x = a && @attr (x |> f(g)) -let x = a && (@attr (x |> f(g))) && @attr (y |> f(h)) +let x = a && (@attr f(g, x)) +let x = a && (@attr f(g, x)) && (@attr f(h, y)) let x = a && a.b let x = a && x.y && g.h @@ -226,11 +238,11 @@ let x = a && !b && !c let x = a && f(b) let x = a && f(b) && f(c) -let x = a && f(. b) -let x = a && f(. b) && f(. c) +let x = a && f(b) +let x = a && f(b) && f(c) -let x = a && x |> f(g) -let x = a && x |> f(g) && y |> f(h) +let x = a && f(g, x) +let x = a && f(g, x) && f(h, y) let x = a && @@ -400,25 +412,24 @@ let x = a && module(Foo: Bool) && module(Bar: Bool) let x = a && truths[0] let x = a && truths[0] && truths[1] -let () = node.left := value |> process |> node.right = value |> process -let () = (node.left := value |> process) |> node.right = value |> process +let () = node.left := (node.right = process(value))(process(value)) +let () = (node.right = process(value))(node.left := process(value)) let x = (true ? 0 : 1) + (false ? 1 : 0) let x = (true ? 0 : 1) + (false ? 1 : 0) + (false ? 1 : 0) while ( - oldIter.contents < oldLen && - rbt.compare(. Js.Array2.unsafe_get(old, oldIter.contents), node.value) + oldIter.contents < oldLen && rbt.compare(Js.Array2.unsafe_get(old, oldIter.contents), node.value) ) { - disappear(. Js.Array2.unsafe_get(old, oldIter.contents)) + disappear(Js.Array2.unsafe_get(old, oldIter.contents)) oldIter.contents = oldIter.contents + 1 } while ( oldIter.contents < oldLen && - rbt.compare(. Js.Array2.unsafe_get(old, oldIter.contents), node.value) < 0 + rbt.compare(Js.Array2.unsafe_get(old, oldIter.contents), node.value) < 0 ) { - disappear(. Js.Array2.unsafe_get(old, oldIter.contents)) + disappear(Js.Array2.unsafe_get(old, oldIter.contents)) oldIter.contents = oldIter.contents + 1 } @@ -455,18 +466,16 @@ x->(y->(z->w)) x->(y && (w && z)) x->y->z -x |> y |> z -x |> (y |> z) -x |> (y |> (z |> w)) +z(y(x)) +z(y, x) +w(z, y, x) -let x = "z" ++ (a |> f) ++ "x" +let x = "z" ++ f(a) ++ "x" let toString = functionArgs => { - functionArgs == [] - ? "" - : "<" ++ (functionArgs |> List.map(argToString) |> String.concat(",")) ++ ">" + functionArgs == [] ? "" : "<" ++ String.concat(",", List.map(argToString, functionArgs)) ++ ">" } -a |> Author.id != (author |> Author.id) +Author.id(a) != Author.id(author) // should indent the switch foo := @@ -475,15 +484,17 @@ foo := }
- {possibleGradeValues - |> List.filter(g => g < state.maxGrade) - |> List.map(possibleGradeValue => - - ) - |> Array.of_list - |> ReasonReact.array} + {ReasonReact.array( + Array.of_list( + List.map( + possibleGradeValue => + , + List.filter(g => g < state.maxGrade, possibleGradeValues), + ), + ), + )}
let aggregateTotal = (forecast, ~audienceType) => @@ -498,13 +509,13 @@ let aggregateTotal = (forecast, ~audienceType) => React.useEffect4(() => { switch (context.library, context.account) { | (Some(library), Some(account)) => - library.getBalance(. account) + library.getBalance(account) ->Promise.Js.catch(_ => {Promise.resolved(None)}) ->Promise.get(newBalance => { dispatch( LoadAddress( account, - newBalance->Belt.Option.flatMap(balance => Eth.make(balance.toString(.))), + newBalance->Belt.Option.flatMap(balance => Eth.make(balance.toString())), ), ) }) diff --git a/jscomp/syntax/tests/printer/expr/expected/braced.res.txt b/jscomp/syntax/tests/printer/expr/expected/braced.res.txt index 0ca6ce4ed5..26c9d855b4 100644 --- a/jscomp/syntax/tests/printer/expr/expected/braced.res.txt +++ b/jscomp/syntax/tests/printer/expr/expected/braced.res.txt @@ -278,7 +278,7 @@ apply(~a={a}) apply({ a }) -apply(. { +apply({ a }) diff --git a/jscomp/syntax/tests/printer/expr/expected/callback.res.txt b/jscomp/syntax/tests/printer/expr/expected/callback.res.txt index 4e04e8a787..d38643f0d7 100644 --- a/jscomp/syntax/tests/printer/expr/expected/callback.res.txt +++ b/jscomp/syntax/tests/printer/expr/expected/callback.res.txt @@ -61,8 +61,8 @@ let _ = { } let trees = - possibilities->Belt.Array.mapU((. combination) => - combination->Belt.Array.reduceU(Nil, (. tree, curr) => tree->insert(curr)) + possibilities->Belt.Array.mapU(combination => + combination->Belt.Array.reduceU(Nil, (tree, curr) => tree->insert(curr)) ) let set = mapThatHasAVeryLongName->Belt.Map.String.getExn(website)->Belt.Set.Int.add(user) @@ -83,8 +83,8 @@ let add2 = (y: coll, e: key) => let add2 = (y: coll, e: key) => if ( - possibilities->Belt.Array.mapU((. combination) => - combination->Belt.Array.reduceU(Nil, (. tree, curr) => tree->insert(curr)) + possibilities->Belt.Array.mapU(combination => + combination->Belt.Array.reduceU(Nil, (tree, curr) => tree->insert(curr)) ) ) { y @@ -92,15 +92,17 @@ let add2 = (y: coll, e: key) => list{e, ...y} } -let test = - moduleTypeDeclaration - |> TranslateSignature.translateModuleTypeDeclaration( +let test = doStuff( + ~x, + ~y, + TranslateSignature.translateModuleTypeDeclaration( ~config, ~outputFileRelative, ~resolver, ~typeEnv, - ) - |> doStuff(~x, ~y) + moduleTypeDeclaration, + ), +) // labelled arguments // callback in last position @@ -216,18 +218,18 @@ let f = () => { } myPromise -->Js.Promise.then_(value => { +->(Js.Promise.then_(value => { Js.log(value) Js.Promise.resolve(value + 2) -}, _) -->Js.Promise.then_(value => { +}, _)) +->(Js.Promise.then_(value => { Js.log(value) Js.Promise.resolve(value + 3) -}, _) -->Js.Promise.catch(err => { - Js.log2("Failure!!", err) - Js.Promise.resolve(-2) -}, _) +}, _)) +->(Js.Promise.catch(err => { + Js.log2("Failure!!", err) + Js.Promise.resolve(-2) + }, _)) let decoratorTags = items diff --git a/jscomp/syntax/tests/printer/expr/expected/field.res.txt b/jscomp/syntax/tests/printer/expr/expected/field.res.txt index 98b169851a..217b82b11c 100644 --- a/jscomp/syntax/tests/printer/expr/expected/field.res.txt +++ b/jscomp/syntax/tests/printer/expr/expected/field.res.txt @@ -17,10 +17,10 @@ let x = (%extension).x let x = user.name.last let x = streets[0].house let x = apply(arg1, arg2).field -let x = apply(. arg1, arg2).field +let x = apply(arg1, arg2).field let x = (-1).x let x = (!true).x -let x = (x => print(x)).x +//let x = (x => print(x)).x let x = ( switch x { | Blue => () diff --git a/jscomp/syntax/tests/printer/expr/expected/fun.res.txt b/jscomp/syntax/tests/printer/expr/expected/fun.res.txt index a1ff38fa4f..9821a0e93d 100644 --- a/jscomp/syntax/tests/printer/expr/expected/fun.res.txt +++ b/jscomp/syntax/tests/printer/expr/expected/fun.res.txt @@ -64,16 +64,16 @@ let f = _ => () let f = (~a=?) => () let f = (~from as hometown=?) => () -let f = (. a) => () -let f = (. a, b) => () -let f = (. ()) => () +let f = a => () +let f = (a, b) => () +let f = () => () let f = @attr (a, b) => @attr2 (c, d) => () let f = @attr (@attrOnA a, @attrOnB b) => @attr2 (@attrOnC c, @attrOnD d) => () -let f = @attr (. a, b) => @attr2 (. c, d) => () +let f = @attr (a, b) => @attr2 (c, d) => () let f = (@attr ~a, @attr ~b) => () -let f = (. @attr ~a) => (. @attr ~b) => () +let f = (@attr ~a, @attr ~b) => () let f = ( thisIsAVeryLongNaaaaaaaaaaaaaaaaaaameeeeeeeeeeeee, @@ -178,11 +178,11 @@ let constrBuilder = ( let genName = () => "Steve" @react.component -let make = (~onChange: option<(. {"testing": bool}, array) => unit>=?, children) => { +let make = (~onChange: option<({"testing": bool}, array) => unit>=?, children) => { let doSomething = () => switch onChange { | None => () - | Some(onChange) => onChange(. {"testing": true}, ["hey"]) + | Some(onChange) => onChange({"testing": true}, ["hey"]) } doSomething()} /> } @@ -345,14 +345,14 @@ let query = (~url, ()): (unit => unit) => { () => Js.log("Queried " ++ url) } -let query = (~url, ()): ((unit, unit) => unit) => { - ((), ()) => Js.log("Queried " ++ url) +let query = (~url, ()): (unit => unit => unit) => { + () => () => Js.log("Queried " ++ url) } -let query = (~url, ()): ((unit, unit, unit) => unit) => { - ((), (), ()) => Js.log("Queried " ++ url) +let query = (~url, ()): (unit => unit => unit => unit) => { + () => () => () => Js.log("Queried " ++ url) } -let f = (. a) => (. b) => a + b -let f = (. a, b) => (. b, c) => a + b + c + d -let f = (. a, b) => (. b, c) => (. e, f, g) => a + b + c + d + e + f + g +let f = a => b => a + b +let f = (a, b) => (b, c) => a + b + c + d +let f = (a, b) => (b, c) => (e, f, g) => a + b + c + d + e + f + g diff --git a/jscomp/syntax/tests/printer/expr/expected/jsObjectSet.res.txt b/jscomp/syntax/tests/printer/expr/expected/jsObjectSet.res.txt index d66f72bef0..707a0897a1 100644 --- a/jscomp/syntax/tests/printer/expr/expected/jsObjectSet.res.txt +++ b/jscomp/syntax/tests/printer/expr/expected/jsObjectSet.res.txt @@ -1,6 +1,6 @@ address["street"] = "Brusselsestraat" -address["street"] = newYork |> getExpensiveStreet +address["street"] = getExpensiveStreet(newYork) let () = @attr address["street"] = "Brusselsestraat" -let () = node["left"] = value |> process |> node["right"] = value |> process -let () = (node["left"] = value |> process) |> node["right"] = value |> process +let () = node["left"] = \"#="(node["right"], process(value), process(value)) +let () = \"#="(node["right"], process(value), node["left"] = process(value)) diff --git a/jscomp/syntax/tests/printer/expr/expected/jsx.res.txt b/jscomp/syntax/tests/printer/expr/expected/jsx.res.txt index f63ffeac15..2384f5ecb6 100644 --- a/jscomp/syntax/tests/printer/expr/expected/jsx.res.txt +++ b/jscomp/syntax/tests/printer/expr/expected/jsx.res.txt @@ -147,7 +147,7 @@ let x = sideEffect(aaaaaaaaaaaaaaarg3) }} apply={myFunction(x)} - applyWithDot={myFunction(. x)} + applyWithDot={myFunction(x)} street={streets[0]} binary={a + b} int={-1} @@ -226,7 +226,7 @@ let x = sideEffect(aaaaaaaaaaaaaaarg3) }} {myFunction(x)} - {myFunction(. x)} + {myFunction(x)} {streets[0]} {a + b} {-1} @@ -288,15 +288,17 @@ let x = let x = test } nav={} />
- {possibleGradeValues - |> List.filter(g => g <= state.maxGrade) - |> List.map(possibleGradeValue => - - ) - |> Array.of_list - |> ReasonReact.array} + {ReasonReact.array( + Array.of_list( + List.map( + possibleGradeValue => + , + List.filter(g => g <= state.maxGrade, possibleGradeValues), + ), + ), + )}
// https://github.com/rescript-lang/syntax/issues/113 diff --git a/jscomp/syntax/tests/printer/expr/expected/pipe.res.txt b/jscomp/syntax/tests/printer/expr/expected/pipe.res.txt index a6ae377f53..b1a7d95a30 100644 --- a/jscomp/syntax/tests/printer/expr/expected/pipe.res.txt +++ b/jscomp/syntax/tests/printer/expr/expected/pipe.res.txt @@ -1,8 +1,8 @@ let s1 = @ann (x->foo) let s1b = (@ann x)->foo -let s2 = @ann (x |> foo) -let s2b = (@ann x) |> foo +let s2 = @ann foo(x) +let s2b = foo(@ann x) let s3 = @ann (x ** foo) let s3b = (@ann x) ** foo diff --git a/jscomp/syntax/tests/printer/expr/expected/record.res.txt b/jscomp/syntax/tests/printer/expr/expected/record.res.txt index 8b07a35cff..b3ac165e2f 100644 --- a/jscomp/syntax/tests/printer/expr/expected/record.res.txt +++ b/jscomp/syntax/tests/printer/expr/expected/record.res.txt @@ -101,4 +101,4 @@ let optParen = {x: 3, y: ?(someBool ? Some("") : None)} let optParen = {x: 3, y: ?(3 + 4)} let optParen = {x: 3, y: ?foo(bar)} let optParen = {x: 3, y: ?foo->bar} -let optParen = {x: 3, y: ?(() => 3)} +let optParen = {x: 3, y: ?() => 3} diff --git a/jscomp/syntax/tests/printer/expr/expected/setfield.res.txt b/jscomp/syntax/tests/printer/expr/expected/setfield.res.txt index c66472001e..5de0c1b523 100644 --- a/jscomp/syntax/tests/printer/expr/expected/setfield.res.txt +++ b/jscomp/syntax/tests/printer/expr/expected/setfield.res.txt @@ -4,7 +4,7 @@ config.shouldSkip = let () = @attr user.name = "steve" -let () = @attr user.name = "steve" |> @attr user.name = "steve" +let () = @attr user.name = (@attr user.name = "steve")("steve") user.name = steve["name"] user.address = addresses[2] diff --git a/jscomp/syntax/tests/printer/expr/expected/ternary.res.txt b/jscomp/syntax/tests/printer/expr/expected/ternary.res.txt index 6af0e980ca..7b81daec25 100644 --- a/jscomp/syntax/tests/printer/expr/expected/ternary.res.txt +++ b/jscomp/syntax/tests/printer/expr/expected/ternary.res.txt @@ -110,14 +110,14 @@ let x = truth thisIsASuperLongIdentifieeeeeeeer2, thisIsASuperLongIdentifieeeeeeeer3, ) -let x = truth ? create(. a, b) : create(. b, c) +let x = truth ? create(a, b) : create(b, c) let x = truth - ? create(. + ? create( thisIsASuperLongIdentifieeeeeeeer, thisIsASuperLongIdentifieeeeeeeer2, thisIsASuperLongIdentifieeeeeeeer3, ) - : create(. + : create( thisIsASuperLongIdentifieeeeeeeer, thisIsASuperLongIdentifieeeeeeeer2, thisIsASuperLongIdentifieeeeeeeer3, diff --git a/jscomp/syntax/tests/printer/expr/expected/unary.res.txt b/jscomp/syntax/tests/printer/expr/expected/unary.res.txt index 4f7ad8b0f9..62fc8f8075 100644 --- a/jscomp/syntax/tests/printer/expr/expected/unary.res.txt +++ b/jscomp/syntax/tests/printer/expr/expected/unary.res.txt @@ -6,7 +6,7 @@ let isMale = !user["female"] !(!a) !(!(!a)) -!(a |> f(b)) +!f(b, a) -1->add -1->add @@ -27,7 +27,7 @@ let x = -a.bar !(assert(x)) assert(!x) !(@attr expr) -!(arg => doStuffWith(arg)) +//!(arg => doStuffWith(arg)) let x = !(truth: bool) let x = (!truth: bool) @@ -37,7 +37,7 @@ let z = !(%extension) !module(Foo: Bar) !module(Foo) let x = -apply(arg) -let x = -apply(. arg) +let x = -apply(arg) let x = -Foo(a, b, c) let x = -{x: 1, y: 2} let x = -list{1, 2, 3} diff --git a/jscomp/syntax/tests/printer/expr/expected/underscoreApply.res.txt b/jscomp/syntax/tests/printer/expr/expected/underscoreApply.res.txt index 0f72ee325e..dc58ba4594 100644 --- a/jscomp/syntax/tests/printer/expr/expected/underscoreApply.res.txt +++ b/jscomp/syntax/tests/printer/expr/expected/underscoreApply.res.txt @@ -10,33 +10,33 @@ let x = f(~a=_, ~b=_, ~c=g(~x=2, ~y=_, ~z=_)) let nested = x => List.length(_) let nested2 = (x, y, z) => List.length(_) -let l = [1, 2, 3] |> List.map(i => i + 1, _) |> List.filter(i => i > 0, _) +let l = (List.filter(i => i > 0, _))((List.map(i => i + 1, _))([1, 2, 3])) -let l = (i => i + 1) |> List.map(_, [1, 2, 3]) +let l = (List.map(_, [1, 2, 3]))(i => i + 1) let x = List.length(_) let incr = (~v) => v + 1 -let l1 = [1, 2, 3] |> List.map(incr(~v=_)) |> List.length +let l1 = List.length(List.map(incr(~v=_), [1, 2, 3])) -let l2 = [1, 2, 3] |> List.map(incr(~v=_)) |> List.length +let l2 = List.length(List.map(incr(~v=_), [1, 2, 3])) let optParam = (~v=?, ()) => v == None ? 0 : 1 -let l1 = [Some(1), None, Some(2)] |> List.map(optParam(~v=?_, ())) |> List.length +let l1 = List.length(List.map(optParam(~v=?_, ()), [Some(1), None, Some(2)])) -let l2 = [Some(1), None, Some(2)] |> List.map(optParam(~v=?_, ())) |> List.length +let l2 = List.length(List.map(optParam(~v=?_, ()), [Some(1), None, Some(2)])) // callback in last position f(a, b, (a, b) => List.length(_)) // callback in first position f((a, b) => List.length(_), a, b) -f(a, b, _)(x, y) +(f(a, b, _))(x, y) -f(a, b, _) -f(a, b, _) + g(x, _, z) -f(a, b, _) + g(x, _, z) + h(alpha, beta, _) +(f(a, b, _)) + (g(x, _, z)) +(f(a, b, _)) + (g(x, _, z)) + (h(alpha, beta, _)) assert(f(a, b, _)) @@ -52,14 +52,14 @@ f(a, b, _)[ix] = 2 getDirector(a, b, _).name = "Steve" -filterNone |> Array.get(_, 0) -filterNone->Array.get(_, 0) +(Array.get(_, 0))(filterNone) +filterNone->(Array.get(_, 0)) Array.get(_, 0) -1 + Array.get(_, 0) -Array.get(_, 1) + Array.get(_, 0) +1 + (Array.get(_, 0)) +(Array.get(_, 1)) + (Array.get(_, 0)) let f = Array.get(_, 0) -let photo = pricedRoom["room"]["photos"] |> filterNone |> Array.get(_, 0) +let photo = (Array.get(_, 0))(filterNone(pricedRoom["room"]["photos"])) underscoreWithComments(// Comment 1 x => { diff --git a/jscomp/syntax/tests/printer/expr/field.res b/jscomp/syntax/tests/printer/expr/field.res index f0f48c55f8..e8a1a62760 100644 --- a/jscomp/syntax/tests/printer/expr/field.res +++ b/jscomp/syntax/tests/printer/expr/field.res @@ -21,7 +21,7 @@ let x = apply(arg1, arg2).field let x = apply(. arg1, arg2).field let x = (-1).x let x = (!true).x -let x = (x => print(x)).x +//let x = (x => print(x)).x let x = (switch x { | Blue => () | Yello => () diff --git a/jscomp/syntax/tests/printer/expr/unary.res b/jscomp/syntax/tests/printer/expr/unary.res index f7aa2905b5..20f6811655 100644 --- a/jscomp/syntax/tests/printer/expr/unary.res +++ b/jscomp/syntax/tests/printer/expr/unary.res @@ -28,7 +28,7 @@ let x = -(a.bar) !(assert(x)) assert(!x) !(@attr expr) -!(arg => doStuffWith(arg)) +//!(arg => doStuffWith(arg)) let x = !(truth: bool) let x = (!truth: bool) diff --git a/jscomp/syntax/tests/printer/structure/expected/include.res.txt b/jscomp/syntax/tests/printer/structure/expected/include.res.txt index 92a19b5e19..a3e5aa2bbd 100644 --- a/jscomp/syntax/tests/printer/structure/expected/include.res.txt +++ b/jscomp/syntax/tests/printer/structure/expected/include.res.txt @@ -12,8 +12,7 @@ include ( external apply: ('theFunction, 'theContext, 'arguments) => 'returnTypeOfTheFunction = "apply" let createElementVariadic = (domClassName, ~props=?, children) => { - let variadicArguments = - [Obj.magic(domClassName), Obj.magic(props)] |> Js.Array.concat(children) + let variadicArguments = Js.Array.concat(children, [Obj.magic(domClassName), Obj.magic(props)]) createElementInternalHack->apply(Js.Nullable.null, variadicArguments) } }: { diff --git a/jscomp/syntax/tests/printer/typexpr/expected/arrow.res.txt b/jscomp/syntax/tests/printer/typexpr/expected/arrow.res.txt index 2c29260aba..4acc006e6d 100644 --- a/jscomp/syntax/tests/printer/typexpr/expected/arrow.res.txt +++ b/jscomp/syntax/tests/printer/typexpr/expected/arrow.res.txt @@ -125,14 +125,14 @@ type t = ( type t = (@attr string, @attr float) => unit type t = (@attr @attr2 string, @attr @attr2 float, @attr3 int) => unit -type t = @attr (string => unit) +type t = @attr string => unit type t = @attr (foo, bar, baz) => unit type t = @attr (foo, @attr2 ~f: bar, @attr3 ~f: baz) => unit -type t = @attr (string => @attr (int => unit)) +type t = @attr string => @attr int => unit type t = @attr (string, int) => @attr (int, float) => unit -type t = @attr (int => @attr (int, float) => @attr (unit, unit) => unit) -type t = (@attr @attr2 ~f: int, @attr3 ~g: float) => unit +type t = @attr int => @attr (int, float) => @attr unit => unit => unit +type t = @attr (@attr2 ~f: int, @attr3 ~g: float) => unit type f = ( @attr @attr @attr @attr @attr @attr @attr @attr @attr ~f: superLong, @@ -144,50 +144,50 @@ type f = ( @attr3 ~h: ccccrazysldkfjslkdjflksdjkf=?, ) => unit -type t = @attr ( - stringWithSuperLongIdentifierNameLoooooooooooooooooooooooooooooooooooooooooooooong => @attr2 ( - floatWithSuperLongIdentifierNameLoooooooooooooooooooooooooooooooooooooooooooooong => @attr3 ( - intWithSuperLongIdentifierNameLoooooooooooooooooooooooooooooooooooooooooooooong => unitWithSuperLongIdentifierNameLoooooooooooooooooooooooooooooooooooooooooooooong - ) - ) -) +type t = @attr +stringWithSuperLongIdentifierNameLoooooooooooooooooooooooooooooooooooooooooooooong => @attr2 +floatWithSuperLongIdentifierNameLoooooooooooooooooooooooooooooooooooooooooooooong => @attr3 +intWithSuperLongIdentifierNameLoooooooooooooooooooooooooooooooooooooooooooooong => unitWithSuperLongIdentifierNameLoooooooooooooooooooooooooooooooooooooooooooooong -type t = @attr ( +type t = @attr +( fooWithSuperLongIdentifierNameLoooooooooooooooooooooooooooooooooooooooooooooong, barWithSuperLongIdentifierNameLoooooooooooooooooooooooooooooooooooooooooooooong, bazWithSuperLongIdentifierNameLoooooooooooooooooooooooooooooooooooooooooooooong, -) => @attr2 ( +) => @attr2 +( stringWithSuperLongIdentifierNameLoooooooooooooooooooooooooooooooooooooooooooooong, floatWithSuperLongIdentifierNameLoooooooooooooooooooooooooooooooooooooooooooooong, ) => unit type t = @attr @attrWithSuperLongIdentifierNameLoooooooooooooooooooooooooooooooooooooooooooooong -@attrWithSuperLongIdentifierNameLoooooooooooooooooooooooooooooooooooooooooooooong ( +@attrWithSuperLongIdentifierNameLoooooooooooooooooooooooooooooooooooooooooooooong +( fooWithSuperLongIdentifierNameLoooooooooooooooooooooooooooooooooooooooooooooong, barWithSuperLongIdentifierNameLoooooooooooooooooooooooooooooooooooooooooooooong, bazWithSuperLongIdentifierNameLoooooooooooooooooooooooooooooooooooooooooooooong, ) => @attr2 @attrWithSuperLongIdentifierNameLoooooooooooooooooooooooooooooooooooooooooooooong -@attrWithSuperLongIdentifierNameLoooooooooooooooooooooooooooooooooooooooooooooong ( +@attrWithSuperLongIdentifierNameLoooooooooooooooooooooooooooooooooooooooooooooong +( stringWithSuperLongIdentifierNameLoooooooooooooooooooooooooooooooooooooooooooooong, floatWithSuperLongIdentifierNameLoooooooooooooooooooooooooooooooooooooooooooooong, ) => unit external debounce: (int, @meth unit) => unit = "debounce" -external debounce: int => @meth (unit => unit) = "debounce" +external debounce: int => @meth unit => unit = "debounce" -external debounce: (int, @meth (unit => unit)) => @meth (unit => unit) = "debounce" +external debounce: (int, @meth unit => unit) => @meth unit => unit = "debounce" -external debounce: (int, @meth (unit => unit), @meth (unit => unit)) => @meth (unit => unit) = - "debounce" +external debounce: (int, @meth unit => unit, @meth unit => unit) => @meth unit => unit = "debounce" external debounce: ( int, - @meth (unit => unit), - @meth (unit => @meth (unit => unit)), -) => @meth (unit => unit) = "debounce" + @meth unit => unit, + @meth unit => @meth unit => unit, +) => @meth unit => unit = "debounce" type returnTyp = (int, int) => @magic float type returnTyp = ( @@ -203,18 +203,18 @@ type returnTyp = ( float // uncurried -type t = (. int) => int -type t = (. int, int) => int -type t = (. int) => (. int) => int -type t = (. int, int) => (. int, int) => int +type t = int => int +type t = (int, int) => int +type t = (int, int) => int +type t = (int, int, int, int) => int -type t = (. @attr int) => unit -type t = (. @attr int) => (. @attr2 int) => unit -type t = (. @attrOnInt int, @attrOnInt int) => (. @attrOnInt int, @attrOnInt int) => int -type t = (. @attr ~x: int, ~y: int) => (. @attr ~z: int, @attr ~omega: int) => unit +type t = @attr int => unit +type t = (@attr int, @attr2 int) => unit +type t = (@attrOnInt int, @attrOnInt int, @attrOnInt int, @attrOnInt int) => int +type t = (@attr ~x: int, ~y: int, @attr ~z: int, @attr ~omega: int) => unit @val external requestAnimationFrame: (float => unit) => unit = "requestAnimationFrame" -@val external requestAnimationFrame: @attr ((float => unit) => unit) = "requestAnimationFrame" +@val external requestAnimationFrame: @attr (float => unit) => unit = "requestAnimationFrame" type arrows = (int, (float => unit) => unit, float) => unit diff --git a/jscomp/test/arith_lexer.js b/jscomp/test/arith_lexer.js index a0653b9414..7ede8cf05e 100644 --- a/jscomp/test/arith_lexer.js +++ b/jscomp/test/arith_lexer.js @@ -2,8 +2,8 @@ 'use strict'; let Lexing = require("../../lib/js/lexing.js"); +let Pervasives = require("../../lib/js/pervasives.js"); let Caml_format = require("../../lib/js/caml_format.js"); -let PervasivesU = require("../../lib/js/pervasivesU.js"); let __ocaml_lex_tables = { lex_base: "\x00\x00\xf6\xff\xf7\xff\xf8\xff\xf9\xff\xfa\xff\xfb\xff\xfc\xff\ @@ -165,7 +165,7 @@ function lexeme(lexbuf) { function str(e) { switch (e.TAG) { case "Numeral" : - return PervasivesU.string_of_float(e._0); + return Pervasives.string_of_float(e._0); case "Plus" : return str(e._0) + ("+" + str(e._1)); case "Minus" : diff --git a/jscomp/test/arith_syntax.js b/jscomp/test/arith_syntax.js index d1b8edbf2f..1847109dfd 100644 --- a/jscomp/test/arith_syntax.js +++ b/jscomp/test/arith_syntax.js @@ -1,12 +1,12 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -let PervasivesU = require("../../lib/js/pervasivesU.js"); +let Pervasives = require("../../lib/js/pervasives.js"); function str(e) { switch (e.TAG) { case "Numeral" : - return PervasivesU.string_of_float(e._0); + return Pervasives.string_of_float(e._0); case "Plus" : return str(e._0) + ("+" + str(e._1)); case "Minus" : diff --git a/jscomp/test/bench.js b/jscomp/test/bench.js index f51082342d..d23518c4a5 100644 --- a/jscomp/test/bench.js +++ b/jscomp/test/bench.js @@ -2,7 +2,7 @@ 'use strict'; let Caml_array = require("../../lib/js/caml_array.js"); -let PervasivesU = require("../../lib/js/pervasivesU.js"); +let Pervasives = require("../../lib/js/pervasives.js"); function map(f, a) { let f$1 = function (x) { @@ -62,7 +62,7 @@ function f2() { let v = fold_left((function (prim0, prim1) { return prim0 + prim1; }), 0, b); - console.log(PervasivesU.string_of_float(v)); + console.log(Pervasives.string_of_float(v)); } f2(); diff --git a/jscomp/test/build.ninja b/jscomp/test/build.ninja index 0d3c2401e3..d3d8237e0f 100644 --- a/jscomp/test/build.ninja +++ b/jscomp/test/build.ninja @@ -1,5 +1,5 @@ -bsc_flags = -bs-cross-module-opt -make-runtime-test -bs-package-output commonjs:jscomp/test -w -3-6-26-27-29-30-32..40-44-45-52-60-9-106+104 -warn-error A -I runtime -I $stdlib -I others -uncurried +bsc_flags = -bs-cross-module-opt -make-runtime-test -bs-package-output commonjs:jscomp/test -w -3-6-26-27-29-30-32..40-44-45-52-60-9-106+104 -warn-error A -I runtime -I $stdlib -I others rule cc command = $bsc -bs-cmi -bs-cmj $bsc_flags -I test $in diff --git a/jscomp/test/caml_compare_bigint_test.js b/jscomp/test/caml_compare_bigint_test.js index 907e14a663..1427f44a73 100644 --- a/jscomp/test/caml_compare_bigint_test.js +++ b/jscomp/test/caml_compare_bigint_test.js @@ -3,7 +3,7 @@ let Mt = require("./mt.js"); let Caml_obj = require("../../lib/js/caml_obj.js"); -let PervasivesU = require("../../lib/js/pervasivesU.js"); +let Pervasives = require("../../lib/js/pervasives.js"); function isLessThan(title, small, big) { return { @@ -423,7 +423,7 @@ function isEqual(title, num1, num2) { let five = BigInt("5"); -let suites = PervasivesU.$at(isLessThan("123 and 555555", BigInt("123"), BigInt("555555")), PervasivesU.$at(isEqual("98765 and 98765", BigInt("98765"), BigInt("98765")), isEqual("same instance", five, five))); +let suites = Pervasives.$at(isLessThan("123 and 555555", BigInt("123"), BigInt("555555")), Pervasives.$at(isEqual("98765 and 98765", BigInt("98765"), BigInt("98765")), isEqual("same instance", five, five))); Mt.from_pair_suites("caml_compare_bigint_test.res", suites); diff --git a/jscomp/test/caml_format_test.js b/jscomp/test/caml_format_test.js index a7e67f6659..6fee11065f 100644 --- a/jscomp/test/caml_format_test.js +++ b/jscomp/test/caml_format_test.js @@ -4,8 +4,8 @@ let Mt = require("./mt.js"); let $$Array = require("../../lib/js/array.js"); let Caml_int64 = require("../../lib/js/caml_int64.js"); +let Pervasives = require("../../lib/js/pervasives.js"); let Caml_format = require("../../lib/js/caml_format.js"); -let PervasivesU = require("../../lib/js/pervasivesU.js"); let of_string = [ [ @@ -80,7 +80,7 @@ let of_string = [ function from_float_of_string(xs) { return $$Array.mapi((function (i, param) { - return PervasivesU.string_of_float; + return Pervasives.string_of_float; }), xs); } @@ -141,19 +141,19 @@ let pairs$1 = [ ] ]; -let suites = PervasivesU.$at(from_of_string(of_string), PervasivesU.$at({ +let suites = Pervasives.$at(from_of_string(of_string), Pervasives.$at({ hd: [ "isnan_of_string", (function () { return { TAG: "Eq", _0: true, - _1: PervasivesU.classify_float(Caml_format.float_of_string("nan")) === "FP_nan" + _1: Pervasives.classify_float(Caml_format.float_of_string("nan")) === "FP_nan" }; }) ], tl: /* [] */0 -}, PervasivesU.$at($$Array.to_list($$Array.mapi((function (i, param) { +}, Pervasives.$at($$Array.to_list($$Array.mapi((function (i, param) { let b = param[1]; let a = param[0]; return [ @@ -162,11 +162,11 @@ let suites = PervasivesU.$at(from_of_string(of_string), PervasivesU.$at({ return { TAG: "Eq", _0: a, - _1: PervasivesU.classify_float(Caml_format.float_of_string(b)) + _1: Pervasives.classify_float(Caml_format.float_of_string(b)) }; }) ]; -}), pairs)), PervasivesU.$at({ +}), pairs)), Pervasives.$at({ hd: [ "throw", (function () { @@ -223,12 +223,12 @@ let float_data = [ ], [ "%f", - PervasivesU.infinity, + Pervasives.infinity, "inf" ], [ "%f", - PervasivesU.neg_infinity, + Pervasives.neg_infinity, "-inf" ], [ @@ -423,7 +423,7 @@ let of_string_data = [ ] ]; -let extra = PervasivesU.$at(suites, PervasivesU.$at($$Array.to_list($$Array.mapi((function (i, param) { +let extra = Pervasives.$at(suites, Pervasives.$at($$Array.to_list($$Array.mapi((function (i, param) { let str_result = param[2]; let f = param[1]; let fmt = param[0]; @@ -437,7 +437,7 @@ let extra = PervasivesU.$at(suites, PervasivesU.$at($$Array.to_list($$Array.mapi }; }) ]; -}), float_data)), PervasivesU.$at(int64_suites, $$Array.to_list($$Array.mapi((function (i, param) { +}), float_data)), Pervasives.$at(int64_suites, $$Array.to_list($$Array.mapi((function (i, param) { let b = param[1]; let a = param[0]; return [ diff --git a/jscomp/test/digest_test.js b/jscomp/test/digest_test.js index f3d612c5f2..645a59a61f 100644 --- a/jscomp/test/digest_test.js +++ b/jscomp/test/digest_test.js @@ -5,7 +5,7 @@ let Mt = require("./mt.js"); let $$Array = require("../../lib/js/array.js"); let Digest = require("../../lib/js/digest.js"); let Caml_array = require("../../lib/js/caml_array.js"); -let PervasivesU = require("../../lib/js/pervasivesU.js"); +let Pervasives = require("../../lib/js/pervasives.js"); let Ext_array_test = require("./ext_array_test.js"); function f(x) { @@ -145,7 +145,7 @@ let ref = [ "b325dc1c6f5e7a2b7cf465b9feab7948" ]; -let extra = PervasivesU.$at({ +let extra = Pervasives.$at({ hd: [ "File \"digest_test.res\", line 9, characters 9-16", (function () { diff --git a/jscomp/test/earger_curry_test.js b/jscomp/test/earger_curry_test.js index 91481c8a07..f7ad48dad5 100644 --- a/jscomp/test/earger_curry_test.js +++ b/jscomp/test/earger_curry_test.js @@ -3,7 +3,7 @@ let Mt = require("./mt.js"); let Caml_array = require("../../lib/js/caml_array.js"); -let PervasivesU = require("../../lib/js/pervasivesU.js"); +let Pervasives = require("../../lib/js/pervasives.js"); function map(f, a) { let f$1 = function (x) { @@ -63,7 +63,7 @@ function f2() { let v = fold_left((function (prim0, prim1) { return prim0 + prim1; }), 0, b); - console.log(PervasivesU.string_of_float(v)); + console.log(Pervasives.string_of_float(v)); } f2(); diff --git a/jscomp/test/epsilon_test.js b/jscomp/test/epsilon_test.js index 68afc22a78..07c8ae1e65 100644 --- a/jscomp/test/epsilon_test.js +++ b/jscomp/test/epsilon_test.js @@ -2,7 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); -let PervasivesU = require("../../lib/js/pervasivesU.js"); +let Pervasives = require("../../lib/js/pervasives.js"); let v = (Number.EPSILON?Number.EPSILON:2.220446049250313e-16); @@ -11,7 +11,7 @@ let suites_0 = [ (function (param) { return { TAG: "Eq", - _0: PervasivesU.epsilon_float, + _0: Pervasives.epsilon_float, _1: v }; }) diff --git a/jscomp/test/ext_filename_test.js b/jscomp/test/ext_filename_test.js index 938ec7cb92..af53b2859e 100644 --- a/jscomp/test/ext_filename_test.js +++ b/jscomp/test/ext_filename_test.js @@ -7,7 +7,7 @@ let List = require("../../lib/js/list.js"); let $$String = require("../../lib/js/string.js"); let Caml_sys = require("../../lib/js/caml_sys.js"); let Filename = require("../../lib/js/filename.js"); -let PervasivesU = require("../../lib/js/pervasivesU.js"); +let Pervasives = require("../../lib/js/pervasives.js"); let Test_literals = require("./test_literals.js"); let Ext_string_test = require("./ext_string_test.js"); let CamlinternalLazy = require("../../lib/js/camlinternalLazy.js"); @@ -107,7 +107,7 @@ function relative_path(file_or_dir_1, file_or_dir_2) { _dir1 = dir1.tl; continue; } - return PervasivesU.$at(List.map((function (param) { + return Pervasives.$at(List.map((function (param) { return node_parent; }), dir2), dir1); }; diff --git a/jscomp/test/float_of_bits_test.js b/jscomp/test/float_of_bits_test.js index 54526635e3..7b6747eae2 100644 --- a/jscomp/test/float_of_bits_test.js +++ b/jscomp/test/float_of_bits_test.js @@ -6,7 +6,7 @@ let List = require("../../lib/js/list.js"); let $$Array = require("../../lib/js/array.js"); let Caml_float = require("../../lib/js/caml_float.js"); let Caml_int64 = require("../../lib/js/caml_int64.js"); -let PervasivesU = require("../../lib/js/pervasivesU.js"); +let Pervasives = require("../../lib/js/pervasives.js"); let one_float = [ 1072693248, @@ -56,7 +56,7 @@ function from_pairs(pair) { }), int32_pairs))); } -let suites = PervasivesU.$at({ +let suites = Pervasives.$at({ hd: [ "one", (function () { diff --git a/jscomp/test/float_test.js b/jscomp/test/float_test.js index 12af2a87ad..9968b2483c 100644 --- a/jscomp/test/float_test.js +++ b/jscomp/test/float_test.js @@ -8,7 +8,7 @@ let Caml_obj = require("../../lib/js/caml_obj.js"); let Mt_global = require("./mt_global.js"); let Caml_float = require("../../lib/js/caml_float.js"); let Caml_int64 = require("../../lib/js/caml_int64.js"); -let PervasivesU = require("../../lib/js/pervasivesU.js"); +let Pervasives = require("../../lib/js/pervasives.js"); let test_id = { contents: 0 @@ -174,7 +174,7 @@ function float_greaterequal(x, y) { let generic_greaterequal = Caml_obj.greaterequal; -eq("File \"float_test.res\", line 59, characters 5-12", PervasivesU.classify_float(3), "FP_normal"); +eq("File \"float_test.res\", line 59, characters 5-12", Pervasives.classify_float(3), "FP_normal"); eq("File \"float_test.res\", line 60, characters 5-12", Caml_float.modf_float(-3.125), [ -0.125, @@ -236,13 +236,13 @@ eq("File \"float_test.res\", line 89, characters 5-12", Caml.float_compare(NaN, eq("File \"float_test.res\", line 90, characters 5-12", Caml_obj.compare(NaN, NaN), 0); -eq("File \"float_test.res\", line 91, characters 5-12", Caml.float_compare(NaN, PervasivesU.neg_infinity), -1); +eq("File \"float_test.res\", line 91, characters 5-12", Caml.float_compare(NaN, Pervasives.neg_infinity), -1); -eq("File \"float_test.res\", line 92, characters 5-12", Caml_obj.compare(NaN, PervasivesU.neg_infinity), -1); +eq("File \"float_test.res\", line 92, characters 5-12", Caml_obj.compare(NaN, Pervasives.neg_infinity), -1); -eq("File \"float_test.res\", line 93, characters 5-12", Caml.float_compare(PervasivesU.neg_infinity, NaN), 1); +eq("File \"float_test.res\", line 93, characters 5-12", Caml.float_compare(Pervasives.neg_infinity, NaN), 1); -eq("File \"float_test.res\", line 94, characters 5-12", Caml_obj.compare(PervasivesU.neg_infinity, NaN), 1); +eq("File \"float_test.res\", line 94, characters 5-12", Caml_obj.compare(Pervasives.neg_infinity, NaN), 1); eq("File \"float_test.res\", line 95, characters 5-12", NaN === NaN, false); @@ -322,7 +322,7 @@ let b = match$4[1]; let a = match$4[0]; -let extra = PervasivesU.$at({ +let extra = Pervasives.$at({ hd: [ "mod_float", (function () { @@ -370,7 +370,7 @@ let extra = PervasivesU.$at({ } } } -}, PervasivesU.$at(from_pairs(results), suites.contents)); +}, Pervasives.$at(from_pairs(results), suites.contents)); Mt.from_pair_suites("Float_test", extra); diff --git a/jscomp/test/format_test.js b/jscomp/test/format_test.js index 379177e27d..9c7de3c192 100644 --- a/jscomp/test/format_test.js +++ b/jscomp/test/format_test.js @@ -4,8 +4,8 @@ let Mt = require("./mt.js"); let List = require("../../lib/js/list.js"); let $$String = require("../../lib/js/string.js"); +let Pervasives = require("../../lib/js/pervasives.js"); let Caml_format = require("../../lib/js/caml_format.js"); -let PervasivesU = require("../../lib/js/pervasivesU.js"); let suites = { contents: /* [] */0 @@ -44,27 +44,27 @@ eq("File \"format_test.res\", line 23, characters 5-12", 7.875, 7.875); eq("File \"format_test.res\", line 25, characters 5-12", -7.875, -7.875); -eq3("File \"format_test.res\", line 29, characters 6-13", Infinity, Number.POSITIVE_INFINITY, PervasivesU.infinity); +eq3("File \"format_test.res\", line 29, characters 6-13", Infinity, Number.POSITIVE_INFINITY, Pervasives.infinity); -eq3("File \"format_test.res\", line 30, characters 6-13", -Infinity, Number.NEGATIVE_INFINITY, PervasivesU.neg_infinity); +eq3("File \"format_test.res\", line 30, characters 6-13", -Infinity, Number.NEGATIVE_INFINITY, Pervasives.neg_infinity); -eq3("File \"format_test.res\", line 31, characters 6-13", PervasivesU.max_float, 1.79769313486231571e+308, Number.MAX_VALUE); +eq3("File \"format_test.res\", line 31, characters 6-13", Pervasives.max_float, 1.79769313486231571e+308, Number.MAX_VALUE); -eq("File \"format_test.res\", line 32, characters 5-12", PervasivesU.classify_float(Infinity), "FP_infinite"); +eq("File \"format_test.res\", line 32, characters 5-12", Pervasives.classify_float(Infinity), "FP_infinite"); -eq("File \"format_test.res\", line 33, characters 5-12", PervasivesU.classify_float(Infinity), "FP_infinite"); +eq("File \"format_test.res\", line 33, characters 5-12", Pervasives.classify_float(Infinity), "FP_infinite"); -eq("File \"format_test.res\", line 35, characters 5-12", PervasivesU.min_float, 2.22507385850720138e-308); +eq("File \"format_test.res\", line 35, characters 5-12", Pervasives.min_float, 2.22507385850720138e-308); -eq("File \"format_test.res\", line 36, characters 5-12", PervasivesU.epsilon_float, 2.22044604925031308e-16); +eq("File \"format_test.res\", line 36, characters 5-12", Pervasives.epsilon_float, 2.22044604925031308e-16); eq("File \"format_test.res\", line 37, characters 5-12", 4.94065645841e-324, 5e-324); -eq("File \"format_test.res\", line 38, characters 5-12", 1.00000000000000022 - 1, PervasivesU.epsilon_float); +eq("File \"format_test.res\", line 38, characters 5-12", 1.00000000000000022 - 1, Pervasives.epsilon_float); eq("File \"format_test.res\", line 39, characters 5-12", 1.11253692925360069e-308 / 2.22507385850720138e-308, 0.5); -eq("File \"format_test.res\", line 40, characters 5-12", PervasivesU.classify_float(1.11253692925360069e-308), "FP_subnormal"); +eq("File \"format_test.res\", line 40, characters 5-12", Pervasives.classify_float(1.11253692925360069e-308), "FP_subnormal"); eq("File \"format_test.res\", line 41, characters 5-12", 1.11253692925360069e-308, 1.11253692925360069e-308); @@ -124,7 +124,7 @@ let literals_1 = { ], tl: { hd: [ - PervasivesU.infinity, + Pervasives.infinity, "infinity" ], tl: { diff --git a/jscomp/test/int32_test.js b/jscomp/test/int32_test.js index fb85a5f735..a2d0f1710f 100644 --- a/jscomp/test/int32_test.js +++ b/jscomp/test/int32_test.js @@ -5,7 +5,7 @@ let Mt = require("./mt.js"); let $$Array = require("../../lib/js/array.js"); let Int32 = require("../../lib/js/int32.js"); let Caml_float = require("../../lib/js/caml_float.js"); -let PervasivesU = require("../../lib/js/pervasivesU.js"); +let Pervasives = require("../../lib/js/pervasives.js"); let Ext_array_test = require("./ext_array_test.js"); function f(x) { @@ -153,7 +153,7 @@ function $star$tilde(prim0, prim1) { } let suites = { - contents: PervasivesU.$at({ + contents: Pervasives.$at({ hd: [ "File \"int32_test.res\", line 131, characters 9-16", (function () { @@ -177,7 +177,7 @@ let suites = { ], tl: /* [] */0 } - }, PervasivesU.$at($$Array.to_list(Ext_array_test.map2i((function (i, a, b) { + }, Pervasives.$at($$Array.to_list(Ext_array_test.map2i((function (i, a, b) { return [ "shift_right_logical_cases " + i, (function () { @@ -188,7 +188,7 @@ let suites = { }; }) ]; - }), shift_right_logical_tests_0, shift_right_logical_tests_1)), PervasivesU.$at($$Array.to_list(Ext_array_test.map2i((function (i, a, b) { + }), shift_right_logical_tests_0, shift_right_logical_tests_1)), Pervasives.$at($$Array.to_list(Ext_array_test.map2i((function (i, a, b) { return [ "shift_right_cases " + i, (function () { diff --git a/jscomp/test/int64_mul_div_test.js b/jscomp/test/int64_mul_div_test.js index 12b57ac72b..6935d118e7 100644 --- a/jscomp/test/int64_mul_div_test.js +++ b/jscomp/test/int64_mul_div_test.js @@ -6,7 +6,7 @@ let List = require("../../lib/js/list.js"); let $$Array = require("../../lib/js/array.js"); let Int64 = require("../../lib/js/int64.js"); let Caml_int64 = require("../../lib/js/caml_int64.js"); -let PervasivesU = require("../../lib/js/pervasivesU.js"); +let Pervasives = require("../../lib/js/pervasives.js"); function commutative_mul(result, a, b) { return { @@ -1600,7 +1600,7 @@ function from_to_string(xs) { }), $$Array.to_list(xs)); } -let extra = PervasivesU.$at(from_pairs("random", pairs), PervasivesU.$at(from_pairs("small", small_pairs), PervasivesU.$at(List.mapi((function (i, param) { +let extra = Pervasives.$at(from_pairs("random", pairs), Pervasives.$at(from_pairs("small", small_pairs), Pervasives.$at(List.mapi((function (i, param) { let f = param[1]; let i64 = param[0]; return [ @@ -1613,7 +1613,7 @@ let extra = PervasivesU.$at(from_pairs("random", pairs), PervasivesU.$at(from_pa }; }) ]; -}), $$Array.to_list(to_floats)), PervasivesU.$at(List.mapi((function (i, param) { +}), $$Array.to_list(to_floats)), Pervasives.$at(List.mapi((function (i, param) { let i64 = param[1]; let f = param[0]; return [ @@ -1626,7 +1626,7 @@ let extra = PervasivesU.$at(from_pairs("random", pairs), PervasivesU.$at(from_pa }; }) ]; -}), $$Array.to_list(of_float_pairs)), PervasivesU.$at({ +}), $$Array.to_list(of_float_pairs)), Pervasives.$at({ hd: [ "compare_check_complete", (function () { @@ -1640,7 +1640,7 @@ let extra = PervasivesU.$at(from_pairs("random", pairs), PervasivesU.$at(from_pa }) ], tl: /* [] */0 -}, PervasivesU.$at(from(simple_divs), PervasivesU.$at(from_compare(int64_compare_tests), { +}, Pervasives.$at(from(simple_divs), Pervasives.$at(from_compare(int64_compare_tests), { hd: [ "div_rem_0", (function () { diff --git a/jscomp/test/int64_test.js b/jscomp/test/int64_test.js index 3807d3d7a9..9106dc41ab 100644 --- a/jscomp/test/int64_test.js +++ b/jscomp/test/int64_test.js @@ -7,7 +7,7 @@ let Int32 = require("../../lib/js/int32.js"); let Int64 = require("../../lib/js/int64.js"); let Caml_obj = require("../../lib/js/caml_obj.js"); let Caml_int64 = require("../../lib/js/caml_int64.js"); -let PervasivesU = require("../../lib/js/pervasivesU.js"); +let Pervasives = require("../../lib/js/pervasives.js"); let Ext_array_test = require("./ext_array_test.js"); let v = Caml_int64.add(Caml_int64.of_int32(Int32.max_int), Int64.one); @@ -849,7 +849,7 @@ function fac(_n, _acc) { }; } -let suites = PervasivesU.$at({ +let suites = Pervasives.$at({ hd: [ "add_one", (function () { @@ -2098,7 +2098,7 @@ let suites = PervasivesU.$at({ } } } -}, PervasivesU.$at($$Array.to_list(Ext_array_test.map2i((function (i, a, b) { +}, Pervasives.$at($$Array.to_list(Ext_array_test.map2i((function (i, a, b) { return [ "shift_left_cases " + i, (function () { @@ -2109,7 +2109,7 @@ let suites = PervasivesU.$at({ }; }) ]; -}), shift_left_tests_0, shift_left_tests_1)), PervasivesU.$at($$Array.to_list(Ext_array_test.map2i((function (i, a, b) { +}), shift_left_tests_0, shift_left_tests_1)), Pervasives.$at($$Array.to_list(Ext_array_test.map2i((function (i, a, b) { return [ "shift_right_cases " + i, (function () { @@ -2147,7 +2147,7 @@ function eq(loc, x, y) { function id(loc, x) { let float_value = Caml_int64.float_of_bits(x); - let match = PervasivesU.classify_float(float_value); + let match = Pervasives.classify_float(float_value); if (match === "FP_nan") { return; } else { diff --git a/jscomp/test/js_float_test.js b/jscomp/test/js_float_test.js index 2e441470dd..28a31f0f7a 100644 --- a/jscomp/test/js_float_test.js +++ b/jscomp/test/js_float_test.js @@ -2,7 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); -let PervasivesU = require("../../lib/js/pervasivesU.js"); +let Pervasives = require("../../lib/js/pervasives.js"); let suites_0 = [ "_NaN <> _NaN", @@ -44,7 +44,7 @@ let suites_1 = { return { TAG: "Eq", _0: false, - _1: Number.isFinite(PervasivesU.infinity) + _1: Number.isFinite(Pervasives.infinity) }; }) ], @@ -55,7 +55,7 @@ let suites_1 = { return { TAG: "Eq", _0: false, - _1: Number.isFinite(PervasivesU.neg_infinity) + _1: Number.isFinite(Pervasives.neg_infinity) }; }) ], diff --git a/jscomp/test/limits_test.js b/jscomp/test/limits_test.js index fd3a43448c..bdf6c1e70d 100644 --- a/jscomp/test/limits_test.js +++ b/jscomp/test/limits_test.js @@ -3,7 +3,7 @@ let Mt = require("./mt.js"); let Int32 = require("../../lib/js/int32.js"); -let PervasivesU = require("../../lib/js/pervasivesU.js"); +let Pervasives = require("../../lib/js/pervasives.js"); let suites = { contents: /* [] */0 @@ -30,9 +30,9 @@ function eq(loc, x, y) { }; } -eq("File \"limits_test.res\", line 10, characters 5-12", PervasivesU.max_int, 2147483647); +eq("File \"limits_test.res\", line 10, characters 5-12", Pervasives.max_int, 2147483647); -eq("File \"limits_test.res\", line 11, characters 5-12", PervasivesU.min_int, -2147483648); +eq("File \"limits_test.res\", line 11, characters 5-12", Pervasives.min_int, -2147483648); eq("File \"limits_test.res\", line 12, characters 5-12", Int32.max_int, 2147483647); diff --git a/jscomp/test/mario_game.js b/jscomp/test/mario_game.js index ba143f5ca6..e9159f4930 100644 --- a/jscomp/test/mario_game.js +++ b/jscomp/test/mario_game.js @@ -6,8 +6,8 @@ let List = require("../../lib/js/list.js"); let Random = require("../../lib/js/random.js"); let Caml_obj = require("../../lib/js/caml_obj.js"); let Caml_int32 = require("../../lib/js/caml_int32.js"); +let Pervasives = require("../../lib/js/pervasives.js"); let Caml_option = require("../../lib/js/caml_option.js"); -let PervasivesU = require("../../lib/js/pervasivesU.js"); let Actors = {}; @@ -789,7 +789,7 @@ let Particle = { }; let id_counter = { - contents: PervasivesU.min_int + contents: Pervasives.min_int }; function setup_obj(has_gravityOpt, speedOpt, param) { @@ -1346,7 +1346,7 @@ function kill(collid, ctx) { hd: make$1(undefined, undefined, "GoombaSquish", pos, ctx), tl: /* [] */0 }) : /* [] */0; - return PervasivesU.$at(score, remains); + return Pervasives.$at(score, remains); case "Item" : let o$1 = collid._2; if (collid._0 === "Mushroom") { @@ -2261,7 +2261,7 @@ function run_update_collid(state, collid, all_collids) { player = collid; } let evolved = update_collidable(state, player, all_collids); - collid_objs.contents = PervasivesU.$at(collid_objs.contents, evolved); + collid_objs.contents = Pervasives.$at(collid_objs.contents, evolved); return player; } let obj = collid._2; @@ -2269,11 +2269,11 @@ function run_update_collid(state, collid, all_collids) { if (!obj.kill) { collid_objs.contents = { hd: collid, - tl: PervasivesU.$at(collid_objs.contents, evolved$1) + tl: Pervasives.$at(collid_objs.contents, evolved$1) }; } let new_parts = obj.kill ? kill(collid, state.ctx) : /* [] */0; - particles.contents = PervasivesU.$at(particles.contents, new_parts); + particles.contents = Pervasives.$at(particles.contents, new_parts); return collid; } @@ -2473,7 +2473,7 @@ function convert_list(lst) { return /* [] */0; } let h = lst.hd; - return PervasivesU.$at({ + return Pervasives.$at({ hd: [ h[0], [ @@ -2537,7 +2537,7 @@ function avoid_overlap(_lst, currentLst) { let t = lst.tl; let h = lst.hd; if (!mem_loc(h[1], currentLst)) { - return PervasivesU.$at({ + return Pervasives.$at({ hd: h, tl: /* [] */0 }, avoid_overlap(t, currentLst)); @@ -2560,7 +2560,7 @@ function trim_edges(_lst, blockw, blockh) { let pixx = blockw * 16; let pixy = blockh * 16; if (!(cx < 128 || pixx - cx < 528 || cy === 0 || pixy - cy < 48)) { - return PervasivesU.$at({ + return Pervasives.$at({ hd: h, tl: /* [] */0 }, trim_edges(t, blockw, blockh)); @@ -2574,7 +2574,7 @@ function generate_clouds(cbx, cby, typ, num) { if (num === 0) { return /* [] */0; } else { - return PervasivesU.$at({ + return Pervasives.$at({ hd: [ typ, [ @@ -2599,7 +2599,7 @@ function generate_coins(_block_coord) { if (place_coin === 0) { let xc = h[1][0]; let yc = h[1][1]; - return PervasivesU.$at({ + return Pervasives.$at({ hd: [ 0, [ @@ -2796,7 +2796,7 @@ function choose_block_pattern(blockw, blockh, cbx, cby, prob) { hd: one_0, tl: /* [] */0 }; - return PervasivesU.$at(four, PervasivesU.$at(three, PervasivesU.$at(two, one))); + return Pervasives.$at(four, Pervasives.$at(three, Pervasives.$at(two, one))); } else { return /* [] */0; } @@ -2874,7 +2874,7 @@ function choose_block_pattern(blockw, blockh, cbx, cby, prob) { hd: one_0$1, tl: one_1 }; - return PervasivesU.$at(three$1, PervasivesU.$at(two$1, one$1)); + return Pervasives.$at(three$1, Pervasives.$at(two$1, one$1)); } else if (blockh - cby > 2) { let one_0$2 = [ stair_typ, @@ -2948,7 +2948,7 @@ function choose_block_pattern(blockw, blockh, cbx, cby, prob) { hd: three_0$2, tl: three_1$2 }; - return PervasivesU.$at(one$2, PervasivesU.$at(two$2, three$2)); + return Pervasives.$at(one$2, Pervasives.$at(two$2, three$2)); } else { return { hd: [ @@ -3076,7 +3076,7 @@ function generate_enemies(blockw, blockh, _cbx, _cby, acc) { hd: enemy_0, tl: /* [] */0 }; - return PervasivesU.$at(enemy, generate_enemies(blockw, blockh, cbx, cby + 1, acc)); + return Pervasives.$at(enemy, generate_enemies(blockw, blockh, cbx, cby + 1, acc)); } _cby = cby + 1; continue; @@ -3096,7 +3096,7 @@ function generate_block_enemies(_block_coord) { if (place_enemy === 0) { let xc = h[1][0]; let yc = h[1][1]; - return PervasivesU.$at({ + return Pervasives.$at({ hd: [ enemy_typ, [ @@ -3136,7 +3136,7 @@ function generate_block_locs(blockw, blockh, _cbx, _cby, _acc) { if (prob < 5) { let newacc = choose_block_pattern(blockw, blockh, cbx, cby, prob); let undup_lst = avoid_overlap(newacc, acc); - let called_acc = PervasivesU.$at(acc, undup_lst); + let called_acc = Pervasives.$at(acc, undup_lst); _acc = called_acc; _cby = cby + 1; continue; @@ -3165,7 +3165,7 @@ function generate_ground(blockw, blockh, _inc, _acc) { } if (inc > 10) { let skip = Random.int(10); - let newacc = PervasivesU.$at(acc, { + let newacc = Pervasives.$at(acc, { hd: [ 4, [ @@ -3183,7 +3183,7 @@ function generate_ground(blockw, blockh, _inc, _acc) { _inc = inc + 1; continue; } - let newacc$1 = PervasivesU.$at(acc, { + let newacc$1 = Pervasives.$at(acc, { hd: [ 4, [ @@ -3209,7 +3209,7 @@ function convert_to_block_obj(lst, context) { TAG: "SBlock", _0: sblock_typ }, context, h[1]); - return PervasivesU.$at({ + return Pervasives.$at({ hd: ob, tl: /* [] */0 }, convert_to_block_obj(lst.tl, context)); @@ -3225,7 +3225,7 @@ function convert_to_enemy_obj(lst, context) { TAG: "SEnemy", _0: senemy_typ }, context, h[1]); - return PervasivesU.$at({ + return Pervasives.$at({ hd: ob, tl: /* [] */0 }, convert_to_enemy_obj(lst.tl, context)); @@ -3239,7 +3239,7 @@ function convert_to_coin_obj(lst, context) { TAG: "SItem", _0: "Coin" }, context, lst.hd[1]); - return PervasivesU.$at({ + return Pervasives.$at({ hd: ob, tl: /* [] */0 }, convert_to_coin_obj(lst.tl, context)); @@ -3251,19 +3251,19 @@ function generate_helper(blockw, blockh, cx, cy, context) { let obj_converted_block_locs = convert_to_block_obj(converted_block_locs, context); let ground_blocks = generate_ground(blockw, blockh, 0, /* [] */0); let obj_converted_ground_blocks = convert_to_block_obj(ground_blocks, context); - let block_locations = PervasivesU.$at(block_locs, ground_blocks); - let all_blocks = PervasivesU.$at(obj_converted_block_locs, obj_converted_ground_blocks); + let block_locations = Pervasives.$at(block_locs, ground_blocks); + let all_blocks = Pervasives.$at(obj_converted_block_locs, obj_converted_ground_blocks); let enemy_locs = generate_enemies(blockw, blockh, 0, 0, block_locations); let obj_converted_enemies = convert_to_enemy_obj(enemy_locs, context); let coin_locs = generate_coins(converted_block_locs); let undup_coin_locs = trim_edges(avoid_overlap(coin_locs, converted_block_locs), blockw, blockh); - let converted_block_coin_locs = PervasivesU.$at(converted_block_locs, coin_locs); + let converted_block_coin_locs = Pervasives.$at(converted_block_locs, coin_locs); let enemy_block_locs = generate_block_enemies(converted_block_locs); let undup_enemy_block_locs = avoid_overlap(enemy_block_locs, converted_block_coin_locs); let obj_enemy_blocks = convert_to_enemy_obj(undup_enemy_block_locs, context); let coin_objects = convert_to_coin_obj(undup_coin_locs, context); let obj_panel = generate_panel(context, blockw, blockh); - return PervasivesU.$at(all_blocks, PervasivesU.$at(obj_converted_enemies, PervasivesU.$at(coin_objects, PervasivesU.$at(obj_enemy_blocks, { + return Pervasives.$at(all_blocks, Pervasives.$at(obj_converted_enemies, Pervasives.$at(coin_objects, Pervasives.$at(obj_enemy_blocks, { hd: obj_panel, tl: /* [] */0 })))); diff --git a/jscomp/test/ocaml_re_test.js b/jscomp/test/ocaml_re_test.js index 6cedd81b44..bb5c1c7235 100644 --- a/jscomp/test/ocaml_re_test.js +++ b/jscomp/test/ocaml_re_test.js @@ -12,9 +12,9 @@ let Hashtbl = require("../../lib/js/hashtbl.js"); let Caml_obj = require("../../lib/js/caml_obj.js"); let Caml_array = require("../../lib/js/caml_array.js"); let Caml_bytes = require("../../lib/js/caml_bytes.js"); +let Pervasives = require("../../lib/js/pervasives.js"); let Caml_option = require("../../lib/js/caml_option.js"); let Caml_string = require("../../lib/js/caml_string.js"); -let PervasivesU = require("../../lib/js/pervasivesU.js"); let Caml_exceptions = require("../../lib/js/caml_exceptions.js"); let Caml_js_exceptions = require("../../lib/js/caml_js_exceptions.js"); @@ -2305,7 +2305,7 @@ function merge_sequences(_x) { } break; case "Alternative" : - _x = PervasivesU.$at(l$p._0, x.tl); + _x = Pervasives.$at(l$p._0, x.tl); continue; default: @@ -3239,18 +3239,18 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { for(let j = 0; j < len; ++j){ try { if (Caml_string.get(s$p, j) !== Caml_string.get(s, i.contents + j | 0)) { - throw new Error(PervasivesU.Exit, { + throw new Error(Pervasives.Exit, { cause: { - RE_EXN_ID: PervasivesU.Exit + RE_EXN_ID: Pervasives.Exit } }); } } catch (exn){ - throw new Error(PervasivesU.Exit, { + throw new Error(Pervasives.Exit, { cause: { - RE_EXN_ID: PervasivesU.Exit + RE_EXN_ID: Pervasives.Exit } }); } @@ -3260,7 +3260,7 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { } catch (raw_exn){ let exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn$1.RE_EXN_ID === PervasivesU.Exit) { + if (exn$1.RE_EXN_ID === Pervasives.Exit) { return false; } throw new Error(exn$1.RE_EXN_ID, { diff --git a/jscomp/test/of_string_test.js b/jscomp/test/of_string_test.js index 3e1775ed0d..fffd6400b2 100644 --- a/jscomp/test/of_string_test.js +++ b/jscomp/test/of_string_test.js @@ -2,7 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); -let PervasivesU = require("../../lib/js/pervasivesU.js"); +let Pervasives = require("../../lib/js/pervasives.js"); let suites_0 = [ "string_of_float_1", @@ -10,7 +10,7 @@ let suites_0 = [ return { TAG: "Eq", _0: "10.", - _1: PervasivesU.string_of_float(10) + _1: Pervasives.string_of_float(10) }; }) ]; @@ -33,7 +33,7 @@ let suites_1 = { return { TAG: "Eq", _0: "10.", - _1: PervasivesU.valid_float_lexem("10") + _1: Pervasives.valid_float_lexem("10") }; }) ], diff --git a/jscomp/test/set_gen.js b/jscomp/test/set_gen.js index bdf878e07d..4c211f46ae 100644 --- a/jscomp/test/set_gen.js +++ b/jscomp/test/set_gen.js @@ -2,7 +2,7 @@ 'use strict'; let List = require("../../lib/js/list.js"); -let PervasivesU = require("../../lib/js/pervasivesU.js"); +let Pervasives = require("../../lib/js/pervasives.js"); let Caml_exceptions = require("../../lib/js/caml_exceptions.js"); function cons_enum(_s, _e) { @@ -214,7 +214,7 @@ function check_height_and_diff(x) { } }); } - let diff = PervasivesU.abs(hl - hr | 0); + let diff = Pervasives.abs(hl - hr | 0); if (diff > 2) { throw new Error(Height_diff_borken, { cause: { diff --git a/jscomp/test/sexp.js b/jscomp/test/sexp.js index 2969de47ea..cc631d3a3a 100644 --- a/jscomp/test/sexp.js +++ b/jscomp/test/sexp.js @@ -4,9 +4,9 @@ let List = require("../../lib/js/list.js"); let Hashtbl = require("../../lib/js/hashtbl.js"); let Caml_obj = require("../../lib/js/caml_obj.js"); +let Pervasives = require("../../lib/js/pervasives.js"); let Caml_format = require("../../lib/js/caml_format.js"); let Caml_option = require("../../lib/js/caml_option.js"); -let PervasivesU = require("../../lib/js/pervasivesU.js"); let equal = Caml_obj.equal; @@ -26,7 +26,7 @@ function of_int(x) { function of_float(x) { return { NAME: "Atom", - VAL: PervasivesU.string_of_float(x) + VAL: Pervasives.string_of_float(x) }; } @@ -248,7 +248,7 @@ function to_int(e) { } function to_bool(e) { - return _try_atom(e, PervasivesU.bool_of_string); + return _try_atom(e, Pervasives.bool_of_string); } function to_float(e) { diff --git a/jscomp/test/sexpm.js b/jscomp/test/sexpm.js index bce2d06177..44de13f8fd 100644 --- a/jscomp/test/sexpm.js +++ b/jscomp/test/sexpm.js @@ -9,7 +9,7 @@ let Bytes = require("../../lib/js/bytes.js"); let Buffer = require("../../lib/js/buffer.js"); let $$String = require("../../lib/js/string.js"); let Caml_bytes = require("../../lib/js/caml_bytes.js"); -let PervasivesU = require("../../lib/js/pervasivesU.js"); +let Pervasives = require("../../lib/js/pervasives.js"); let Caml_js_exceptions = require("../../lib/js/caml_js_exceptions.js"); function _must_escape(s) { @@ -22,16 +22,16 @@ function _must_escape(s) { if (c !== 92) { exit = 1; } else { - throw new Error(PervasivesU.Exit, { + throw new Error(Pervasives.Exit, { cause: { - RE_EXN_ID: PervasivesU.Exit + RE_EXN_ID: Pervasives.Exit } }); } } else { - throw new Error(PervasivesU.Exit, { + throw new Error(Pervasives.Exit, { cause: { - RE_EXN_ID: PervasivesU.Exit + RE_EXN_ID: Pervasives.Exit } }); } @@ -50,9 +50,9 @@ function _must_escape(s) { case 34 : case 40 : case 41 : - throw new Error(PervasivesU.Exit, { + throw new Error(Pervasives.Exit, { cause: { - RE_EXN_ID: PervasivesU.Exit + RE_EXN_ID: Pervasives.Exit } }); @@ -62,18 +62,18 @@ function _must_escape(s) { } } else { if (c >= 9) { - throw new Error(PervasivesU.Exit, { + throw new Error(Pervasives.Exit, { cause: { - RE_EXN_ID: PervasivesU.Exit + RE_EXN_ID: Pervasives.Exit } }); } exit = 1; } if (exit === 1 && c > 127) { - throw new Error(PervasivesU.Exit, { + throw new Error(Pervasives.Exit, { cause: { - RE_EXN_ID: PervasivesU.Exit + RE_EXN_ID: Pervasives.Exit } }); } @@ -83,7 +83,7 @@ function _must_escape(s) { } catch (raw_exn){ let exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === PervasivesU.Exit) { + if (exn.RE_EXN_ID === Pervasives.Exit) { return true; } throw new Error(exn.RE_EXN_ID, { diff --git a/jscomp/test/test_list.js b/jscomp/test/test_list.js index c92b992af0..36532409f3 100644 --- a/jscomp/test/test_list.js +++ b/jscomp/test/test_list.js @@ -3,7 +3,7 @@ let List = require("../../lib/js/list.js"); let Caml_obj = require("../../lib/js/caml_obj.js"); -let PervasivesU = require("../../lib/js/pervasivesU.js"); +let Pervasives = require("../../lib/js/pervasives.js"); function length_aux(_len, _x) { while(true) { @@ -99,7 +99,7 @@ function rev(l) { function flatten(x) { if (x) { - return PervasivesU.$at(x.hd, flatten(x.tl)); + return Pervasives.$at(x.hd, flatten(x.tl)); } else { return /* [] */0; } @@ -1513,7 +1513,7 @@ function sort_uniq(cmp, l) { let u = List.length; -let append = PervasivesU.$at; +let append = Pervasives.$at; let concat = flatten; diff --git a/jscomp/test/test_seq.js b/jscomp/test/test_seq.js index 81e28520d9..fe6bb57c1a 100644 --- a/jscomp/test/test_seq.js +++ b/jscomp/test/test_seq.js @@ -2,7 +2,7 @@ 'use strict'; let Caml_obj = require("../../lib/js/caml_obj.js"); -let PervasivesU = require("../../lib/js/pervasivesU.js"); +let Pervasives = require("../../lib/js/pervasives.js"); let Caml_exceptions = require("../../lib/js/caml_exceptions.js"); let Caml_js_exceptions = require("../../lib/js/caml_js_exceptions.js"); @@ -103,7 +103,7 @@ function add_help(speclist) { }); } } - return PervasivesU.$at(speclist, PervasivesU.$at(add1, add2)); + return Pervasives.$at(speclist, Pervasives.$at(add1, add2)); } exports.Bad = Bad; diff --git a/jscomp/test/ticker.js b/jscomp/test/ticker.js index 51a6827b93..80e119537a 100644 --- a/jscomp/test/ticker.js +++ b/jscomp/test/ticker.js @@ -5,9 +5,9 @@ let Caml = require("../../lib/js/caml.js"); let List = require("../../lib/js/list.js"); let $$String = require("../../lib/js/string.js"); let Caml_obj = require("../../lib/js/caml_obj.js"); +let Pervasives = require("../../lib/js/pervasives.js"); let Caml_format = require("../../lib/js/caml_format.js"); let Caml_option = require("../../lib/js/caml_option.js"); -let PervasivesU = require("../../lib/js/pervasivesU.js"); let Caml_js_exceptions = require("../../lib/js/caml_js_exceptions.js"); function split(delim, s) { @@ -57,7 +57,7 @@ function split(delim, s) { function string_of_float_option(x) { if (x !== undefined) { - return PervasivesU.string_of_float(x); + return Pervasives.string_of_float(x); } else { return "nan"; } @@ -1139,7 +1139,7 @@ function compute_update_sequences(all_tickers) { let ticker_name = ticker.ticker_name; if (typeof type_ !== "object") { let l = find(ticker_name, map); - return add(ticker_name, PervasivesU.$at(up, l), map); + return add(ticker_name, Pervasives.$at(up, l), map); } let match = type_._0; let map$1 = loop({ diff --git a/jscomp/test/to_string_test.js b/jscomp/test/to_string_test.js index 6c388c6ff2..58bf0132ca 100644 --- a/jscomp/test/to_string_test.js +++ b/jscomp/test/to_string_test.js @@ -2,10 +2,10 @@ 'use strict'; let Mt = require("./mt.js"); -let PervasivesU = require("../../lib/js/pervasivesU.js"); +let Pervasives = require("../../lib/js/pervasives.js"); function ff(v) { - return PervasivesU.string_of_float(v); + return Pervasives.string_of_float(v); } function f(v) { @@ -18,7 +18,7 @@ Mt.from_pair_suites("To_string_test", { (function () { return { TAG: "Eq", - _0: PervasivesU.string_of_float(PervasivesU.infinity), + _0: Pervasives.string_of_float(Pervasives.infinity), _1: "inf" }; }) @@ -29,7 +29,7 @@ Mt.from_pair_suites("To_string_test", { (function () { return { TAG: "Eq", - _0: PervasivesU.string_of_float(PervasivesU.neg_infinity), + _0: Pervasives.string_of_float(Pervasives.neg_infinity), _1: "-inf" }; }) diff --git a/jscomp/test/topsort_test.js b/jscomp/test/topsort_test.js index edfcd11ba6..8f6ce9ba4a 100644 --- a/jscomp/test/topsort_test.js +++ b/jscomp/test/topsort_test.js @@ -5,8 +5,8 @@ let Caml = require("../../lib/js/caml.js"); let List = require("../../lib/js/list.js"); let $$String = require("../../lib/js/string.js"); let Caml_obj = require("../../lib/js/caml_obj.js"); +let Pervasives = require("../../lib/js/pervasives.js"); let Caml_option = require("../../lib/js/caml_option.js"); -let PervasivesU = require("../../lib/js/pervasivesU.js"); let Caml_exceptions = require("../../lib/js/caml_exceptions.js"); let Caml_js_exceptions = require("../../lib/js/caml_js_exceptions.js"); @@ -91,7 +91,7 @@ function dfs1(_nodes, graph, _visited) { hd: x, tl: visited }; - _nodes = PervasivesU.$at(nexts(x, graph), xs); + _nodes = Pervasives.$at(nexts(x, graph), xs); continue; }; } diff --git a/jscomp/test/unsafe_ppx_test.js b/jscomp/test/unsafe_ppx_test.js index f7bb84b9f4..f0e9d4a747 100644 --- a/jscomp/test/unsafe_ppx_test.js +++ b/jscomp/test/unsafe_ppx_test.js @@ -2,8 +2,8 @@ 'use strict'; let Mt = require("./mt.js"); +let Pervasives = require("../../lib/js/pervasives.js"); let Ffi_js_test = require("./ffi_js_test.js"); -let PervasivesU = require("../../lib/js/pervasivesU.js"); let x = "\\x01\\x02\\x03"; @@ -23,7 +23,7 @@ function g(a) { return "" }); let regression2 = Math.max; - regression(a, PervasivesU.failwith); + regression(a, Pervasives.failwith); regression2(3, 2); regression3(3, 2); regression4(3, (function (x) { diff --git a/lib/es6/arg.js b/lib/es6/arg.js index 81a83d525b..c65c77c67f 100644 --- a/lib/es6/arg.js +++ b/lib/es6/arg.js @@ -8,9 +8,9 @@ import * as Buffer from "./buffer.js"; import * as $$String from "./string.js"; import * as Caml_obj from "./caml_obj.js"; import * as Caml_array from "./caml_array.js"; +import * as Pervasives from "./pervasives.js"; import * as Caml_format from "./caml_format.js"; import * as Caml_string from "./caml_string.js"; -import * as PervasivesU from "./pervasivesU.js"; import * as Caml_exceptions from "./caml_exceptions.js"; import * as Caml_js_exceptions from "./caml_js_exceptions.js"; @@ -121,7 +121,7 @@ function add_help(speclist) { }); } } - return PervasivesU.$at(speclist, PervasivesU.$at(add1, add2)); + return Pervasives.$at(speclist, Pervasives.$at(add1, add2)); } function usage_b(buf, speclist, errmsg) { @@ -157,7 +157,7 @@ let current = { function bool_of_string_opt(x) { try { - return PervasivesU.bool_of_string(x); + return Pervasives.bool_of_string(x); } catch (raw_exn){ let exn = Caml_js_exceptions.internalToOCamlException(raw_exn); @@ -559,11 +559,11 @@ function parse(l, f, msg) { let msg$1 = Caml_js_exceptions.internalToOCamlException(raw_msg); if (msg$1.RE_EXN_ID === Bad) { console.log(msg$1._1); - return PervasivesU.exit(2); + return Pervasives.exit(2); } if (msg$1.RE_EXN_ID === Help) { console.log(msg$1._1); - return PervasivesU.exit(0); + return Pervasives.exit(0); } throw new Error(msg$1.RE_EXN_ID, { cause: msg$1 @@ -579,11 +579,11 @@ function parse_dynamic(l, f, msg) { let msg$1 = Caml_js_exceptions.internalToOCamlException(raw_msg); if (msg$1.RE_EXN_ID === Bad) { console.log(msg$1._1); - return PervasivesU.exit(2); + return Pervasives.exit(2); } if (msg$1.RE_EXN_ID === Help) { console.log(msg$1._1); - return PervasivesU.exit(0); + return Pervasives.exit(0); } throw new Error(msg$1.RE_EXN_ID, { cause: msg$1 @@ -608,11 +608,11 @@ function parse_expand(l, f, msg) { let msg$1 = Caml_js_exceptions.internalToOCamlException(raw_msg); if (msg$1.RE_EXN_ID === Bad) { console.log(msg$1._1); - return PervasivesU.exit(2); + return Pervasives.exit(2); } if (msg$1.RE_EXN_ID === Help) { console.log(msg$1._1); - return PervasivesU.exit(0); + return Pervasives.exit(0); } throw new Error(msg$1.RE_EXN_ID, { cause: msg$1 @@ -694,7 +694,7 @@ function replace_leading_tab(s) { } function align(limitOpt, speclist) { - let limit = limitOpt !== undefined ? limitOpt : PervasivesU.max_int; + let limit = limitOpt !== undefined ? limitOpt : Pervasives.max_int; let completed = add_help(speclist); let len = List.fold_left(max_arg_len, 0, completed); let len$1 = len < limit ? len : limit; diff --git a/lib/es6/hashtbl.js b/lib/es6/hashtbl.js index a409284a6d..ca21010481 100644 --- a/lib/es6/hashtbl.js +++ b/lib/es6/hashtbl.js @@ -7,8 +7,8 @@ import * as Random from "./random.js"; import * as Caml_obj from "./caml_obj.js"; import * as Caml_hash from "./caml_hash.js"; import * as Caml_array from "./caml_array.js"; +import * as Pervasives from "./pervasives.js"; import * as Caml_option from "./caml_option.js"; -import * as PervasivesU from "./pervasivesU.js"; import * as CamlinternalLazy from "./camlinternalLazy.js"; function hash(x) { @@ -79,11 +79,11 @@ function clear(h) { function reset(h) { let len = h.data.length; - if (len === PervasivesU.abs(h.initial_size)) { + if (len === Pervasives.abs(h.initial_size)) { return clear(h); } else { h.size = 0; - h.data = Caml_array.make(PervasivesU.abs(h.initial_size), "Empty"); + h.data = Caml_array.make(Pervasives.abs(h.initial_size), "Empty"); return; } } diff --git a/lib/es6/list.js b/lib/es6/list.js index 929512878e..75645dc081 100644 --- a/lib/es6/list.js +++ b/lib/es6/list.js @@ -1,8 +1,8 @@ import * as Caml_obj from "./caml_obj.js"; +import * as Pervasives from "./pervasives.js"; import * as Caml_option from "./caml_option.js"; -import * as PervasivesU from "./pervasivesU.js"; function length(l) { let _len = 0; @@ -172,7 +172,7 @@ function init(len, f) { function flatten(param) { if (param) { - return PervasivesU.$at(param.hd, flatten(param.tl)); + return Pervasives.$at(param.hd, flatten(param.tl)); } else { return /* [] */0; } @@ -1669,7 +1669,7 @@ function compare_length_with(_l, _n) { }; } -let append = PervasivesU.$at; +let append = Pervasives.$at; let concat = flatten; diff --git a/lib/es6/listLabels.js b/lib/es6/listLabels.js index 60c1eafb66..85bb33989a 100644 --- a/lib/es6/listLabels.js +++ b/lib/es6/listLabels.js @@ -1,8 +1,8 @@ import * as Caml_obj from "./caml_obj.js"; +import * as Pervasives from "./pervasives.js"; import * as Caml_option from "./caml_option.js"; -import * as PervasivesU from "./pervasivesU.js"; function length(l) { let _len = 0; @@ -172,7 +172,7 @@ function init(len, f) { function flatten(param) { if (param) { - return PervasivesU.$at(param.hd, flatten(param.tl)); + return Pervasives.$at(param.hd, flatten(param.tl)); } else { return /* [] */0; } @@ -1669,7 +1669,7 @@ function compare_length_with(_l, _n) { }; } -let append = PervasivesU.$at; +let append = Pervasives.$at; let concat = flatten; diff --git a/lib/es6/pervasivesU.js b/lib/es6/pervasivesU.js deleted file mode 100644 index fb53e9cbb0..0000000000 --- a/lib/es6/pervasivesU.js +++ /dev/null @@ -1,276 +0,0 @@ - - -import * as Caml_sys from "./caml_sys.js"; -import * as Caml_format from "./caml_format.js"; -import * as Caml_string from "./caml_string.js"; -import * as Caml_exceptions from "./caml_exceptions.js"; -import * as Caml_js_exceptions from "./caml_js_exceptions.js"; - -let JsxModules = { - Jsx: undefined, - JsxEvent: undefined, - JsxDOM: undefined -}; - -function failwith(s) { - throw new Error("Failure", { - cause: { - RE_EXN_ID: "Failure", - _1: s - } - }); -} - -function invalid_arg(s) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: s - } - }); -} - -let Exit = /* @__PURE__ */Caml_exceptions.create("PervasivesU.Exit"); - -function abs(x) { - if (x >= 0) { - return x; - } else { - return -x | 0; - } -} - -function lnot(x) { - return x ^ -1; -} - -let min_int = -2147483648; - -function classify_float(x) { - if (isFinite(x)) { - if (Math.abs(x) >= 2.22507385850720138e-308) { - return "FP_normal"; - } else if (x !== 0) { - return "FP_subnormal"; - } else { - return "FP_zero"; - } - } else if (isNaN(x)) { - return "FP_nan"; - } else { - return "FP_infinite"; - } -} - -function char_of_int(n) { - if (n < 0 || n > 255) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "char_of_int" - } - }); - } - return n; -} - -function string_of_bool(b) { - if (b) { - return "true"; - } else { - return "false"; - } -} - -function bool_of_string(param) { - switch (param) { - case "false" : - return false; - case "true" : - return true; - default: - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "bool_of_string" - } - }); - } -} - -function bool_of_string_opt(param) { - switch (param) { - case "false" : - return false; - case "true" : - return true; - default: - return; - } -} - -function int_of_string_opt(s) { - try { - return Caml_format.int_of_string(s); - } - catch (raw_exn){ - let exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === "Failure") { - return; - } - throw new Error(exn.RE_EXN_ID, { - cause: exn - }); - } -} - -function valid_float_lexem(s) { - let l = s.length; - let _i = 0; - while(true) { - let i = _i; - if (i >= l) { - return s + "."; - } - let match = Caml_string.get(s, i); - if (match >= 48) { - if (match >= 58) { - return s; - } - _i = i + 1 | 0; - continue; - } - if (match !== 45) { - return s; - } - _i = i + 1 | 0; - continue; - }; -} - -function string_of_float(f) { - return valid_float_lexem(Caml_format.format_float("%.12g", f)); -} - -function float_of_string_opt(s) { - try { - return Caml_format.float_of_string(s); - } - catch (raw_exn){ - let exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === "Failure") { - return; - } - throw new Error(exn.RE_EXN_ID, { - cause: exn - }); - } -} - -function $at(l1, l2) { - if (l1) { - return { - hd: l1.hd, - tl: $at(l1.tl, l2) - }; - } else { - return l2; - } -} - -function print_newline() { - console.log(""); -} - -function prerr_newline() { - console.error(""); -} - -function print_int(i) { - console.log(String(i)); -} - -function print_float(i) { - console.log(string_of_float(i)); -} - -function print_string(prim) { - console.log(prim); -} - -let exit_function = { - contents: (function (prim) { - - }) -}; - -function at_exit(f) { - let g = exit_function.contents; - exit_function.contents = (function () { - f(); - g(); - }); -} - -function exit(retcode) { - exit_function.contents(); - return Caml_sys.sys_exit(retcode); -} - -let Jsx; - -let JsxEvent; - -let JsxDOM; - -let JsxPPXReactSupport; - -let max_int = 2147483647; - -let infinity = Infinity; - -let neg_infinity = -Infinity; - -let max_float = 1.79769313486231571e+308; - -let min_float = 2.22507385850720138e-308; - -let epsilon_float = 2.22044604925031308e-16; - -export { - Jsx, - JsxEvent, - JsxDOM, - JsxPPXReactSupport, - JsxModules, - invalid_arg, - failwith, - Exit, - abs, - max_int, - min_int, - lnot, - infinity, - neg_infinity, - max_float, - min_float, - epsilon_float, - classify_float, - char_of_int, - string_of_bool, - bool_of_string, - bool_of_string_opt, - int_of_string_opt, - string_of_float, - float_of_string_opt, - $at, - print_string, - print_int, - print_float, - print_newline, - prerr_newline, - exit, - at_exit, - valid_float_lexem, -} -/* No side effect */ diff --git a/lib/js/arg.js b/lib/js/arg.js index 6adf5e61c8..192e936c98 100644 --- a/lib/js/arg.js +++ b/lib/js/arg.js @@ -8,9 +8,9 @@ let Buffer = require("./buffer.js"); let $$String = require("./string.js"); let Caml_obj = require("./caml_obj.js"); let Caml_array = require("./caml_array.js"); +let Pervasives = require("./pervasives.js"); let Caml_format = require("./caml_format.js"); let Caml_string = require("./caml_string.js"); -let PervasivesU = require("./pervasivesU.js"); let Caml_exceptions = require("./caml_exceptions.js"); let Caml_js_exceptions = require("./caml_js_exceptions.js"); @@ -121,7 +121,7 @@ function add_help(speclist) { }); } } - return PervasivesU.$at(speclist, PervasivesU.$at(add1, add2)); + return Pervasives.$at(speclist, Pervasives.$at(add1, add2)); } function usage_b(buf, speclist, errmsg) { @@ -157,7 +157,7 @@ let current = { function bool_of_string_opt(x) { try { - return PervasivesU.bool_of_string(x); + return Pervasives.bool_of_string(x); } catch (raw_exn){ let exn = Caml_js_exceptions.internalToOCamlException(raw_exn); @@ -559,11 +559,11 @@ function parse(l, f, msg) { let msg$1 = Caml_js_exceptions.internalToOCamlException(raw_msg); if (msg$1.RE_EXN_ID === Bad) { console.log(msg$1._1); - return PervasivesU.exit(2); + return Pervasives.exit(2); } if (msg$1.RE_EXN_ID === Help) { console.log(msg$1._1); - return PervasivesU.exit(0); + return Pervasives.exit(0); } throw new Error(msg$1.RE_EXN_ID, { cause: msg$1 @@ -579,11 +579,11 @@ function parse_dynamic(l, f, msg) { let msg$1 = Caml_js_exceptions.internalToOCamlException(raw_msg); if (msg$1.RE_EXN_ID === Bad) { console.log(msg$1._1); - return PervasivesU.exit(2); + return Pervasives.exit(2); } if (msg$1.RE_EXN_ID === Help) { console.log(msg$1._1); - return PervasivesU.exit(0); + return Pervasives.exit(0); } throw new Error(msg$1.RE_EXN_ID, { cause: msg$1 @@ -608,11 +608,11 @@ function parse_expand(l, f, msg) { let msg$1 = Caml_js_exceptions.internalToOCamlException(raw_msg); if (msg$1.RE_EXN_ID === Bad) { console.log(msg$1._1); - return PervasivesU.exit(2); + return Pervasives.exit(2); } if (msg$1.RE_EXN_ID === Help) { console.log(msg$1._1); - return PervasivesU.exit(0); + return Pervasives.exit(0); } throw new Error(msg$1.RE_EXN_ID, { cause: msg$1 @@ -694,7 +694,7 @@ function replace_leading_tab(s) { } function align(limitOpt, speclist) { - let limit = limitOpt !== undefined ? limitOpt : PervasivesU.max_int; + let limit = limitOpt !== undefined ? limitOpt : Pervasives.max_int; let completed = add_help(speclist); let len = List.fold_left(max_arg_len, 0, completed); let len$1 = len < limit ? len : limit; diff --git a/lib/js/hashtbl.js b/lib/js/hashtbl.js index 21d29fbb69..e06bff9294 100644 --- a/lib/js/hashtbl.js +++ b/lib/js/hashtbl.js @@ -7,8 +7,8 @@ let Random = require("./random.js"); let Caml_obj = require("./caml_obj.js"); let Caml_hash = require("./caml_hash.js"); let Caml_array = require("./caml_array.js"); +let Pervasives = require("./pervasives.js"); let Caml_option = require("./caml_option.js"); -let PervasivesU = require("./pervasivesU.js"); let CamlinternalLazy = require("./camlinternalLazy.js"); function hash(x) { @@ -79,11 +79,11 @@ function clear(h) { function reset(h) { let len = h.data.length; - if (len === PervasivesU.abs(h.initial_size)) { + if (len === Pervasives.abs(h.initial_size)) { return clear(h); } else { h.size = 0; - h.data = Caml_array.make(PervasivesU.abs(h.initial_size), "Empty"); + h.data = Caml_array.make(Pervasives.abs(h.initial_size), "Empty"); return; } } diff --git a/lib/js/list.js b/lib/js/list.js index 3794a4fc25..436c025ee2 100644 --- a/lib/js/list.js +++ b/lib/js/list.js @@ -1,8 +1,8 @@ 'use strict'; let Caml_obj = require("./caml_obj.js"); +let Pervasives = require("./pervasives.js"); let Caml_option = require("./caml_option.js"); -let PervasivesU = require("./pervasivesU.js"); function length(l) { let _len = 0; @@ -172,7 +172,7 @@ function init(len, f) { function flatten(param) { if (param) { - return PervasivesU.$at(param.hd, flatten(param.tl)); + return Pervasives.$at(param.hd, flatten(param.tl)); } else { return /* [] */0; } @@ -1669,7 +1669,7 @@ function compare_length_with(_l, _n) { }; } -let append = PervasivesU.$at; +let append = Pervasives.$at; let concat = flatten; diff --git a/lib/js/listLabels.js b/lib/js/listLabels.js index 66e84f6859..6f81e7afde 100644 --- a/lib/js/listLabels.js +++ b/lib/js/listLabels.js @@ -1,8 +1,8 @@ 'use strict'; let Caml_obj = require("./caml_obj.js"); +let Pervasives = require("./pervasives.js"); let Caml_option = require("./caml_option.js"); -let PervasivesU = require("./pervasivesU.js"); function length(l) { let _len = 0; @@ -172,7 +172,7 @@ function init(len, f) { function flatten(param) { if (param) { - return PervasivesU.$at(param.hd, flatten(param.tl)); + return Pervasives.$at(param.hd, flatten(param.tl)); } else { return /* [] */0; } @@ -1669,7 +1669,7 @@ function compare_length_with(_l, _n) { }; } -let append = PervasivesU.$at; +let append = Pervasives.$at; let concat = flatten; diff --git a/lib/js/pervasivesU.js b/lib/js/pervasivesU.js deleted file mode 100644 index 0cf8db3ec2..0000000000 --- a/lib/js/pervasivesU.js +++ /dev/null @@ -1,274 +0,0 @@ -'use strict'; - -let Caml_sys = require("./caml_sys.js"); -let Caml_format = require("./caml_format.js"); -let Caml_string = require("./caml_string.js"); -let Caml_exceptions = require("./caml_exceptions.js"); -let Caml_js_exceptions = require("./caml_js_exceptions.js"); - -let JsxModules = { - Jsx: undefined, - JsxEvent: undefined, - JsxDOM: undefined -}; - -function failwith(s) { - throw new Error("Failure", { - cause: { - RE_EXN_ID: "Failure", - _1: s - } - }); -} - -function invalid_arg(s) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: s - } - }); -} - -let Exit = /* @__PURE__ */Caml_exceptions.create("PervasivesU.Exit"); - -function abs(x) { - if (x >= 0) { - return x; - } else { - return -x | 0; - } -} - -function lnot(x) { - return x ^ -1; -} - -let min_int = -2147483648; - -function classify_float(x) { - if (isFinite(x)) { - if (Math.abs(x) >= 2.22507385850720138e-308) { - return "FP_normal"; - } else if (x !== 0) { - return "FP_subnormal"; - } else { - return "FP_zero"; - } - } else if (isNaN(x)) { - return "FP_nan"; - } else { - return "FP_infinite"; - } -} - -function char_of_int(n) { - if (n < 0 || n > 255) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "char_of_int" - } - }); - } - return n; -} - -function string_of_bool(b) { - if (b) { - return "true"; - } else { - return "false"; - } -} - -function bool_of_string(param) { - switch (param) { - case "false" : - return false; - case "true" : - return true; - default: - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "bool_of_string" - } - }); - } -} - -function bool_of_string_opt(param) { - switch (param) { - case "false" : - return false; - case "true" : - return true; - default: - return; - } -} - -function int_of_string_opt(s) { - try { - return Caml_format.int_of_string(s); - } - catch (raw_exn){ - let exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === "Failure") { - return; - } - throw new Error(exn.RE_EXN_ID, { - cause: exn - }); - } -} - -function valid_float_lexem(s) { - let l = s.length; - let _i = 0; - while(true) { - let i = _i; - if (i >= l) { - return s + "."; - } - let match = Caml_string.get(s, i); - if (match >= 48) { - if (match >= 58) { - return s; - } - _i = i + 1 | 0; - continue; - } - if (match !== 45) { - return s; - } - _i = i + 1 | 0; - continue; - }; -} - -function string_of_float(f) { - return valid_float_lexem(Caml_format.format_float("%.12g", f)); -} - -function float_of_string_opt(s) { - try { - return Caml_format.float_of_string(s); - } - catch (raw_exn){ - let exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === "Failure") { - return; - } - throw new Error(exn.RE_EXN_ID, { - cause: exn - }); - } -} - -function $at(l1, l2) { - if (l1) { - return { - hd: l1.hd, - tl: $at(l1.tl, l2) - }; - } else { - return l2; - } -} - -function print_newline() { - console.log(""); -} - -function prerr_newline() { - console.error(""); -} - -function print_int(i) { - console.log(String(i)); -} - -function print_float(i) { - console.log(string_of_float(i)); -} - -function print_string(prim) { - console.log(prim); -} - -let exit_function = { - contents: (function (prim) { - - }) -}; - -function at_exit(f) { - let g = exit_function.contents; - exit_function.contents = (function () { - f(); - g(); - }); -} - -function exit(retcode) { - exit_function.contents(); - return Caml_sys.sys_exit(retcode); -} - -let Jsx; - -let JsxEvent; - -let JsxDOM; - -let JsxPPXReactSupport; - -let max_int = 2147483647; - -let infinity = Infinity; - -let neg_infinity = -Infinity; - -let max_float = 1.79769313486231571e+308; - -let min_float = 2.22507385850720138e-308; - -let epsilon_float = 2.22044604925031308e-16; - -exports.Jsx = Jsx; -exports.JsxEvent = JsxEvent; -exports.JsxDOM = JsxDOM; -exports.JsxPPXReactSupport = JsxPPXReactSupport; -exports.JsxModules = JsxModules; -exports.invalid_arg = invalid_arg; -exports.failwith = failwith; -exports.Exit = Exit; -exports.abs = abs; -exports.max_int = max_int; -exports.min_int = min_int; -exports.lnot = lnot; -exports.infinity = infinity; -exports.neg_infinity = neg_infinity; -exports.max_float = max_float; -exports.min_float = min_float; -exports.epsilon_float = epsilon_float; -exports.classify_float = classify_float; -exports.char_of_int = char_of_int; -exports.string_of_bool = string_of_bool; -exports.bool_of_string = bool_of_string; -exports.bool_of_string_opt = bool_of_string_opt; -exports.int_of_string_opt = int_of_string_opt; -exports.string_of_float = string_of_float; -exports.float_of_string_opt = float_of_string_opt; -exports.$at = $at; -exports.print_string = print_string; -exports.print_int = print_int; -exports.print_float = print_float; -exports.print_newline = print_newline; -exports.prerr_newline = prerr_newline; -exports.exit = exit; -exports.at_exit = at_exit; -exports.valid_float_lexem = valid_float_lexem; -/* No side effect */ diff --git a/packages/artifacts.txt b/packages/artifacts.txt index d237740ebf..7b9d73b91f 100644 --- a/packages/artifacts.txt +++ b/packages/artifacts.txt @@ -174,7 +174,6 @@ lib/es6/obj.js lib/es6/package.json lib/es6/parsing.js lib/es6/pervasives.js -lib/es6/pervasivesU.js lib/es6/queue.js lib/es6/random.js lib/es6/runtime_ast_extensions.js @@ -339,7 +338,6 @@ lib/js/moreLabels.js lib/js/obj.js lib/js/parsing.js lib/js/pervasives.js -lib/js/pervasivesU.js lib/js/queue.js lib/js/random.js lib/js/runtime_ast_extensions.js @@ -977,12 +975,6 @@ lib/ocaml/pervasives.cmt lib/ocaml/pervasives.cmti lib/ocaml/pervasives.res lib/ocaml/pervasives.resi -lib/ocaml/pervasivesU.cmi -lib/ocaml/pervasivesU.cmj -lib/ocaml/pervasivesU.cmt -lib/ocaml/pervasivesU.cmti -lib/ocaml/pervasivesU.res -lib/ocaml/pervasivesU.resi lib/ocaml/queue.cmi lib/ocaml/queue.cmj lib/ocaml/queue.cmt diff --git a/scripts/ninja.js b/scripts/ninja.js index b58a121b9f..c0fb7f4e20 100755 --- a/scripts/ninja.js +++ b/scripts/ninja.js @@ -782,7 +782,7 @@ async function runtimeNinja(devmode = true) { var externalDeps = devmode ? [compilerTarget] : []; var ninjaOutput = devmode ? "build.ninja" : "release.ninja"; var templateRuntimeRules = ` -bsc_no_open_flags = ${commonBsFlags} -bs-cross-module-opt -make-runtime -nopervasives -unsafe -w +50 -warn-error A -uncurried +bsc_no_open_flags = ${commonBsFlags} -bs-cross-module-opt -make-runtime -nopervasives -unsafe -w +50 -warn-error A bsc_flags = $bsc_no_open_flags -open Bs_stdlib_mini ${ruleCC(ninjaCwd)} ${ninjaQuickBuildList([ @@ -791,7 +791,7 @@ ${ninjaQuickBuildList([ "bs_stdlib_mini.resi", "cc", ninjaCwd, - [["bsc_flags", "-nostdlib -nopervasives -uncurried"]], + [["bsc_flags", "-nostdlib -nopervasives"]], [], externalDeps, ], @@ -863,7 +863,7 @@ async function othersNinja(devmode = true) { var ninjaCwd = "others"; var templateOthersRules = ` -bsc_primitive_flags = ${commonBsFlags} -bs-cross-module-opt -make-runtime -nopervasives -unsafe -w +50 -warn-error A -uncurried +bsc_primitive_flags = ${commonBsFlags} -bs-cross-module-opt -make-runtime -nopervasives -unsafe -w +50 -warn-error A bsc_flags = $bsc_primitive_flags -open Belt_internals ${ruleCC(ninjaCwd)} ${ninjaQuickBuildList([ @@ -965,14 +965,12 @@ async function stdlibNinja(devmode = true) { /** * @type [string,string][] */ - var bsc_builtin_overrides = [ - [bsc_flags, `$${bsc_flags} -nopervasives -uncurried`], - ]; + var bsc_builtin_overrides = [[bsc_flags, `$${bsc_flags} -nopervasives`]]; // It is interesting `-w -a` would generate not great code sometimes // deprecations diabled due to string_of_float var warnings = "-w -9-3-106 -warn-error A"; var templateStdlibRules = ` -${bsc_flags} = ${commonBsFlags} -bs-cross-module-opt -make-runtime ${warnings} -I others -uncurried +${bsc_flags} = ${commonBsFlags} -bs-cross-module-opt -make-runtime ${warnings} -I others ${ruleCC(ninjaCwd)} ${ninjaQuickBuildList([ // we make it still depends on external @@ -996,41 +994,19 @@ ${ninjaQuickBuildList([ [], externalDeps, ], - [ - "pervasivesU.cmj", - "pervasivesU.res", - "cc_cmi", - ninjaCwd, - bsc_builtin_overrides, - "pervasivesU.cmi", - externalDeps, - ], - [ - "pervasivesU.cmi", - "pervasivesU.resi", - "cc", - ninjaCwd, - bsc_builtin_overrides, - [], - externalDeps, - ], ])} `; var stdlibDirFiles = fs.readdirSync(stdlibDir, "ascii"); var sources = stdlibDirFiles.filter(x => { return ( !x.startsWith("pervasives.") && - !x.startsWith("pervasivesU.") && (x.endsWith(".res") || x.endsWith(".resi")) ); }); let depsMap = new Map(); await ocamlDepForBscAsync(sources, stdlibDir, depsMap); var targets = collectTarget(sources); - var allTargets = scanFileTargets(targets, [ - "pervasivesU.cmi", - "pervasivesU.cmj", - ]); + var allTargets = scanFileTargets(targets, []); targets.forEach((ext, mod) => { switch (ext) { case "HAS_RESI": @@ -1104,7 +1080,7 @@ async function testNinja() { var ninjaOutput = "build.ninja"; var ninjaCwd = `test`; var templateTestRules = ` -bsc_flags = -bs-cross-module-opt -make-runtime-test -bs-package-output commonjs:jscomp/test -w -3-6-26-27-29-30-32..40-44-45-52-60-9-106+104 -warn-error A -I runtime -I $stdlib -I others -uncurried +bsc_flags = -bs-cross-module-opt -make-runtime-test -bs-package-output commonjs:jscomp/test -w -3-6-26-27-29-30-32..40-44-45-52-60-9-106+104 -warn-error A -I runtime -I $stdlib -I others ${ruleCC(ninjaCwd)} `; var testDirFiles = fs.readdirSync(testDir, "ascii");