From bf4e2c5021c988c89fd0fd7a8d31429755a10cdd Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Mon, 26 Oct 2026 09:57:02 +0000 Subject: [PATCH 1/4] Remove stdlib APIs deprecated in v12 Why: v12 deprecated these APIs with migration templates, so v13 can drop them. List.has and the Error and Exn modules are deprecated in 12.3.2 (#8807) and go as well. Reanalyze, gentype and completion no longer name the removed modules. Review: Why does lam_analysis lose its Lazy.from_fun case? That case treated a call to the removed `Lazy.from_fun` as free of side effects; no program can call it any more. Breaking: Code using a removed API no longer compiles. Run `rescript-tools migrate-all` with ReScript 12.3.2 before upgrading; 13.0.0 must therefore be released after 12.3.2. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013ZYFYMu3AE9P1xFVCR34d1 Signed-off-by: Christoph Knittel --- analysis/reanalyze/src/exn.ml | 1 - analysis/reanalyze/src/exn.mli | 1 - analysis/reanalyze/src/exn_lib.ml | 65 +-- analysis/src/completion_back_end.ml | 2 +- .../remove-v12-deprecated-stdlib.breaking.md | 1 + compiler/core/lam_analysis.ml | 6 - .../gentype/translate_type_expr_from_types.ml | 3 +- packages/@rescript/runtime/JsxDOM.res | 6 - packages/@rescript/runtime/Pervasives.res | 14 - packages/@rescript/runtime/Stdlib.res | 8 +- packages/@rescript/runtime/Stdlib_Array.res | 62 +-- packages/@rescript/runtime/Stdlib_Array.resi | 143 ------ .../@rescript/runtime/Stdlib_ArrayBuffer.res | 7 - .../@rescript/runtime/Stdlib_ArrayBuffer.resi | 7 - packages/@rescript/runtime/Stdlib_BigInt.res | 24 - packages/@rescript/runtime/Stdlib_BigInt.resi | 122 ----- .../runtime/Stdlib_BigInt64Array.res | 32 -- .../runtime/Stdlib_BigUint64Array.res | 35 -- packages/@rescript/runtime/Stdlib_Bool.res | 6 - packages/@rescript/runtime/Stdlib_Bool.resi | 21 - .../@rescript/runtime/Stdlib_DataView.res | 13 - .../@rescript/runtime/Stdlib_DataView.resi | 39 -- packages/@rescript/runtime/Stdlib_Error.res | 47 -- packages/@rescript/runtime/Stdlib_Error.resi | 277 ---------- packages/@rescript/runtime/Stdlib_Exn.res | 75 --- packages/@rescript/runtime/Stdlib_Exn.resi | 122 ----- packages/@rescript/runtime/Stdlib_Float.res | 30 -- packages/@rescript/runtime/Stdlib_Float.resi | 122 ----- .../@rescript/runtime/Stdlib_Float32Array.res | 35 -- .../@rescript/runtime/Stdlib_Float64Array.res | 35 -- packages/@rescript/runtime/Stdlib_Int.res | 45 +- packages/@rescript/runtime/Stdlib_Int.resi | 169 ------- .../@rescript/runtime/Stdlib_Int16Array.res | 35 -- .../@rescript/runtime/Stdlib_Int32Array.res | 35 -- .../@rescript/runtime/Stdlib_Int8Array.res | 35 -- packages/@rescript/runtime/Stdlib_JSON.res | 139 ----- packages/@rescript/runtime/Stdlib_JSON.resi | 476 +----------------- packages/@rescript/runtime/Stdlib_JsExn.resi | 4 +- packages/@rescript/runtime/Stdlib_Lazy.res | 34 +- packages/@rescript/runtime/Stdlib_Lazy.resi | 61 --- packages/@rescript/runtime/Stdlib_List.res | 98 ---- packages/@rescript/runtime/Stdlib_List.resi | 191 ------- packages/@rescript/runtime/Stdlib_Null.res | 6 - packages/@rescript/runtime/Stdlib_Null.resi | 39 -- .../@rescript/runtime/Stdlib_Nullable.res | 6 - .../@rescript/runtime/Stdlib_Nullable.resi | 42 -- packages/@rescript/runtime/Stdlib_Option.res | 6 - packages/@rescript/runtime/Stdlib_Option.resi | 39 -- packages/@rescript/runtime/Stdlib_Promise.res | 2 - .../@rescript/runtime/Stdlib_Promise.resi | 10 - packages/@rescript/runtime/Stdlib_RegExp.res | 1 - packages/@rescript/runtime/Stdlib_RegExp.resi | 45 +- packages/@rescript/runtime/Stdlib_Result.res | 6 - packages/@rescript/runtime/Stdlib_Result.resi | 35 -- packages/@rescript/runtime/Stdlib_String.res | 49 +- packages/@rescript/runtime/Stdlib_String.resi | 153 ------ .../@rescript/runtime/Stdlib_TypedArray.res | 52 -- .../@rescript/runtime/Stdlib_Uint16Array.res | 35 -- .../@rescript/runtime/Stdlib_Uint32Array.res | 35 -- .../@rescript/runtime/Stdlib_Uint8Array.res | 35 -- .../runtime/Stdlib_Uint8ClampedArray.res | 35 -- .../@rescript/runtime/lib/es6/Pervasives.mjs | 29 +- packages/@rescript/runtime/lib/es6/Stdlib.mjs | 8 +- .../@rescript/runtime/lib/es6/Stdlib_Bool.mjs | 3 - .../runtime/lib/es6/Stdlib_Error.mjs | 38 -- .../@rescript/runtime/lib/es6/Stdlib_Exn.mjs | 56 --- .../@rescript/runtime/lib/es6/Stdlib_Int.mjs | 14 - .../@rescript/runtime/lib/es6/Stdlib_JSON.mjs | 38 -- .../@rescript/runtime/lib/es6/Stdlib_Lazy.mjs | 46 +- .../@rescript/runtime/lib/es6/Stdlib_List.mjs | 150 ------ .../@rescript/runtime/lib/es6/Stdlib_Null.mjs | 9 - .../runtime/lib/es6/Stdlib_Nullable.mjs | 9 - .../runtime/lib/es6/Stdlib_Option.mjs | 9 - .../runtime/lib/es6/Stdlib_Result.mjs | 9 - .../@rescript/runtime/lib/js/Pervasives.cjs | 27 +- packages/@rescript/runtime/lib/js/Stdlib.cjs | 8 +- .../@rescript/runtime/lib/js/Stdlib_Bool.cjs | 3 - .../@rescript/runtime/lib/js/Stdlib_Error.cjs | 36 -- .../@rescript/runtime/lib/js/Stdlib_Exn.cjs | 54 -- .../@rescript/runtime/lib/js/Stdlib_Int.cjs | 14 - .../@rescript/runtime/lib/js/Stdlib_JSON.cjs | 38 -- .../@rescript/runtime/lib/js/Stdlib_Lazy.cjs | 46 +- .../@rescript/runtime/lib/js/Stdlib_List.cjs | 150 ------ .../@rescript/runtime/lib/js/Stdlib_Null.cjs | 9 - .../runtime/lib/js/Stdlib_Nullable.cjs | 9 - .../runtime/lib/js/Stdlib_Option.cjs | 9 - .../runtime/lib/js/Stdlib_Result.cjs | 9 - packages/artifacts.json | 16 - 88 files changed, 52 insertions(+), 4108 deletions(-) create mode 100644 changes/remove-v12-deprecated-stdlib.breaking.md delete mode 100644 packages/@rescript/runtime/Stdlib_Error.res delete mode 100644 packages/@rescript/runtime/Stdlib_Error.resi delete mode 100644 packages/@rescript/runtime/Stdlib_Exn.res delete mode 100644 packages/@rescript/runtime/Stdlib_Exn.resi delete mode 100644 packages/@rescript/runtime/lib/es6/Stdlib_Error.mjs delete mode 100644 packages/@rescript/runtime/lib/es6/Stdlib_Exn.mjs delete mode 100644 packages/@rescript/runtime/lib/js/Stdlib_Error.cjs delete mode 100644 packages/@rescript/runtime/lib/js/Stdlib_Exn.cjs diff --git a/analysis/reanalyze/src/exn.ml b/analysis/reanalyze/src/exn.ml index c14e5476969..47b64705cea 100644 --- a/analysis/reanalyze/src/exn.ml +++ b/analysis/reanalyze/src/exn.ml @@ -4,7 +4,6 @@ let compare = String.compare let decode_error = "DecodeError" let assert_failure = "Assert_failure" let division_by_zero = "Division_by_zero" -let failure = "Failure" let invalid_argument = "Invalid_argument" let js_exn = "JsExn" let match_failure = "Match_failure" diff --git a/analysis/reanalyze/src/exn.mli b/analysis/reanalyze/src/exn.mli index fc6ee05557b..21eb9f90cc5 100644 --- a/analysis/reanalyze/src/exn.mli +++ b/analysis/reanalyze/src/exn.mli @@ -4,7 +4,6 @@ val compare : t -> t -> int val assert_failure : t val decode_error : t val division_by_zero : t -val failure : t val from_lid : Longident.t -> t val from_string : string -> t val invalid_argument : t diff --git a/analysis/reanalyze/src/exn_lib.ml b/analysis/reanalyze/src/exn_lib.ml index 6c53ce850f6..2fe0d9a5849 100644 --- a/analysis/reanalyze/src/exn_lib.ml +++ b/analysis/reanalyze/src/exn_lib.ml @@ -61,29 +61,14 @@ let raises_lib_table : (Name.t, Exceptions.t) Hashtbl.t = [ ("panic", [js_exn]); ("assertEqual", [js_exn]); - ("invalid_arg", [invalid_argument]); - ("failwith", [failure]); ("/", [division_by_zero]); ("mod", [division_by_zero]); - ("char_of_int", [invalid_argument]); - ("bool_of_string", [invalid_argument]); - ("int_of_string", [failure]); - ("float_of_string", [failure]); ] in let stdlib_big_int = - [ - ("fromStringExn", [js_exn]); - ("fromStringOrThrow", [js_exn]); - ("fromFloatOrThrow", [js_exn]); - ] - in - let stdlib_bool = - [ - ("fromStringExn", [invalid_argument]); - ("fromStringOrThrow", [invalid_argument]); - ] + [("fromStringOrThrow", [js_exn]); ("fromFloatOrThrow", [js_exn])] in + let stdlib_bool = [("fromStringOrThrow", [invalid_argument])] in let stdlib_js_error = [ ("EvalError.throwWithMessage", [js_exn]); @@ -97,42 +82,18 @@ let raises_lib_table : (Name.t, Exceptions.t) Hashtbl.t = ("throwWithMessage", [js_exn]); ] in - let stdlib_error = - [("raise", [js_exn]); ("panic", [js_exn]); ("throw", [js_exn])] - in - let stdlib_exn = - [ - ("raiseError", [js_exn]); - ("raiseEvalError", [js_exn]); - ("raiseRangeError", [js_exn]); - ("raiseReferenceError", [js_exn]); - ("raiseSyntaxError", [js_exn]); - ("raiseTypeError", [js_exn]); - ("raiseUriError", [js_exn]); - ] - in - let stdlib_json = - [ - ("parseExn", [js_exn]); - ("parseExnWithReviver", [js_exn]); - ("parseOrThrow", [js_exn]); - ("stringifyAny", [js_exn]); - ("stringifyAnyWithIndent", [js_exn]); - ("stringifyAnyWithReplacer", [js_exn]); - ("stringifyAnyWithReplacerAndIndent", [js_exn]); - ("stringifyAnyWithFilter", [js_exn]); - ("stringifyAnyWithFilterAndIndent", [js_exn]); - ] - in + let stdlib_json = [("parseOrThrow", [js_exn]); ("stringifyAny", [js_exn])] in let stdlib_list = [ - ("headExn", [not_found]); ("tailExn", [not_found]); ("getExn", [not_found]); + ("headOrThrow", [not_found]); + ("tailOrThrow", [not_found]); + ("getOrThrow", [not_found]); ] in - let stdlib_null = [("getExn", [invalid_argument])] in - let stdlib_nullable = [("getExn", [invalid_argument])] in - let stdlib_option = [("getExn", [js_exn])] in - let stdlib_result = [("getExn", [not_found])] in + let stdlib_null = [("getOrThrow", [invalid_argument])] in + let stdlib_nullable = [("getOrThrow", [invalid_argument])] in + let stdlib_option = [("getOrThrow", [js_exn])] in + let stdlib_result = [("getOrThrow", [js_exn])] in let yojson_basic = [("from_string", [yojson_json_error])] in let yojson_basic_util = [ @@ -192,8 +153,6 @@ let raises_lib_table : (Name.t, Exceptions.t) Hashtbl.t = ("Belt_SetString", belt_set); ("BigInt", stdlib_big_int); ("Bool", stdlib_bool); - ("Error", stdlib_error); - ("Exn", stdlib_exn); ("JsError", stdlib_js_error); ("JSON", stdlib_json); ("Json_decode", bs_json); @@ -212,10 +171,6 @@ let raises_lib_table : (Name.t, Exceptions.t) Hashtbl.t = ("Stdlib.BigInt", stdlib_big_int); ("Stdlib_Bool", stdlib_bool); ("Stdlib.Bool", stdlib_bool); - ("Stdlib_Error", stdlib_error); - ("Stdlib.Error", stdlib_error); - ("Stdlib_Exn", stdlib_exn); - ("Stdlib.Exn", stdlib_exn); ("Stdlib_JsError", stdlib_js_error); ("Stdlib.JsError", stdlib_js_error); ("Stdlib_JSON", stdlib_json); diff --git a/analysis/src/completion_back_end.ml b/analysis/src/completion_back_end.ml index 62e11faabb7..2ebd1804826 100644 --- a/analysis/src/completion_back_end.ml +++ b/analysis/src/completion_back_end.ml @@ -2075,7 +2075,7 @@ let rec complete_typed_value ?(type_arg_context : type_arg_context option) if Debug.verbose () then print_endline "[complete_typed_value]--> Texn"; [ create - (["Exn"; "Error(error)"] |> ident) + (["JsExn(error)"] |> ident) ~kind:(Label "Catches errors from JavaScript errors.") ~docstring: [ diff --git a/changes/remove-v12-deprecated-stdlib.breaking.md b/changes/remove-v12-deprecated-stdlib.breaking.md new file mode 100644 index 00000000000..17528949a7c --- /dev/null +++ b/changes/remove-v12-deprecated-stdlib.breaking.md @@ -0,0 +1 @@ +- Remove the standard library APIs deprecated in v12, including `List.has` and the `Error` and `Exn` modules. Run `rescript-tools migrate-all` with ReScript 12.3.2 before upgrading to migrate your code automatically. diff --git a/compiler/core/lam_analysis.ml b/compiler/core/lam_analysis.ml index 43cd70bc898..de610d34089 100644 --- a/compiler/core/lam_analysis.ml +++ b/compiler/core/lam_analysis.ml @@ -134,12 +134,6 @@ let rec no_side_effects (lam : Lambda.t) : bool = | Lfor _ -> false | Lfor_of _ | Lfor_await_of _ -> false | Lassign _ -> false (* actually it depends ... *) - | Lapply - { - ap_func = Lprim {primitive = Pfield (_, Fld_module {name = "from_fun"})}; - ap_args = [arg]; - } -> - no_side_effects arg | Lapply _ -> false (* we need purity analysis .. *) diff --git a/compiler/gentype/translate_type_expr_from_types.ml b/compiler/gentype/translate_type_expr_from_types.ml index feae883c15f..57142aabb01 100644 --- a/compiler/gentype/translate_type_expr_from_types.ml +++ b/compiler/gentype/translate_type_expr_from_types.ml @@ -127,8 +127,7 @@ let translate_constr ~config ~params_translation ~(path : Path.t) ~type_env = | ["Stdlib"; "Symbol"; "t"], [] -> {dependencies = []; type_ = ident "symbol"} | ["Stdlib"; "Intl"; intl_module; "t"], [] -> {dependencies = []; type_ = ident ("Intl." ^ intl_module)} - | (["Stdlib"; "Error"; "t"] | ["Stdlib"; "JsError"; "t"]), [] -> - {dependencies = []; type_ = ident "Error"} + | ["Stdlib"; "JsError"; "t"], [] -> {dependencies = []; type_ = ident "Error"} | (["Stdlib"; "Iterable"; "t"] | ["iterable"]), [param_translation] -> { dependencies = param_translation.dependencies; diff --git a/packages/@rescript/runtime/JsxDOM.res b/packages/@rescript/runtime/JsxDOM.res index 33f1d474ebe..de9d04575ee 100644 --- a/packages/@rescript/runtime/JsxDOM.res +++ b/packages/@rescript/runtime/JsxDOM.res @@ -372,8 +372,6 @@ type domProps = { baselineShift?: string, bbox?: string, begin?: string, - @deprecated("Please use begin") - begin_?: string, bias?: string, by?: string, calcMode?: string, @@ -406,8 +404,6 @@ type domProps = { elevation?: string, enableBackground?: string, end?: string, - @deprecated("Please use end") - end_?: string, exponent?: string, externalResourcesRequired?: string, fill?: string, @@ -555,8 +551,6 @@ type domProps = { textLength?: string, textRendering?: string, to?: string, - @deprecated("Please use to") - to_?: string, transform?: string, u1?: string, u2?: string, diff --git a/packages/@rescript/runtime/Pervasives.res b/packages/@rescript/runtime/Pervasives.res index 959de6ee21d..b71e4380532 100644 --- a/packages/@rescript/runtime/Pervasives.res +++ b/packages/@rescript/runtime/Pervasives.res @@ -19,20 +19,6 @@ result == "Caught exception: Out of milk" */ external throw: exn => 'a = "%raise" -@deprecated({ - reason: "`raise` has been renamed to `throw` to align with JavaScript vocabulary. Please use `throw` instead", - migrate: throw(), -}) -external raise: exn => 'a = "%raise" - -@deprecated("Use a custom exception or `JsError.throwWithMessage` instead.") -let failwith = s => throw(Failure(s)) - -@deprecated("Use a custom exception or `JsError.throwWithMessage` instead.") -let invalid_arg = s => throw(Invalid_argument(s)) - -@deprecated("Use custom exception instead") exception Exit - /* Debugging */ external __LOC__: string = "%loc_LOC" diff --git a/packages/@rescript/runtime/Stdlib.res b/packages/@rescript/runtime/Stdlib.res index 20469035b87..c9eca2b2138 100644 --- a/packages/@rescript/runtime/Stdlib.res +++ b/packages/@rescript/runtime/Stdlib.res @@ -8,8 +8,6 @@ module Console = Stdlib_Console module DataView = Stdlib_DataView module Date = Stdlib_Date module Dict = Stdlib_Dict -module Exn = Stdlib_Exn -module Error = Stdlib_Error module File = Stdlib_File module Float = Stdlib_Float module Int = Stdlib_Int @@ -67,11 +65,7 @@ type date = Date.t type null<+'a> = Primitive_js_extern.null<'a> type undefined<+'a> = Primitive_js_extern.undefined<'a> type nullable<+'a> = Primitive_js_extern.nullable<'a> -@deprecated("Use Lazy.t instead") -type lazy_t<+'a> = Lazy.t<'a> -@deprecated("Use rescript-webapi instead") @val external window: Dom.window = "window" -@deprecated("Use rescript-webapi instead") @val external document: Dom.document = "document" /** `globalThis` gives you the host global object (`window` in browsers, `global` in Node, etc.). You can reach shared globals from any runtime without special checks. @@ -155,7 +149,7 @@ let panic = JsError.panic ## Examples ```rescript -list{1, 2}->List.tailExn == list{2} +list{1, 2}->List.tailOrThrow == list{2} ``` */ let assertEqual = (a, b) => { diff --git a/packages/@rescript/runtime/Stdlib_Array.res b/packages/@rescript/runtime/Stdlib_Array.res index 98f04f47f5a..91f393ea304 100644 --- a/packages/@rescript/runtime/Stdlib_Array.res +++ b/packages/@rescript/runtime/Stdlib_Array.res @@ -14,22 +14,8 @@ external fromIterable: Stdlib_Iterable.t<'a> => array<'a> = "Array.from" @val external fromArrayLikeWithMap: (arrayLike<'a>, 'a => 'b) => array<'b> = "Array.from" -@deprecated({ - reason: "Use `fill` instead", - migrate: Array.fill(), -}) -@send -external fillAll: (array<'a>, 'a) => unit = "fill" - @val external fromString: string => array = "Array.from" -@deprecated({ - reason: "Use `fill` instead", - migrate: Array.fill(~start=%insert.labelledArgument("start")), -}) -@send -external fillToEnd: (array<'a>, 'a, ~start: int) => unit = "fill" - @send external fill: (array<'a>, 'a, ~start: int=?, ~end: int=?) => unit = "fill" let make = (~length, x) => @@ -37,7 +23,7 @@ let make = (~length, x) => [] } else { let arr = makeUninitializedUnsafe(length) - arr->fillAll(x) + arr->fill(x) arr } @@ -98,20 +84,6 @@ let compare = (a, b, cmp) => { : compareFromIndex(a, b, 0, cmp, lenA) } -@deprecated({ - reason: "Use `copyWithin` instead", - migrate: Array.copyWithin(~start=0), -}) -@send -external copyAllWithin: (array<'a>, ~target: int) => array<'a> = "copyWithin" - -@deprecated({ - reason: "Use `copyWithin` instead", - migrate: Array.copyWithin(), -}) -@send -external copyWithinToEnd: (array<'a>, ~target: int, ~start: int) => array<'a> = "copyWithin" - @send external copyWithin: (array<'a>, ~target: int, ~start: int, ~end: int=?) => array<'a> = "copyWithin" @@ -155,51 +127,19 @@ let indexOfOpt = (arr, item) => | -1 => None | index => Some(index) } -@deprecated({ - reason: "Use `indexOf` instead", - migrate: Array.indexOf(~from=%insert.unlabelledArgument(2)), -}) -@send -external indexOfFrom: (array<'a>, 'a, int) => int = "indexOf" @send external join: (array, string) => string = "join" -@deprecated({ - reason: "Use `join` instead", - migrate: Array.join(), -}) -@send -external joinWith: (array, string) => string = "join" - @send external joinUnsafe: (array<'a>, string) => string = "join" -@deprecated({ - reason: "Use `joinUnsafe` instead", - migrate: Array.joinUnsafe(), -}) -@send -external joinWithUnsafe: (array<'a>, string) => string = "join" - @send external lastIndexOf: (array<'a>, 'a, ~from: int=?) => int = "lastIndexOf" let lastIndexOfOpt = (arr, item) => switch arr->lastIndexOf(item) { | -1 => None | index => Some(index) } -@deprecated({ - reason: "Use `lastIndexOf` instead", - migrate: Array.lastIndexOf(~from=%insert.unlabelledArgument(2)), -}) -@send -external lastIndexOfFrom: (array<'a>, 'a, int) => int = "lastIndexOf" @send external slice: (array<'a>, ~start: int=?, ~end: int=?) => array<'a> = "slice" -@deprecated({ - reason: "Use `slice` instead", - migrate: Array.slice(), -}) -@send -external sliceToEnd: (array<'a>, ~start: int) => array<'a> = "slice" @send external copy: array<'a> => array<'a> = "slice" diff --git a/packages/@rescript/runtime/Stdlib_Array.resi b/packages/@rescript/runtime/Stdlib_Array.resi index 32a06640ebe..6c6769807cf 100644 --- a/packages/@rescript/runtime/Stdlib_Array.resi +++ b/packages/@rescript/runtime/Stdlib_Array.resi @@ -171,45 +171,6 @@ nonEmptyArray->Array.isEmpty->assertEqual(false) */ let isEmpty: array<'a> => bool -/** -`isEmpty(array)` returns `true` if the array is empty (has length 0), `false` otherwise. - -## Examples - -```rescript -let arr = [100, 101, 102, 103, 104] -arr->Array.copyAllWithin(~target=2) == [100, 101, 100, 101, 102] -arr == [100, 101, 100, 101, 102] -``` -*/ -@deprecated({ - reason: "Use `copyWithin` instead", - migrate: Array.copyWithin(~start=0), -}) -@send external copyAllWithin: (array<'a>, ~target: int) => array<'a> = "copyWithin" - -/** -`copyWithinToEnd(array, ~target, ~start)` copies starting at element `start` in the given array to the designated `target` position, returning the resulting array. - -Beware this will *mutate* the array. - -See [`Array.copyWithin`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin) on MDN. - -## Examples - -```rescript -let arr = [100, 101, 102, 103, 104] -arr->Array.copyWithinToEnd(~target=0, ~start=2) == [102, 103, 104, 103, 104] -arr == [102, 103, 104, 103, 104] -``` -*/ -@deprecated({ - reason: "Use `copyWithin` instead", - migrate: Array.copyWithin(), -}) -@send -external copyWithinToEnd: (array<'a>, ~target: int, ~start: int) => array<'a> = "copyWithin" - /** `copyWithin(array, ~target, ~start, ~end)` copies starting at element `start` in the given array up to but not including `end` to the designated `target` position, returning the resulting array. @@ -228,50 +189,6 @@ arr == [100, 102, 103, 104, 104, 105] @send external copyWithin: (array<'a>, ~target: int, ~start: int, ~end: int=?) => array<'a> = "copyWithin" -/** -`fillAll(array, value)` fills the entire `array` with `value`. - -Beware this will *mutate* the array. - -See [`Array.fill`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill) on MDN. - -## Examples - -```rescript -let myArray = [1, 2, 3, 4] -myArray->Array.fillAll(9) -myArray == [9, 9, 9, 9] -``` -*/ -@deprecated({ - reason: "Use `fill` instead", - migrate: Array.fill(), -}) -@send -external fillAll: (array<'a>, 'a) => unit = "fill" - -/** -`fillToEnd(array, value, ~start)` fills `array` with `value` from the `start` index. - -Beware this will *mutate* the array. - -See [`Array.fill`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill) on MDN. - -## Examples - -```rescript -let myArray = [1, 2, 3, 4] -myArray->Array.fillToEnd(9, ~start=1) -myArray == [1, 9, 9, 9] -``` -*/ -@deprecated({ - reason: "Use `fill` instead", - migrate: Array.fill(~start=%insert.labelledArgument("start")), -}) -@send -external fillToEnd: (array<'a>, 'a, ~start: int) => unit = "fill" - /** `fill(array, value, ~start, ~end)` fills `array` with `value` from `start` to `end`. @@ -661,12 +578,6 @@ See [`Array.indexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Re ``` */ let indexOfOpt: (array<'a>, 'a) => option -@deprecated({ - reason: "Use `indexOf` instead", - migrate: Array.indexOf(~from=%insert.unlabelledArgument(2)), -}) -@send -external indexOfFrom: (array<'a>, 'a, int) => int = "indexOf" /** `join(array, separator)` produces a string where all items of `array` are printed, separated by `separator`. Array items must be strings, to join number or other arrays, use `joinUnsafe`. Under the hood this will run JavaScript's `toString` on all the array items. @@ -682,22 +593,6 @@ See [Array.join](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referen @send external join: (array, string) => string = "join" -/** -`joinWith(array, separator)` produces a string where all items of `array` are printed, separated by `separator`. Array items must be strings, to join number or other arrays, use `joinWithUnsafe`. Under the hood this will run JavaScript's `toString` on all the array items. - -## Examples - -```rescript -["One", "Two", "Three"]->Array.joinWith(" -- ") == "One -- Two -- Three" -``` -*/ -@deprecated({ - reason: "Use `join` instead", - migrate: Array.join(), -}) -@send -external joinWith: (array, string) => string = "join" - /** `joinUnsafe(array, separator)` produces a string where all items of `array` are printed, separated by `separator`. Under the hood this will run JavaScript's `toString` on all the array items. @@ -712,21 +607,6 @@ See [Array.join](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referen @send external joinUnsafe: (array<'a>, string) => string = "join" -/** -`joinWithUnsafe(array, separator)` produces a string where all items of `array` are printed, separated by `separator`. Under the hood this will run JavaScript's `toString` on all the array items. - -## Examples - -```rescript -[1, 2, 3]->Array.joinWithUnsafe(" -- ") == "1 -- 2 -- 3" -``` -*/ -@deprecated({ - reason: "Use `joinUnsafe` instead", - migrate: Array.joinUnsafe(), -}) -@send -external joinWithUnsafe: (array<'a>, string) => string = "join" /** `lastIndexOf(array, item, ~from)` returns the last index of the provided `item` in `array`, searching backwards from `from`. Uses [strict check for equality](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality) when comparing items. @@ -746,12 +626,6 @@ See [`Array.lastIndexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScrip */ @send external lastIndexOf: (array<'a>, 'a, ~from: int=?) => int = "lastIndexOf" let lastIndexOfOpt: (array<'a>, 'a) => option -@deprecated({ - reason: "Use `lastIndexOf` instead", - migrate: Array.lastIndexOf(~from=%insert.unlabelledArgument(2)), -}) -@send -external lastIndexOfFrom: (array<'a>, 'a, int) => int = "lastIndexOf" /** `slice(array, ~start, ~end)` creates a new array of items copied from `array` from `start` until (but not including) `end`. @@ -769,23 +643,6 @@ See [`Array.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe @send external slice: (array<'a>, ~start: int=?, ~end: int=?) => array<'a> = "slice" -/** -`sliceToEnd(array, start)` creates a new array from `array`, with all items from `array` starting from `start`. - -See [`Array.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice) on MDN. - -## Examples - -```rescript -[1, 2, 3, 4]->Array.sliceToEnd(~start=1) == [2, 3, 4] -``` -*/ -@deprecated({ - reason: "Use `slice` instead", - migrate: Array.slice(), -}) -@send -external sliceToEnd: (array<'a>, ~start: int) => array<'a> = "slice" /** `copy(array)` makes a copy of the array with the items in it, but does not make copies of the items themselves. diff --git a/packages/@rescript/runtime/Stdlib_ArrayBuffer.res b/packages/@rescript/runtime/Stdlib_ArrayBuffer.res index 24773b6bce8..7556e56614b 100644 --- a/packages/@rescript/runtime/Stdlib_ArrayBuffer.res +++ b/packages/@rescript/runtime/Stdlib_ArrayBuffer.res @@ -6,11 +6,4 @@ type t @send external slice: (t, ~start: int=?, ~end: int=?) => t = "slice" -@deprecated({ - reason: "Use `slice` instead.", - migrate: ArrayBuffer.slice(), -}) -@send -external sliceToEnd: (t, ~start: int) => t = "slice" - external ignore: t => unit = "%ignore" diff --git a/packages/@rescript/runtime/Stdlib_ArrayBuffer.resi b/packages/@rescript/runtime/Stdlib_ArrayBuffer.resi index f45360bb879..95ae0b9773c 100644 --- a/packages/@rescript/runtime/Stdlib_ArrayBuffer.resi +++ b/packages/@rescript/runtime/Stdlib_ArrayBuffer.resi @@ -53,13 +53,6 @@ ArrayBuffer.byteLength(sliced) == 8 */ @send external slice: (t, ~start: int=?, ~end: int=?) => t = "slice" -@deprecated({ - reason: "Use `slice` instead.", - migrate: ArrayBuffer.slice(), -}) -@send -external sliceToEnd: (t, ~start: int) => t = "slice" - /** `ignore(arrayBuffer)` ignores the provided arrayBuffer and returns unit. diff --git a/packages/@rescript/runtime/Stdlib_BigInt.res b/packages/@rescript/runtime/Stdlib_BigInt.res index d8b608f7259..5c0b7737e60 100644 --- a/packages/@rescript/runtime/Stdlib_BigInt.res +++ b/packages/@rescript/runtime/Stdlib_BigInt.res @@ -12,9 +12,6 @@ let fromString = (value: string) => { } } -@deprecated("Use `fromStringOrThrow` instead") @val -external fromStringExn: string => bigint = "BigInt" - @val external fromInt: int => bigint = "BigInt" @val @@ -29,9 +26,6 @@ let fromFloat = (value: float) => { @send external toString: (bigint, ~radix: int=?) => string = "toString" -@deprecated("Use `toString` with `~radix` instead") @send -external toStringWithRadix: (bigint, ~radix: int) => string = "toString" - @send external toLocaleString: bigint => string = "toLocaleString" @@ -55,21 +49,3 @@ external shiftLeft: (bigint, bigint) => bigint = "%lslbigint" external shiftRight: (bigint, bigint) => bigint = "%asrbigint" external ignore: bigint => unit = "%ignore" - -@deprecated("Use `&&&` operator or `bitwiseAnd` instead.") -external land: (bigint, bigint) => bigint = "%andbigint" - -@deprecated("Use `|||` operator or `bitwiseOr` instead.") -external lor: (bigint, bigint) => bigint = "%orbigint" - -@deprecated("Use `^^^` operator or `bitwiseXor` instead.") -external lxor: (bigint, bigint) => bigint = "%xorbigint" - -@deprecated("Use `~` operator or `bitwiseNot` instead.") -external lnot: bigint => bigint = "%bitnot_bigint" - -@deprecated("Use `<<` operator or `shiftLeft` instead.") -external lsl: (bigint, bigint) => bigint = "%lslbigint" - -@deprecated("Use `>>` operator or `shiftRight` instead.") -external asr: (bigint, bigint) => bigint = "%asrbigint" diff --git a/packages/@rescript/runtime/Stdlib_BigInt.resi b/packages/@rescript/runtime/Stdlib_BigInt.resi index 87d666e8af7..231b853659b 100644 --- a/packages/@rescript/runtime/Stdlib_BigInt.resi +++ b/packages/@rescript/runtime/Stdlib_BigInt.resi @@ -80,13 +80,6 @@ BigInt.fromString("invalid") == None */ let fromString: string => option -@deprecated({ - reason: "Use `fromStringOrThrow` instead", - migrate: BigInt.fromStringOrThrow(), -}) -@val -external fromStringExn: string => bigint = "BigInt" - /** `fromInt(int)` converts an `int` to a `bigint`. @@ -151,13 +144,6 @@ BigInt.toString(123n) == "123" @send external toString: (bigint, ~radix: int=?) => string = "toString" -@deprecated({ - reason: "Use `toString` with `~radix` instead", - migrate: BigInt.toString(), -}) -@send -external toStringWithRadix: (bigint, ~radix: int) => string = "toString" - /** Returns a string with a language-sensitive representation of this BigInt value. @@ -335,111 +321,3 @@ external shiftRight: (bigint, bigint) => bigint = "%asrbigint" without having to store or process it further. */ external ignore: bigint => unit = "%ignore" - -/** -`land(a, b)` calculates the bitwise AND of two bigints. - -**Deprecated:** Use `&&&` operator or `bitwiseAnd` instead. - -## Examples - -```rescript -BigInt.land(7n, 4n) == 4n -``` -*/ -@deprecated({ - reason: "Use `&&&` operator or `bitwiseAnd` instead.", - migrate: %insert.unlabelledArgument(0) &&& %insert.unlabelledArgument(1), - migrateInPipeChain: BigInt.bitwiseAnd(), -}) -external land: (bigint, bigint) => bigint = "%andbigint" - -/** -`lor(a, b)` calculates the bitwise OR of two bigints. - -**Deprecated:** Use `|||` operator or `bitwiseOr` instead. - -## Examples - -```rescript -BigInt.lor(7n, 4n) == 7n -``` -*/ -@deprecated({ - reason: "Use `|||` operator or `bitwiseOr` instead.", - migrate: %insert.unlabelledArgument(0) ||| %insert.unlabelledArgument(1), - migrateInPipeChain: BigInt.bitwiseOr(), -}) -external lor: (bigint, bigint) => bigint = "%orbigint" - -/** -`lxor(a, b)` calculates the bitwise XOR of two bigints. - -**Deprecated:** Use `^^^` operator or `bitwiseXor` instead. - -## Examples - -```rescript -BigInt.lxor(7n, 4n) == 3n -``` -*/ -@deprecated({ - reason: "Use `^^^` operator or `bitwiseXor` instead.", - migrate: %insert.unlabelledArgument(0) ^^^ %insert.unlabelledArgument(1), - migrateInPipeChain: BigInt.bitwiseXor(), -}) -external lxor: (bigint, bigint) => bigint = "%xorbigint" - -/** -`lnot(bigint)` calculates the bitwise NOT of a bigint. - -**Deprecated:** Use `~~~` operator or `bitwiseNot` instead. - -## Examples - -```rescript -BigInt.lnot(2n) == -3n -``` -*/ -@deprecated({ - reason: "Use `~~~` operator or `bitwiseNot` instead.", - migrate: ~~~(%insert.unlabelledArgument(0)), - migrateInPipeChain: BigInt.bitwiseNot(), -}) -external lnot: bigint => bigint = "%bitnot_bigint" - -/** -`lsl(bigint, amount)` calculates the shifted value of a bigint by `amount` bits to the left. - -**Deprecated:** Use `<<` operator or `shiftLeft` instead. - -## Examples - -```rescript -BigInt.lsl(4n, 1n) == 8n -``` -*/ -@deprecated({ - reason: "Use `<<` operator or `shiftLeft` instead.", - migrate: %insert.unlabelledArgument(0) << %insert.unlabelledArgument(1), - migrateInPipeChain: BigInt.shiftLeft(), -}) -external lsl: (bigint, bigint) => bigint = "%lslbigint" - -/** -`asr(bigint, amount)` calculates the shifted value of a bigint by `amount` bits to the right. - -**Deprecated:** Use `>>` operator or `shiftRight` instead. - -## Examples - -```rescript -BigInt.asr(8n, 1n) == 4n -``` -*/ -@deprecated({ - reason: "Use `>>` operator or `shiftRight` instead.", - migrate: %insert.unlabelledArgument(0) >> %insert.unlabelledArgument(1), - migrateInPipeChain: BigInt.shiftRight(), -}) -external asr: (bigint, bigint) => bigint = "%asrbigint" diff --git a/packages/@rescript/runtime/Stdlib_BigInt64Array.res b/packages/@rescript/runtime/Stdlib_BigInt64Array.res index 6a637606e3a..cff186e5dba 100644 --- a/packages/@rescript/runtime/Stdlib_BigInt64Array.res +++ b/packages/@rescript/runtime/Stdlib_BigInt64Array.res @@ -28,29 +28,6 @@ external fromArray: array => t = "BigInt64Array" external fromBuffer: (Stdlib_ArrayBuffer.t, ~byteOffset: int=?, ~length: int=?) => t = "BigInt64Array" -/** `fromBufferToEnd` creates a `BigInt64Array` from an `ArrayBuffer.t`, starting at a particular offset and continuing through to the end. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array/BigInt64Array) - -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. -*/ -@deprecated({ - reason: "Use `fromBuffer` instead", - migrate: BigInt64Array.fromBuffer(), -}) -@new -external fromBufferToEnd: (Stdlib_ArrayBuffer.t, ~byteOffset: int) => t = "BigInt64Array" - -/** `fromBufferWithRange` creates a `BigInt64Array` from an `ArrayBuffer.t`, starting at a particular offset and consuming `length` **bytes**. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array/BigInt64Array) - -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. -*/ -@deprecated({ - reason: "Use `fromBuffer` instead", - migrate: BigInt64Array.fromBuffer(), -}) -@new -external fromBufferWithRange: (Stdlib_ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = - "BigInt64Array" - /** `fromLength` creates a zero-initialized `BigInt64Array` to hold the specified count of numbers; this is **not** a byte length. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array/BigInt64Array) **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. @@ -63,15 +40,6 @@ external fromLength: int => t = "BigInt64Array" @val external fromArrayLikeOrIterable: ('a, ~map: ('b, int) => bigint=?) => t = "BigInt64Array.from" -/** `fromArrayLikeOrIterableWithMap` creates a `BigInt64Array` from an array-like or iterable object and applies the mapping function to each item. The mapping function expects (value, index). See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from) -*/ -@deprecated({ - reason: "Use `fromArrayLikeOrIterable` instead", - migrate: BigInt64Array.fromArrayLikeOrIterable(~map=%insert.unlabelledArgument(1)), -}) -@val -external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => bigint) => t = "BigInt64Array.from" - /** `ignore(bigIntArray)` ignores the provided bigIntArray and returns unit. diff --git a/packages/@rescript/runtime/Stdlib_BigUint64Array.res b/packages/@rescript/runtime/Stdlib_BigUint64Array.res index 2a6ff49a5df..b1b505c1268 100644 --- a/packages/@rescript/runtime/Stdlib_BigUint64Array.res +++ b/packages/@rescript/runtime/Stdlib_BigUint64Array.res @@ -28,29 +28,6 @@ external fromArray: array => t = "BigUint64Array" external fromBuffer: (Stdlib_ArrayBuffer.t, ~byteOffset: int=?, ~length: int=?) => t = "BigUint64Array" -/** `fromBufferToEnd` creates a `BigUint64Array` from an `ArrayBuffer.t`, starting at a particular offset and continuing through to the end. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigUint64Array/BigUint64Array) - -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. -*/ -@deprecated({ - reason: "Use `fromBuffer` instead", - migrate: BigUint64Array.fromBuffer(), -}) -@new -external fromBufferToEnd: (Stdlib_ArrayBuffer.t, ~byteOffset: int) => t = "BigUint64Array" - -/** `fromBufferWithRange` creates a `BigUint64Array` from an `ArrayBuffer.t`, starting at a particular offset and consuming `length` **bytes**. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigUint64Array/BigUint64Array) - -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. -*/ -@deprecated({ - reason: "Use `fromBuffer` instead", - migrate: BigUint64Array.fromBuffer(), -}) -@new -external fromBufferWithRange: (Stdlib_ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = - "BigUint64Array" - /** `fromLength` creates a zero-initialized `BigUint64Array` to hold the specified count of numbers; this is **not** a byte length. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigUint64Array/BigUint64Array) **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. @@ -63,18 +40,6 @@ external fromLength: int => t = "BigUint64Array" @val external fromArrayLikeOrIterable: ('a, ~map: ('b, int) => bigint=?) => t = "BigUint64Array.from" -/** `fromArrayLikeOrIterableWithMap` creates a `BigUint64Array` from an array-like or iterable object and applies the mapping function to each item. The mapping function expects (value, index). See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from) -*/ -@deprecated({ - reason: "Use `fromArrayLikeOrIterable` instead", - migrate: BigUint64Array.fromArrayLikeOrIterable( - %insert.unlabelledArgument(0), - ~map=%insert.unlabelledArgument(1), - ), -}) -@val -external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => bigint) => t = "BigUint64Array.from" - /** `ignore(bigUintArray)` ignores the provided bigUintArray and returns unit. diff --git a/packages/@rescript/runtime/Stdlib_Bool.res b/packages/@rescript/runtime/Stdlib_Bool.res index 5120e5229ed..69d27430314 100644 --- a/packages/@rescript/runtime/Stdlib_Bool.res +++ b/packages/@rescript/runtime/Stdlib_Bool.res @@ -22,12 +22,6 @@ let fromStringOrThrow = param => | _ => throw(Invalid_argument(`Bool.fromStringOrThrow: value is neither "true" nor "false"`)) } -@deprecated({ - reason: "Use `fromStringOrThrow` instead", - migrate: Bool.fromStringOrThrow(), -}) -let fromStringExn = fromStringOrThrow - external compare: (bool, bool) => Stdlib_Ordering.t = "%compare" external equal: (bool, bool) => bool = "%equal" diff --git a/packages/@rescript/runtime/Stdlib_Bool.resi b/packages/@rescript/runtime/Stdlib_Bool.resi index 0bd7bb209ed..1a28996cc66 100644 --- a/packages/@rescript/runtime/Stdlib_Bool.resi +++ b/packages/@rescript/runtime/Stdlib_Bool.resi @@ -47,27 +47,6 @@ switch Bool.fromStringOrThrow("notAValidBoolean") { */ let fromStringOrThrow: string => bool -/** -Converts a string to a boolean. -Beware, this function will throw an `Invalid_argument` exception -if the string is not a valid boolean. - -## Examples -```rescript -Bool.fromStringExn("true") == true -Bool.fromStringExn("false") == false -switch Bool.fromStringExn("notAValidBoolean") { -| exception Invalid_argument(_) => assert(true) -| _ => assert(false) -} -``` -*/ -@deprecated({ - reason: "Use `fromStringOrThrow` instead", - migrate: Bool.fromStringOrThrow(), -}) -let fromStringExn: string => bool - /** Compares two booleans, returns an `Ordering.t` value. diff --git a/packages/@rescript/runtime/Stdlib_DataView.res b/packages/@rescript/runtime/Stdlib_DataView.res index b9533aebfe4..20c44eaae0e 100644 --- a/packages/@rescript/runtime/Stdlib_DataView.res +++ b/packages/@rescript/runtime/Stdlib_DataView.res @@ -3,19 +3,6 @@ type t @new external fromBuffer: (Stdlib_ArrayBuffer.t, ~byteOffset: int=?, ~length: int=?) => t = "DataView" -@deprecated({ - reason: "Use `fromBuffer` instead", - migrate: DataView.fromBuffer(), -}) -@new -external fromBufferToEnd: (Stdlib_ArrayBuffer.t, ~byteOffset: int) => t = "DataView" -@deprecated({ - reason: "Use `fromBuffer` instead", - migrate: DataView.fromBuffer(), -}) -@new -external fromBufferWithRange: (Stdlib_ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = - "DataView" @get external buffer: t => Stdlib_ArrayBuffer.t = "buffer" @get external byteLength: t => int = "byteLength" diff --git a/packages/@rescript/runtime/Stdlib_DataView.resi b/packages/@rescript/runtime/Stdlib_DataView.resi index 79bf937c87a..c80c5525fcb 100644 --- a/packages/@rescript/runtime/Stdlib_DataView.resi +++ b/packages/@rescript/runtime/Stdlib_DataView.resi @@ -32,45 +32,6 @@ DataView.fromBuffer(ArrayBuffer.make(16), ~byteOffset=4, ~length=8) @new external fromBuffer: (Stdlib_ArrayBuffer.t, ~byteOffset: int=?, ~length: int=?) => t = "DataView" -/** -`fromBufferToEnd(buffer, ~byteOffset)` creates a DataView starting at a given byte offset. See [`DataView`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView) on MDN. - -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. - -## Examples - -```rescript -DataView.fromBufferToEnd(buffer, ~byteOffset=4) -``` -*/ -@deprecated({ - reason: "Use `fromBuffer` instead", - migrate: DataView.fromBuffer(~byteOffset=%insert.labelledArgument("byteOffset")), -}) -@new -external fromBufferToEnd: (Stdlib_ArrayBuffer.t, ~byteOffset: int) => t = "DataView" - -/** -`fromBufferWithRange(buffer, ~byteOffset, ~length)` creates a DataView for a specific byte range. - -See [`DataView`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView) on MDN. - -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. - -## Examples - -```rescript -DataView.fromBufferWithRange(ArrayBuffer.make(16), ~byteOffset=2, ~length=8) -``` -*/ -@deprecated({ - reason: "Use `fromBuffer` instead", - migrate: DataView.fromBuffer(), -}) -@new -external fromBufferWithRange: (Stdlib_ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = - "DataView" - /** `buffer(dataView)` returns the underlying ArrayBuffer referenced by this DataView. diff --git a/packages/@rescript/runtime/Stdlib_Error.res b/packages/@rescript/runtime/Stdlib_Error.res deleted file mode 100644 index aaf799a143f..00000000000 --- a/packages/@rescript/runtime/Stdlib_Error.res +++ /dev/null @@ -1,47 +0,0 @@ -type t = Stdlib_Exn.t - -let fromException: exn => option = exn => - switch Obj.magic(exn) { - | Stdlib_Exn.Error(t) => Some(t) - | _ => None - } -external toException: t => exn = "%identity" - -@get external stack: t => option = "stack" -@get external message: t => option = "message" -@get external name: t => option = "name" -@get external fileName: t => option = "fileName" - -@new external make: string => t = "Error" - -module EvalError = { - @new external make: string => t = "EvalError" -} - -module RangeError = { - @new external make: string => t = "RangeError" -} - -module ReferenceError = { - @new external make: string => t = "ReferenceError" -} - -module SyntaxError = { - @new external make: string => t = "SyntaxError" -} - -module TypeError = { - @new external make: string => t = "TypeError" -} - -module URIError = { - @new external make: string => t = "URIError" -} - -external raise: t => 'a = "%raise" - -external throw: t => 'a = "%raise" - -let panic = msg => make(`Panic! ${msg}`)->raise - -external ignore: t => unit = "%ignore" diff --git a/packages/@rescript/runtime/Stdlib_Error.resi b/packages/@rescript/runtime/Stdlib_Error.resi deleted file mode 100644 index 86327ba7130..00000000000 --- a/packages/@rescript/runtime/Stdlib_Error.resi +++ /dev/null @@ -1,277 +0,0 @@ -/*** -Functions for working with JavaScript exceptions. - -See [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) on MDN. -*/ -@@deprecated("Use `JsError` module") - -/** Represents a JavaScript exception. */ -@deprecated({ - reason: "Use `JsError.t` instead", - migrate: %replace.type(: JsError.t), -}) -type t = Stdlib_Exn.t - -@deprecated({ - reason: "Use `JsExn.fromException` instead", - migrate: JsExn.fromException(), -}) -let fromException: exn => option - -/** -Turns an `Error.t` into an `exn`. - -## Examples -```rescript -let error = Error.make("Something went wrong.") - -let asExn = error->Error.toException // `asExn` is now type `exn` -``` -*/ -@deprecated("Use functions from `JsExn` instead") -external toException: t => exn = "%identity" - -/** -`stack(error)` retrieves the `stack` property of the error, if it exists. The stack is a list of what functions were called, and what files they are defined in, prior to the error happening. - -See [`Error.prototype.stack`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Stack) on MDN. - -## Example -```rescript -let error = Error.make("error") -Console.log(error->Error.stack) // Logs `stack` if it exists on `someError` -``` -*/ -@deprecated({ - reason: "Use `JsError.stack` instead", - migrate: JsError.stack(), -}) -@get -external stack: t => option = "stack" - -/** -`message(error)` retrieves the `message` property of the error, if it exists. - -See [`Error.prototype.message`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/message) on MDN. - -## Example -```rescript -let error = Error.SyntaxError.make("Some message here") -Console.log(error->Error.message) // Logs "Some message here" to the console -``` -*/ -@deprecated({ - reason: "Use `JsError.message` instead", - migrate: JsError.message(), -}) -@get -external message: t => option = "message" - -/** -`name(error)` retrieves the `name` property of the error, if it exists. - -See [`Error.prototype.name`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name) on MDN. - -## Example -```rescript -let error = Error.SyntaxError.make("Some message here") -Console.log(error->Error.name) // Logs "SyntaxError" to the console -``` -*/ -@deprecated({ - reason: "Use `JsError.name` instead", - migrate: JsError.name(), -}) -@get -external name: t => option = "name" - -/** -`fileName(error)` retrieves the `fileName` property of the error, if it exists. - -See [`Error.prototype.fileName`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/fileName) on MDN. -*/ -@deprecated({ - reason: "Use `JsError.fileName` instead", - migrate: JsError.fileName(), -}) -@get -external fileName: t => option = "fileName" - -/** -`make(message)` creates a new error, setting its `message` to the provided value. - -See [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Error) on MDN. - -## Example -```rescript -let error = Error.make("Some message here") -Console.log(error->Error.message) // Logs "Some message here" to the console -Console.log(error->Error.name) // Logs "Error" to the console, because this is a regular error -``` -*/ -@deprecated({ - reason: "Use `JsError.make` instead", - migrate: JsError.make(), -}) -@new -external make: string => t = "Error" - -module EvalError: { - /** - Creates a new `EvalError` with the provided `message`. - - See [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) on MDN. - */ - @deprecated({ - reason: "Use `JsError.EvalError.make` instead", - migrate: JsError.EvalError.make(), - }) - @new - external make: string => t = "EvalError" -} -module RangeError: { - /** - Creates a new `RangeError` with the provided `message`. - - See [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) on MDN. - */ - @deprecated({ - reason: "Use `JsError.RangeError.make` instead", - migrate: JsError.RangeError.make(), - }) - @new - external make: string => t = "RangeError" -} -module ReferenceError: { - /** - Creates a new `ReferenceError` with the provided `message`. - - See [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) on MDN. - */ - @deprecated({ - reason: "Use `JsError.ReferenceError.make` instead", - migrate: JsError.ReferenceError.make(), - }) - @new - external make: string => t = "ReferenceError" -} -module SyntaxError: { - /** - Creates a new `SyntaxError` with the provided `message`. - - See [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) on MDN. - */ - @deprecated({ - reason: "Use `JsError.SyntaxError.make` instead", - migrate: JsError.SyntaxError.make(), - }) - @new - external make: string => t = "SyntaxError" -} -module TypeError: { - /** - Creates a new `TypeError` with the provided `message`. - - See [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) on MDN. - */ - @deprecated({ - reason: "Use `JsError.TypeError.make` instead", - migrate: JsError.TypeError.make(), - }) - @new - external make: string => t = "TypeError" -} -module URIError: { - /** - Creates a new `URIError` with the provided `message`. - - See [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError) on MDN. - */ - @deprecated({ - reason: "Use `JsError.URIError.make` instead", - migrate: JsError.URIError.make(), - }) - @new - external make: string => t = "URIError" -} - -/** -Raises (throws in JavaScript language) the provided `Error.t`, which will stop execution. - -## Examples -```rescript -let error = Error.make("Everything is upside down.") - -if 5 > 10 { - error->Error.raise -} else { - Console.log("Phew, sanity still rules.") -} -``` -*/ -@deprecated({ - reason: "`raise` has been renamed to `throw` to align with JavaScript vocabulary. Please use `JsError.throw` instead", - migrate: JsError.throw(), -}) -external raise: t => 'a = "%raise" - -/** -Throws the given exception, terminating execution unless caught by a surrounding try/catch block. - -## Examples - -```rescript -let error = Error.make("Everything is upside down.") - -if 5 > 10 { - Error.throw(error) -} else { - Console.log("Phew, sanity still rules.") -} -``` -*/ -@deprecated({ - reason: "Use `JsError.throw` instead", - migrate: JsError.throw(), -}) -external throw: t => 'a = "%raise" - -/** -Throws a panic exception with the given message. - -A panic exception is a native JavaScript exception that is not intended to be caught and -handled. Compared to a ReScript exception this will give a better stack trace and -debugging experience. - -## Examples - -```rescript -try { - Error.panic("Uh oh. This was unexpected!") -} catch { -| Exn.Error(obj) => - switch Exn.message(obj) { - | Some(m) => assert(m == "Panic! Uh oh. This was unexpected!") - | None => assert(false) - } -| _ => assert(false) -} -``` -*/ -@deprecated({ - reason: "Use `JsError.panic` instead", - migrate: JsError.panic(), -}) -let panic: string => 'a - -/** - `ignore(error)` ignores the provided error and returns unit. - - This helper is useful when you want to discard a value (for example, the result of an operation with side effects) - without having to store or process it further. -*/ -@deprecated({ - reason: "Use `JsError.ignore` instead", - migrate: JsError.ignore(), -}) -external ignore: t => unit = "%ignore" diff --git a/packages/@rescript/runtime/Stdlib_Exn.res b/packages/@rescript/runtime/Stdlib_Exn.res deleted file mode 100644 index 65629c01a08..00000000000 --- a/packages/@rescript/runtime/Stdlib_Exn.res +++ /dev/null @@ -1,75 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -type t = unknown - -@@warning("-38") /* unused extension constructor */ -exception Error = JsExn - -let asJsExn: exn => option = exn => - switch Obj.magic(exn) { - | Error(t) => Some(t) - | _ => None - } - -@get external stack: t => option = "stack" -@get external message: t => option = "message" -@get external name: t => option = "name" -@get external fileName: t => option = "fileName" - -type error -@new external makeError: string => error = "Error" - -let anyToExnInternal = (x: 'a): exn => - Primitive_exceptions.internalToException((Obj.magic(x): unknown)) - -let raiseError = str => throw((Obj.magic((makeError(str): error)): exn)) - -type eval_error -@new external makeEvalError: string => eval_error = "EvalError" - -let raiseEvalError = str => throw((Obj.magic((makeEvalError(str): eval_error)): exn)) - -type range_error -@new external makeRangeError: string => range_error = "RangeError" - -let raiseRangeError = str => throw((Obj.magic((makeRangeError(str): range_error)): exn)) - -type reference_error - -@new external makeReferenceError: string => reference_error = "ReferenceError" - -let raiseReferenceError = str => throw(Obj.magic(makeReferenceError(str))) - -type syntax_error -@new external makeSyntaxError: string => syntax_error = "SyntaxError" - -let raiseSyntaxError = str => throw(Obj.magic(makeSyntaxError(str))) - -type type_error -@new external makeTypeError: string => type_error = "TypeError" - -let raiseTypeError = str => throw(Obj.magic(makeTypeError(str))) - -type uri_error -@new external makeURIError: string => uri_error = "URIError" - -let raiseUriError = str => throw(Obj.magic(makeURIError(str))) - -/* TODO add predicate to tell which error is which " */ - -/* -exception EvalError of error -exception RangeError of error -exception ReferenceError of error -exception SyntaxError of error -exception TypeError of error - - The URIError object represents an error when a global URI handling function was used in a wrong way. -exception URIError of error -*/ - -external ignore: t => unit = "%ignore" diff --git a/packages/@rescript/runtime/Stdlib_Exn.resi b/packages/@rescript/runtime/Stdlib_Exn.resi deleted file mode 100644 index ea5443b3d55..00000000000 --- a/packages/@rescript/runtime/Stdlib_Exn.resi +++ /dev/null @@ -1,122 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -/*** -Provide utilities for dealing with JS exceptions. -*/ -@@deprecated("Use `JsExn` module") - -/** Represents a JS exception */ -@deprecated({ - reason: "Use `JsExn.t` instead", - migrate: %replace.type(: JsExn.t), -}) -type t - -type exn += - private - | @deprecated({ - reason: "Use `JsExn` instead", - migrate: %replace.constructor(JsExn), - }) - Error(t) - -@deprecated({ - reason: "Use `JsExn.fromException` instead", - migrate: JsExn.fromException(), -}) -let asJsExn: exn => option - -@deprecated({ - reason: "Use `JsExn.stack` instead", - migrate: JsExn.stack(), -}) -@get -external stack: t => option = "stack" -@deprecated({ - reason: "Use `JsExn.message` instead", - migrate: JsExn.message(), -}) -@get -external message: t => option = "message" -@deprecated({ - reason: "Use `JsExn.name` instead", - migrate: JsExn.name(), -}) -@get -external name: t => option = "name" -@deprecated({ - reason: "Use `JsExn.fileName` instead", - migrate: JsExn.fileName(), -}) -@get -external fileName: t => option = "fileName" - -/** -`anyToExnInternal(obj)` will take any value `obj` and wrap it -in a Exn.Error if given value is not an exn already. If -`obj` is an exn, it will return `obj` without any changes. - -This function is mostly useful for cases where you want to unify a type of a value -that potentially is either exn, a JS error, or any other JS value really (e.g. for -a value passed to a Promise.catch callback) - -**IMPORTANT**: This is an internal API and may be changed / removed any time in the future. -*/ -@deprecated({ - reason: "Use `JsExn.anyToExnInternal` instead", - migrate: JsExn.anyToExnInternal(), -}) -let anyToExnInternal: 'a => exn - -/** Raise Js exception Error object with stacktrace */ -@deprecated({ - reason: "Use `JsError.throwWithMessage` instead", - migrate: JsError.throwWithMessage(), -}) -let raiseError: string => 'a -@deprecated({ - reason: "Use `JsError.EvalError.throwWithMessage` instead", - migrate: JsError.EvalError.throwWithMessage(), -}) -let raiseEvalError: string => 'a -@deprecated({ - reason: "Use `JsError.RangeError.throwWithMessage` instead", - migrate: JsError.RangeError.throwWithMessage(), -}) -let raiseRangeError: string => 'a -@deprecated({ - reason: "Use `JsError.ReferenceError.throwWithMessage` instead", - migrate: JsError.ReferenceError.throwWithMessage(), -}) -let raiseReferenceError: string => 'a -@deprecated({ - reason: "Use `JsError.SyntaxError.throwWithMessage` instead", - migrate: JsError.SyntaxError.throwWithMessage(), -}) -let raiseSyntaxError: string => 'a -@deprecated({ - reason: "Use `JsError.TypeError.throwWithMessage` instead", - migrate: JsError.TypeError.throwWithMessage(), -}) -let raiseTypeError: string => 'a -@deprecated({ - reason: "Use `JsError.URIError.throwWithMessage` instead", - migrate: JsError.URIError.throwWithMessage(), -}) -let raiseUriError: string => 'a - -/** - `ignore(exn)` ignores the provided exn and returns unit. - - This helper is useful when you want to discard a value (for example, the result of an operation with side effects) - without having to store or process it further. -*/ -@deprecated({ - reason: "Use `JsExn.ignore` instead", - migrate: JsExn.ignore(), -}) -external ignore: t => unit = "%ignore" diff --git a/packages/@rescript/runtime/Stdlib_Float.res b/packages/@rescript/runtime/Stdlib_Float.res index 1843b5f443e..82c6b7fed86 100644 --- a/packages/@rescript/runtime/Stdlib_Float.res +++ b/packages/@rescript/runtime/Stdlib_Float.res @@ -18,44 +18,14 @@ external compare: (float, float) => Stdlib_Ordering.t = "%compare" @val external parseFloat: 'a => float = "parseFloat" // parseInt's return type is a float because it can be NaN @val external parseInt: ('a, ~radix: int=?) => float = "parseInt" -@deprecated({ - reason: "Use `parseInt` instead", - migrate: Float.parseInt(), -}) -@val -external parseIntWithRadix: ('a, ~radix: int) => float = "parseInt" @send external toExponential: (float, ~digits: int=?) => string = "toExponential" -@deprecated({ - reason: "Use `toExponential` instead", - migrate: Float.toExponential(), -}) -@send -external toExponentialWithPrecision: (float, ~digits: int) => string = "toExponential" @send external toFixed: (float, ~digits: int=?) => string = "toFixed" -@deprecated({ - reason: "Use `toFixed` instead", - migrate: Float.toFixed(), -}) -@send -external toFixedWithPrecision: (float, ~digits: int) => string = "toFixed" @send external toPrecision: (float, ~digits: int=?) => string = "toPrecision" -@deprecated({ - reason: "Use `toPrecision` instead", - migrate: Float.toPrecision(), -}) -@send -external toPrecisionWithPrecision: (float, ~digits: int) => string = "toPrecision" @send external toString: (float, ~radix: int=?) => string = "toString" -@deprecated({ - reason: "Use `toString` instead", - migrate: Float.toString(), -}) -@send -external toStringWithRadix: (float, ~radix: int) => string = "toString" @send external toLocaleString: float => string = "toLocaleString" let fromString: string => option = %raw(`str => { diff --git a/packages/@rescript/runtime/Stdlib_Float.resi b/packages/@rescript/runtime/Stdlib_Float.resi index ed8c6490285..6ea17339168 100644 --- a/packages/@rescript/runtime/Stdlib_Float.resi +++ b/packages/@rescript/runtime/Stdlib_Float.resi @@ -192,30 +192,6 @@ Float.parseInt("17", ~radix=40)->Float.isNaN == true @val external parseInt: ('a, ~radix: int=?) => float = "parseInt" -/** -`parseIntWithRadix(v, ~radix)` parse the given `v` and returns a float. Leading -whitespace in this argument `v`is ignored. `radix` specifies the radix base to -use for the formatted number. The value must be in the range \[2, 36\] (inclusive). -Returns `NaN` if `v` can't be parsed and `radix` is smaller than 2 or bigger -than 36. -See [`parseInt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt) on MDN. - -## Examples - -```rescript -Float.parseIntWithRadix("10.0", ~radix=2) == 2.0 -Float.parseIntWithRadix("15 * 3", ~radix=10) == 15.0 -Float.parseIntWithRadix("12", ~radix=13) == 15.0 -Float.parseIntWithRadix("17", ~radix=40)->Float.isNaN == true -``` -*/ -@deprecated({ - reason: "Use `parseInt` instead", - migrate: Float.parseInt(), -}) -@val -external parseIntWithRadix: ('a, ~radix: int) => float = "parseInt" - /** `toExponential(v, ~digits=?)` return a `string` representing the given value in exponential notation. `digits` specifies how many digits should appear after @@ -238,30 +214,6 @@ Float.toExponential(5678.0, ~digits=2) == "5.68e+3" @send external toExponential: (float, ~digits: int=?) => string = "toExponential" -/** -`toExponential(v, ~digits)` return a `string` representing the given value in -exponential notation. `digits` specifies how many digits should appear after -the decimal point. -See [`Number.toExponential`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential) on MDN. - -## Examples - -```rescript -Float.toExponentialWithPrecision(77.0, ~digits=2) == "7.70e+1" -Float.toExponentialWithPrecision(5678.0, ~digits=2) == "5.68e+3" -``` - -## Exceptions - -- `RangeError`: If `digits` less than 0 or greater than 10. -*/ -@deprecated({ - reason: "Use `toExponential` instead", - migrate: Float.toExponential(), -}) -@send -external toExponentialWithPrecision: (float, ~digits: int) => string = "toExponential" - /** `toFixed(v, ~digits=?)` return a `string` representing the given value using fixed-point notation. `digits` specifies how many digits should @@ -284,30 +236,6 @@ Float.toFixed(300.0, ~digits=1) == "300.0" @send external toFixed: (float, ~digits: int=?) => string = "toFixed" -/** -`toFixedWithPrecision(v, ~digits)` return a `string` representing the given -value using fixed-point notation. `digits` specifies how many digits should -appear after the decimal point. -See [`Number.toFixed`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed) on MDN. - -## Examples - -```rescript -Float.toFixedWithPrecision(300.0, ~digits=4) == "300.0000" -Float.toFixedWithPrecision(300.0, ~digits=1) == "300.0" -``` - -## Exceptions - -- `RangeError`: If `digits` is less than 0 or larger than 100. -*/ -@deprecated({ - reason: "Use `toFixed` instead", - migrate: Float.toFixed(), -}) -@send -external toFixedWithPrecision: (float, ~digits: int) => string = "toFixed" - /** `toPrecision(v, ~digits=?)` return a `string` representing the giver value with precision. `digits` specifies the number of significant digits. @@ -331,32 +259,6 @@ Float.toPrecision(1.0, ~digits=1) == "1" @send external toPrecision: (float, ~digits: int=?) => string = "toPrecision" -/** -`toPrecisionWithPrecision(v, ~digits)` return a `string` representing the giver value with -precision. `digits` specifies the number of significant digits. -See [`Number.toPrecision`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision) on MDN. - -## Examples - -```rescript -Float.toPrecisionWithPrecision(100.0, ~digits=2) == "1.0e+2" -Float.toPrecisionWithPrecision(1.0, ~digits=1) == "1" -``` - -## Exceptions - -- `RangeError`: If `digits` is not between 1 and 100 (inclusive). - Implementations are allowed to support larger and smaller values as well. - ECMA-262 only requires a precision of up to 21 significant digits. - -*/ -@deprecated({ - reason: "Use `toPrecision` instead", - migrate: Float.toPrecision(), -}) -@send -external toPrecisionWithPrecision: (float, ~digits: int) => string = "toPrecision" - /** `toString(v)` return a `string` representing the given value. See [`Number.toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString) on MDN. @@ -371,30 +273,6 @@ Float.toString(-1000.0) == "-1000" @send external toString: (float, ~radix: int=?) => string = "toString" -/** -`toStringWithRadix(v, ~radix)` return a `string` representing the given value. -`~radix` specifies the radix base to use for the formatted number. -See [`Number.toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString) on MDN. - -## Examples - -```rescript -Float.toStringWithRadix(6.0, ~radix=2) == "110" -Float.toStringWithRadix(3735928559.0, ~radix=16) == "deadbeef" -Float.toStringWithRadix(123456.0, ~radix=36) == "2n9c" -``` - -## Exceptions - -`RangeError`: if `radix` is less than 2 or greater than 36. -*/ -@deprecated({ - reason: "Use `toString` with `~radix` instead", - migrate: Float.toString(), -}) -@send -external toStringWithRadix: (float, ~radix: int) => string = "toString" - /** `toLocaleString(v)` return a `string` with language-sensitive representing the given value. diff --git a/packages/@rescript/runtime/Stdlib_Float32Array.res b/packages/@rescript/runtime/Stdlib_Float32Array.res index 1874ad8ec28..bdff38c3012 100644 --- a/packages/@rescript/runtime/Stdlib_Float32Array.res +++ b/packages/@rescript/runtime/Stdlib_Float32Array.res @@ -28,29 +28,6 @@ external fromArray: array => t = "Float32Array" external fromBuffer: (Stdlib_ArrayBuffer.t, ~byteOffset: int=?, ~length: int=?) => t = "Float32Array" -/** `fromBufferToEnd` creates a `Float32Array` from an `ArrayBuffer.t`, starting at a particular offset and continuing through to the end. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array/Float32Array) - -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. -*/ -@deprecated({ - reason: "Use `fromBuffer` instead", - migrate: Float32Array.fromBuffer(), -}) -@new -external fromBufferToEnd: (Stdlib_ArrayBuffer.t, ~byteOffset: int) => t = "Float32Array" - -/** `fromBufferWithRange` creates a `Float32Array` from an `ArrayBuffer.t`, starting at a particular offset and consuming `length` **bytes**. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array/Float32Array) - -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. -*/ -@deprecated({ - reason: "Use `fromBuffer` instead", - migrate: Float32Array.fromBuffer(), -}) -@new -external fromBufferWithRange: (Stdlib_ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = - "Float32Array" - /** `fromLength` creates a zero-initialized `Float32Array` to hold the specified count of numbers; this is **not** a byte length. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array/Float32Array) **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. @@ -63,18 +40,6 @@ external fromLength: int => t = "Float32Array" @val external fromArrayLikeOrIterable: ('a, ~map: ('b, int) => float=?) => t = "Float32Array.from" -/** `fromArrayLikeOrIterableWithMap` creates a `Float32Array` from an array-like or iterable object and applies the mapping function to each item. The mapping function expects (value, index). See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from) -*/ -@deprecated({ - reason: "Use `fromArrayLikeOrIterable` instead", - migrate: Float32Array.fromArrayLikeOrIterable( - %insert.unlabelledArgument(0), - ~map=%insert.unlabelledArgument(1), - ), -}) -@val -external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => float) => t = "Float32Array.from" - /** `ignore(floatArray)` ignores the provided floatArray and returns unit. diff --git a/packages/@rescript/runtime/Stdlib_Float64Array.res b/packages/@rescript/runtime/Stdlib_Float64Array.res index 255b0601b9b..1b256403b1e 100644 --- a/packages/@rescript/runtime/Stdlib_Float64Array.res +++ b/packages/@rescript/runtime/Stdlib_Float64Array.res @@ -28,29 +28,6 @@ external fromArray: array => t = "Float64Array" external fromBuffer: (Stdlib_ArrayBuffer.t, ~byteOffset: int=?, ~length: int=?) => t = "Float64Array" -/** `fromBufferToEnd` creates a `Float64Array` from an `ArrayBuffer.t`, starting at a particular offset and continuing through to the end. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array/Float64Array) - -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. -*/ -@deprecated({ - reason: "Use `fromBuffer` instead", - migrate: Float64Array.fromBuffer(), -}) -@new -external fromBufferToEnd: (Stdlib_ArrayBuffer.t, ~byteOffset: int) => t = "Float64Array" - -/** `fromBufferWithRange` creates a `Float64Array` from an `ArrayBuffer.t`, starting at a particular offset and consuming `length` **bytes**. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array/Float64Array) - -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. -*/ -@deprecated({ - reason: "Use `fromBuffer` instead", - migrate: Float64Array.fromBuffer(), -}) -@new -external fromBufferWithRange: (Stdlib_ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = - "Float64Array" - /** `fromLength` creates a zero-initialized `Float64Array` to hold the specified count of numbers; this is **not** a byte length. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array/Float64Array) **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. @@ -63,18 +40,6 @@ external fromLength: int => t = "Float64Array" @val external fromArrayLikeOrIterable: ('a, ~map: ('b, int) => float=?) => t = "Float64Array.from" -/** `fromArrayLikeOrIterableWithMap` creates a `Float64Array` from an array-like or iterable object and applies the mapping function to each item. The mapping function expects (value, index). See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from) -*/ -@deprecated({ - reason: "Use `fromArrayLikeOrIterable` instead", - migrate: Float64Array.fromArrayLikeOrIterable( - %insert.unlabelledArgument(0), - ~map=%insert.unlabelledArgument(1), - ), -}) -@val -external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => float) => t = "Float64Array.from" - /** `ignore(floatArray)` ignores the provided floatArray and returns unit. diff --git a/packages/@rescript/runtime/Stdlib_Int.res b/packages/@rescript/runtime/Stdlib_Int.res index c7bcccf079c..eee7b0ba8d1 100644 --- a/packages/@rescript/runtime/Stdlib_Int.res +++ b/packages/@rescript/runtime/Stdlib_Int.res @@ -10,36 +10,12 @@ external equal: (int, int) => bool = "%equal" external compare: (int, int) => Stdlib_Ordering.t = "%compare" @send external toExponential: (int, ~digits: int=?) => string = "toExponential" -@deprecated({ - reason: "Use `toExponential` instead", - migrate: Int.toExponential(), -}) -@send -external toExponentialWithPrecision: (int, ~digits: int) => string = "toExponential" @send external toFixed: (int, ~digits: int=?) => string = "toFixed" -@deprecated({ - reason: "Use `toFixed` instead", - migrate: Int.toFixed(), -}) -@send -external toFixedWithPrecision: (int, ~digits: int) => string = "toFixed" @send external toPrecision: (int, ~digits: int=?) => string = "toPrecision" -@deprecated({ - reason: "Use `toPrecision` instead", - migrate: Int.toPrecision(), -}) -@send -external toPrecisionWithPrecision: (int, ~digits: int) => string = "toPrecision" @send external toString: (int, ~radix: int=?) => string = "toString" -@deprecated({ - reason: "Use `toString` instead", - migrate: Int.toString(), -}) -@send -external toStringWithRadix: (int, ~radix: int) => string = "toString" @send external toLocaleString: int => string = "toLocaleString" external toFloat: int => float = "%identity" @@ -69,7 +45,7 @@ let range = (start, end, ~options: rangeOptions={}) => { let step = switch options.step { | None => isInverted ? -1 : 1 | Some(0) if start !== end => - Stdlib_Error.throw(Stdlib_Error.RangeError.make("Incorrect range arguments")) + Stdlib_JsError.throw(Stdlib_JsError.RangeError.make("Incorrect range arguments")) | Some(n) => n } @@ -86,13 +62,6 @@ let range = (start, end, ~options: rangeOptions={}) => { Stdlib_Array.fromInitializer(~length, i => start + i * step) } -@deprecated({ - reason: "Use `range` instead", - migrate: Int.range(~options=%insert.unlabelledArgument(2)), -}) -@send -let rangeWithOptions = (start, end, options) => range(start, end, ~options) - let clamp = (~min=?, ~max=?, value): int => { let value = switch max { | Some(max) if max < value => max @@ -114,16 +83,4 @@ external shiftLeft: (int, int) => int = "%lslint" external shiftRight: (int, int) => int = "%asrint" external shiftRightUnsigned: (int, int) => int = "%lsrint" -module Bitwise = { - external land: (int, int) => int = "%andint" - external lor: (int, int) => int = "%orint" - external lxor: (int, int) => int = "%xorint" - - external lsl: (int, int) => int = "%lslint" - external lsr: (int, int) => int = "%lsrint" - external asr: (int, int) => int = "%asrint" - - let lnot = x => lxor(x, -1) -} - external ignore: int => unit = "%ignore" diff --git a/packages/@rescript/runtime/Stdlib_Int.resi b/packages/@rescript/runtime/Stdlib_Int.resi index bd71f41fc21..0b95289be97 100644 --- a/packages/@rescript/runtime/Stdlib_Int.resi +++ b/packages/@rescript/runtime/Stdlib_Int.resi @@ -68,30 +68,6 @@ Int.toExponential(5678, ~digits=2) // "5.68e+3" @send external toExponential: (int, ~digits: int=?) => string = "toExponential" -/** -`toExponential(n, ~digits)` return a `string` representing the given value in -exponential notation. `digits` specifies how many digits should appear after -the decimal point. See [`Number.toExponential`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential) -on MDN. - -## Examples - -```rescript -Int.toExponentialWithPrecision(77, ~digits=2) // "7.70e+1" -Int.toExponentialWithPrecision(5678, ~digits=2) // "5.68e+3" -``` - -## Exceptions - -- `RangeError`: If `digits` less than 0 or greater than 10. -*/ -@deprecated({ - reason: "Use `toExponential` instead", - migrate: Int.toExponential(), -}) -@send -external toExponentialWithPrecision: (int, ~digits: int) => string = "toExponential" - /** `toFixed(n, ~digits=?)` return a `string` representing the given value using fixed-point notation. `digits` specifies how many digits should @@ -114,30 +90,6 @@ Int.toFixed(300, ~digits=1) // "300.0" @send external toFixed: (int, ~digits: int=?) => string = "toFixed" -/** -`toFixedWithPrecision(n, ~digits)` return a `string` representing the given -value using fixed-point notation. `digits` specifies how many digits should -appear after the decimal point. See [`Number.toFixed`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed) -on MDN. - -## Examples - -```rescript -Int.toFixedWithPrecision(300, ~digits=4) // "300.0000" -Int.toFixedWithPrecision(300, ~digits=1) // "300.0" -``` - -## Exceptions - -- `RangeError`: If `digits` is less than 0 or larger than 100. -*/ -@deprecated({ - reason: "Use `toFixed` instead", - migrate: Int.toFixed(), -}) -@send -external toFixedWithPrecision: (int, ~digits: int) => string = "toFixed" - /** `toPrecision(n, ~digits=?)` return a `string` representing the giver value with precision. `digits` specifies the number of significant digits. See [`Number.toPrecision`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision) on MDN. @@ -160,30 +112,6 @@ Int.toPrecision(1, ~digits=2) // "1.0" @send external toPrecision: (int, ~digits: int=?) => string = "toPrecision" -/** -`toPrecisionWithPrecision(n, ~digits)` return a `string` representing the giver value with -precision. `digits` specifies the number of significant digits. See [`Number.toPrecision`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision) on MDN. - -## Examples - -```rescript -Int.toPrecisionWithPrecision(100, ~digits=2) // "1.0e+2" -Int.toPrecisionWithPrecision(1, ~digits=2) // "1.0" -``` - -## Exceptions - -- `RangeError`: If `digits` is not between 1 and 100 (inclusive). - Implementations are allowed to support larger and smaller values as well. - ECMA-262 only requires a precision of up to 21 significant digits. -*/ -@send -@deprecated({ - reason: "Use `toPrecision` instead", - migrate: Int.toPrecision(), -}) -external toPrecisionWithPrecision: (int, ~digits: int) => string = "toPrecision" - /** `toString(n, ~radix=?)` return a `string` representing the given value. `~radix` specifies the radix base to use for the formatted number. @@ -207,31 +135,6 @@ Int.toString(123456, ~radix=36) // "2n9c" @send external toString: (int, ~radix: int=?) => string = "toString" -/** -`toStringWithRadix(n, ~radix)` return a `string` representing the given value. -`~radix` specifies the radix base to use for the formatted number. -See [`Number.toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString) -on MDN. - -## Examples - -```rescript -Int.toStringWithRadix(6, ~radix=2) // "110" -Int.toStringWithRadix(373592855, ~radix=16) // "16449317" -Int.toStringWithRadix(123456, ~radix=36) // "2n9c" -``` - -## Exceptions - -`RangeError`: if `radix` is less than 2 or greater than 36. -*/ -@deprecated({ - reason: "Use `toString` instead", - migrate: Int.toString(), -}) -@send -external toStringWithRadix: (int, ~radix: int) => string = "toString" - /** `toLocaleString(n)` return a `string` with language-sensitive representing the given value. See [`Number.toLocaleString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString) on MDN. @@ -343,38 +246,6 @@ Int.range(3, 6, ~options={step: -2}) // RangeError */ let range: (int, int, ~options: rangeOptions=?) => array -/** -`rangeWithOptions(start, end, options)` is like `range`, but with `step` and -`inclusive` options configurable. - -If `step` is set, the sequence will increase or decrease by that amount for each -step. If `start < end` and `step` is negative, or vice versa, an empty array is -returned since the sequence would otherwise never reach or exceed the end value -and hence be infinite. If `step` is `0` and `start !=` end, a `RangeError` is -raised as the sequence would never reach or exceed the end value and hence be -infinite. - -If `inclusive` is set to `true`, the sequence will include `end` if `step` is -set such that the sequence includes it. - -## Examples - -```rescript -Int.rangeWithOptions(3, 7, {step: 2}) == [3, 5] -Int.rangeWithOptions(3, 7, {step: 2, inclusive: true}) == [3, 5, 7] -Int.rangeWithOptions(3, 6, {step: -2}) // RangeError -``` - -## Exceptions - -- Raises `RangeError` if `step == 0 && start != end`. -*/ -@deprecated({ - reason: "Use `range` instead", - migrate: Int.range(~options=%insert.unlabelledArgument(2)), -}) -let rangeWithOptions: (int, int, rangeOptions) => array - /** `clamp(~min=?, ~max=?, value)` returns `value`, optionally bounded by `min` and `max`. @@ -473,46 +344,6 @@ Int.shiftRightUnsigned(4, 1) == 2 */ external shiftRightUnsigned: (int, int) => int = "%lsrint" -module Bitwise: { - @deprecated({ - reason: "Use `Int.bitwiseAnd` instead", - migrate: Int.bitwiseAnd(), - }) - external land: (int, int) => int = "%andint" - @deprecated({ - reason: "Use `Int.bitwiseOr` instead", - migrate: Int.bitwiseOr(), - }) - external lor: (int, int) => int = "%orint" - @deprecated({ - reason: "Use `Int.bitwiseXor` instead", - migrate: Int.bitwiseXor(), - }) - external lxor: (int, int) => int = "%xorint" - - @deprecated({ - reason: "Use `Int.shiftLeft` instead", - migrate: Int.shiftLeft(), - }) - external lsl: (int, int) => int = "%lslint" - @deprecated({ - reason: "Use `Int.shiftRightUnsigned` instead", - migrate: Int.shiftRightUnsigned(), - }) - external lsr: (int, int) => int = "%lsrint" - @deprecated({ - reason: "Use `Int.shiftRight` instead", - migrate: Int.shiftRight(), - }) - external asr: (int, int) => int = "%asrint" - - @deprecated({ - reason: "Use `Int.bitwiseNot` instead", - migrate: Int.bitwiseNot(), - }) - let lnot: int => int -} - /** `ignore(int)` ignores the provided int and returns unit. diff --git a/packages/@rescript/runtime/Stdlib_Int16Array.res b/packages/@rescript/runtime/Stdlib_Int16Array.res index 4c77496b4ff..a7d8db87bfe 100644 --- a/packages/@rescript/runtime/Stdlib_Int16Array.res +++ b/packages/@rescript/runtime/Stdlib_Int16Array.res @@ -27,29 +27,6 @@ external fromArray: array => t = "Int16Array" @new external fromBuffer: (Stdlib_ArrayBuffer.t, ~byteOffset: int=?, ~length: int=?) => t = "Int16Array" -/** `fromBufferToEnd` creates a `Int16Array` from an `ArrayBuffer.t`, starting at a particular offset and continuing through to the end. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array/Int16Array) - -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. -*/ -@deprecated({ - reason: "Use `fromBuffer` instead", - migrate: Int16Array.fromBuffer(), -}) -@new -external fromBufferToEnd: (Stdlib_ArrayBuffer.t, ~byteOffset: int) => t = "Int16Array" - -/** `fromBufferWithRange` creates a `Int16Array` from an `ArrayBuffer.t`, starting at a particular offset and consuming `length` **bytes**. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array/Int16Array) - -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. -*/ -@deprecated({ - reason: "Use `fromBuffer` instead", - migrate: Int16Array.fromBuffer(), -}) -@new -external fromBufferWithRange: (Stdlib_ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = - "Int16Array" - /** `fromLength` creates a zero-initialized `Int16Array` to hold the specified count of numbers; this is **not** a byte length. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array/Int16Array) **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. @@ -62,18 +39,6 @@ external fromLength: int => t = "Int16Array" @val external fromArrayLikeOrIterable: ('a, ~map: ('b, int) => int=?) => t = "Int16Array.from" -/** `fromArrayLikeOrIterableWithMap` creates a `Int16Array` from an array-like or iterable object and applies the mapping function to each item. The mapping function expects (value, index). See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from) -*/ -@deprecated({ - reason: "Use `fromArrayLikeOrIterable` instead", - migrate: Int16Array.fromArrayLikeOrIterable( - %insert.unlabelledArgument(0), - ~map=%insert.unlabelledArgument(1), - ), -}) -@val -external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => int) => t = "Int16Array.from" - /** `ignore(intArray)` ignores the provided intArray and returns unit. diff --git a/packages/@rescript/runtime/Stdlib_Int32Array.res b/packages/@rescript/runtime/Stdlib_Int32Array.res index 98e8f69d062..8ad351fffa6 100644 --- a/packages/@rescript/runtime/Stdlib_Int32Array.res +++ b/packages/@rescript/runtime/Stdlib_Int32Array.res @@ -27,29 +27,6 @@ external fromArray: array => t = "Int32Array" @new external fromBuffer: (Stdlib_ArrayBuffer.t, ~byteOffset: int=?, ~length: int=?) => t = "Int32Array" -/** `fromBufferToEnd` creates a `Int32Array` from an `ArrayBuffer.t`, starting at a particular offset and continuing through to the end. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array/Int32Array) - -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. -*/ -@deprecated({ - reason: "Use `fromBuffer` instead", - migrate: Int32Array.fromBuffer(), -}) -@new -external fromBufferToEnd: (Stdlib_ArrayBuffer.t, ~byteOffset: int) => t = "Int32Array" - -/** `fromBufferWithRange` creates a `Int32Array` from an `ArrayBuffer.t`, starting at a particular offset and consuming `length` **bytes**. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array/Int32Array) - -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. -*/ -@deprecated({ - reason: "Use `fromBuffer` instead", - migrate: Int32Array.fromBuffer(), -}) -@new -external fromBufferWithRange: (Stdlib_ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = - "Int32Array" - /** `fromLength` creates a zero-initialized `Int32Array` to hold the specified count of numbers; this is **not** a byte length. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array/Int32Array) **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. @@ -62,18 +39,6 @@ external fromLength: int => t = "Int32Array" @val external fromArrayLikeOrIterable: ('a, ~map: ('b, int) => int=?) => t = "Int32Array.from" -/** `fromArrayLikeOrIterableWithMap` creates a `Int32Array` from an array-like or iterable object and applies the mapping function to each item. The mapping function expects (value, index). See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from) -*/ -@deprecated({ - reason: "Use `fromArrayLikeOrIterable` instead", - migrate: Int32Array.fromArrayLikeOrIterable( - %insert.unlabelledArgument(0), - ~map=%insert.unlabelledArgument(1), - ), -}) -@val -external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => int) => t = "Int32Array.from" - /** `ignore(intArray)` ignores the provided intArray and returns unit. diff --git a/packages/@rescript/runtime/Stdlib_Int8Array.res b/packages/@rescript/runtime/Stdlib_Int8Array.res index 6a5bb59208a..43a717b4f40 100644 --- a/packages/@rescript/runtime/Stdlib_Int8Array.res +++ b/packages/@rescript/runtime/Stdlib_Int8Array.res @@ -27,29 +27,6 @@ external fromArray: array => t = "Int8Array" @new external fromBuffer: (Stdlib_ArrayBuffer.t, ~byteOffset: int=?, ~length: int=?) => t = "Int8Array" -/** `fromBufferToEnd` creates a `Int8Array` from an `ArrayBuffer.t`, starting at a particular offset and continuing through to the end. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array/Int8Array) - -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. -*/ -@deprecated({ - reason: "Use `fromBuffer` instead", - migrate: Int8Array.fromBuffer(), -}) -@new -external fromBufferToEnd: (Stdlib_ArrayBuffer.t, ~byteOffset: int) => t = "Int8Array" - -/** `fromBufferWithRange` creates a `Int8Array` from an `ArrayBuffer.t`, starting at a particular offset and consuming `length` **bytes**. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array/Int8Array) - -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. -*/ -@deprecated({ - reason: "Use `fromBuffer` instead", - migrate: Int8Array.fromBuffer(), -}) -@new -external fromBufferWithRange: (Stdlib_ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = - "Int8Array" - /** `fromLength` creates a zero-initialized `Int8Array` to hold the specified count of numbers; this is **not** a byte length. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array/Int8Array) **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. @@ -62,18 +39,6 @@ external fromLength: int => t = "Int8Array" @val external fromArrayLikeOrIterable: ('a, ~map: ('b, int) => int=?) => t = "Int8Array.from" -/** `fromArrayLikeOrIterableWithMap` creates a `Int8Array` from an array-like or iterable object and applies the mapping function to each item. The mapping function expects (value, index). See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from) -*/ -@deprecated({ - reason: "Use `fromArrayLikeOrIterable` instead", - migrate: Int8Array.fromArrayLikeOrIterable( - %insert.unlabelledArgument(0), - ~map=%insert.unlabelledArgument(1), - ), -}) -@val -external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => int) => t = "Int8Array.from" - /** `ignore(intArray)` ignores the provided intArray and returns unit. diff --git a/packages/@rescript/runtime/Stdlib_JSON.res b/packages/@rescript/runtime/Stdlib_JSON.res index 50012e67c87..a6aaa0fb7af 100644 --- a/packages/@rescript/runtime/Stdlib_JSON.res +++ b/packages/@rescript/runtime/Stdlib_JSON.res @@ -12,150 +12,11 @@ type replacer = Keys(array) | Replacer((string, t) => t) @throws @val external parseOrThrow: (string, ~reviver: (string, t) => t=?) => t = "JSON.parse" -@deprecated({ - reason: "Use `JSON.parseOrThrow` instead", - migrate: JSON.parseOrThrow(), -}) -@raises -@val -external parseExn: (string, ~reviver: (string, t) => t=?) => t = "JSON.parse" - -@deprecated({ - reason: "Use `JSON.parseOrThrow` with optional parameter instead", - migrate: JSON.parseOrThrow(%insert.unlabelledArgument(0), ~reviver=%insert.unlabelledArgument(1)), -}) -@raises -@val -external parseExnWithReviver: (string, (string, t) => t) => t = "JSON.parse" - @val external stringify: (t, ~replacer: replacer=?, ~space: int=?) => string = "JSON.stringify" -@deprecated({ - reason: "Use `JSON.stringify` with optional parameter instead", - migrate: JSON.stringify(%insert.unlabelledArgument(0), ~space=%insert.unlabelledArgument(2)), -}) -@val -external stringifyWithIndent: (t, @as(json`null`) _, int) => string = "JSON.stringify" -@deprecated({ - reason: "Use `JSON.stringify` with optional parameter instead", - migrate: JSON.stringify( - %insert.unlabelledArgument(0), - ~replacer=Replacer(%insert.unlabelledArgument(1)), - ), -}) -@val -external stringifyWithReplacer: (t, (string, t) => t) => string = "JSON.stringify" -@deprecated({ - reason: "Use `JSON.stringify` with optional parameters instead", - migrate: JSON.stringify( - %insert.unlabelledArgument(0), - ~replacer=Replacer(%insert.unlabelledArgument(1)), - ~space=%insert.unlabelledArgument(2), - ), -}) -@val -external stringifyWithReplacerAndIndent: (t, (string, t) => t, int) => string = "JSON.stringify" -@deprecated({ - reason: "Use `JSON.stringify` with optional parameter instead", - migrate: JSON.stringify( - %insert.unlabelledArgument(0), - ~replacer=Keys(%insert.unlabelledArgument(1)), - ), -}) -@val -external stringifyWithFilter: (t, array) => string = "JSON.stringify" -@deprecated({ - reason: "Use `JSON.stringify` with optional parameters instead", - migrate: JSON.stringify( - %insert.unlabelledArgument(0), - ~replacer=Keys(%insert.unlabelledArgument(1)), - ~space=%insert.unlabelledArgument(2), - ), -}) -@val -external stringifyWithFilterAndIndent: (t, array, int) => string = "JSON.stringify" @throws @val external stringifyAny: ('a, ~replacer: replacer=?, ~space: int=?) => option = "JSON.stringify" -@deprecated({ - reason: "Use `JSON.stringifyAny` with optional parameter instead", - migrate: JSON.stringifyAny(%insert.unlabelledArgument(0), ~space=%insert.unlabelledArgument(2)), -}) -@raises -@val -external stringifyAnyWithIndent: ('a, @as(json`null`) _, int) => option = "JSON.stringify" -@deprecated({ - reason: "Use `JSON.stringifyAny` with optional parameter instead", - migrate: JSON.stringifyAny( - %insert.unlabelledArgument(0), - ~replacer=Replacer(%insert.unlabelledArgument(1)), - ), -}) -@raises -@val -external stringifyAnyWithReplacer: ('a, (string, t) => t) => option = "JSON.stringify" -@deprecated({ - reason: "Use `JSON.stringifyAny` with optional parameters instead", - migrate: JSON.stringifyAny( - %insert.unlabelledArgument(0), - ~replacer=Replacer(%insert.unlabelledArgument(1)), - ~space=%insert.unlabelledArgument(2), - ), -}) -@raises -@val -external stringifyAnyWithReplacerAndIndent: ('a, (string, t) => t, int) => option = - "JSON.stringify" -@deprecated({ - reason: "Use `JSON.stringifyAny` with optional parameter instead", - migrate: JSON.stringifyAny( - %insert.unlabelledArgument(0), - ~replacer=Keys(%insert.unlabelledArgument(1)), - ), -}) -@raises -@val -external stringifyAnyWithFilter: ('a, array) => string = "JSON.stringify" -@deprecated({ - reason: "Use `JSON.stringifyAny` with optional parameters instead", - migrate: JSON.stringifyAny( - %insert.unlabelledArgument(0), - ~replacer=Keys(%insert.unlabelledArgument(1)), - ~space=%insert.unlabelledArgument(2), - ), -}) -@raises -@val -external stringifyAnyWithFilterAndIndent: ('a, array, int) => string = "JSON.stringify" - -module Classify = { - @val external _internalClass: 'a => string = "Object.prototype.toString.call" - external _asBool: 'a => bool = "%identity" - external _asString: 'a => string = "%identity" - external _asFloat: 'a => float = "%identity" - external _asArray: 'a => array = "%identity" - external _asDict: 'a => dict = "%identity" - - type t = - | Bool(bool) - | Null - | String(string) - | Number(float) - | Object(dict) - | Array(array) - - @deprecated("Directly switch on the JSON object instead") - let classify = value => { - switch _internalClass(value) { - | "[object Boolean]" => Bool(_asBool(value)) - | "[object Null]" => Null - | "[object String]" => String(_asString(value)) - | "[object Number]" => Number(_asFloat(value)) - | "[object Array]" => Array(_asArray(value)) - | _ => Object(_asDict(value)) - } - } -} module Encode = { external bool: bool => t = "%identity" diff --git a/packages/@rescript/runtime/Stdlib_JSON.resi b/packages/@rescript/runtime/Stdlib_JSON.resi index 18b3870b494..429c2ffcc12 100644 --- a/packages/@rescript/runtime/Stdlib_JSON.resi +++ b/packages/@rescript/runtime/Stdlib_JSON.resi @@ -58,93 +58,11 @@ try { ## Exceptions -- Throws a SyntaxError (Exn.t) if the string isn't valid JSON. +- Throws a SyntaxError (JsExn.t) if the string isn't valid JSON. */ @val external parseOrThrow: (string, ~reviver: (string, t) => t=?) => t = "JSON.parse" -/** -`parseExn(string, ~reviver=?)` - -Parses a JSON string or throws a JavaScript exception (SyntaxError), if the string isn't valid. -The reviver describes how the value should be transformed. It is a function which receives a key and a value. -It returns a JSON type. - -## Examples -```rescript -try { - let _ = JSON.parseExn(`{"foo":"bar","hello":"world"}`) - // { foo: 'bar', hello: 'world' } - - let _ = JSON.parseExn("") - // error -} catch { -| JsExn(_) => Console.log("error") -} - -let reviver = (_, value: JSON.t) => - switch value { - | String(string) => string->String.toUpperCase->JSON.Encode.string - | Number(number) => (number *. 2.0)->JSON.Encode.float - | _ => value - } - -let jsonString = `{"hello":"world","someNumber":21}` - -try { - JSON.parseExn(jsonString, ~reviver)->Console.log - // { hello: 'WORLD', someNumber: 42 } - - JSON.parseExn("", ~reviver)->Console.log - // error -} catch { -| JsExn(_) => Console.log("error") -} -``` - -## Exceptions - -- Throws a SyntaxError (Exn.t) if the string isn't valid JSON. -*/ -@deprecated("Use `parseOrThrow` instead") @val -external parseExn: (string, ~reviver: (string, t) => t=?) => t = "JSON.parse" - -/** -`parseExnWithReviver(string, reviver)` - -Parses a JSON string or throws a JavaScript exception (SyntaxError), if the string isn't valid. -The reviver describes how the value should be transformed. It is a function which receives a key and a value. -It returns a JSON type. - -## Examples -```rescript -let reviver = (_, value: JSON.t) => - switch value { - | String(string) => string->String.toUpperCase->JSON.Encode.string - | Number(number) => (number *. 2.0)->JSON.Encode.float - | _ => value - } - -let jsonString = `{"hello":"world","someNumber":21}` - -JSON.parseExnWithReviver(jsonString, reviver)->Console.log -// { hello: 'WORLD', someNumber: 42 } - -try { - JSON.parseExnWithReviver("", reviver)->Console.log - // error -} catch { -| JsExn(_) => Console.log("error") -} -``` - -## Exceptions - -- Throws a SyntaxError if the string is not a valid JSON. -*/ -@deprecated("Use `parseOrThrow` with optional parameter instead") @val -external parseExnWithReviver: (string, (string, t) => t) => t = "JSON.parse" - /** `stringify(json, ~replacer=?, ~space=?)` @@ -193,149 +111,6 @@ JSON.stringify(json, ~replacer) @val external stringify: (t, ~replacer: replacer=?, ~space: int=?) => string = "JSON.stringify" -/** -`stringifyWithIndent(json, indentation)` - -Converts a JSON object to a JSON string. The output will be indented. -If you want to stringify any type, use `JSON.stringifyAnyWithIndent` instead. - -## Examples -```rescript -let json = - Dict.fromArray([ - ("foo", JSON.Encode.string("bar")), - ("hello", JSON.Encode.string("world")), - ("someNumber", JSON.Encode.int(42)), - ])->JSON.Encode.object - -JSON.stringifyWithIndent(json, 2) -// { -// "foo": "bar", -// "hello": "world", -// "someNumber": 42 -// } -``` -*/ -@deprecated("Use `stringify` with optional parameter instead") @val -external stringifyWithIndent: (t, @as(json`null`) _, int) => string = "JSON.stringify" - -/** -`stringifyWithReplacer(json, replacer)` - -Converts a JSON object to a JSON string. -The replacer describes how the value should be transformed. It is a function which receives a key and a value. -If you want to stringify any type, use `JSON.stringifyAnyWithReplacer` instead. - -## Examples -```rescript -let json = - Dict.fromArray([ - ("foo", JSON.Encode.string("bar")), - ("hello", JSON.Encode.string("world")), - ("someNumber", JSON.Encode.int(42)), - ])->JSON.Encode.object - -let replacer = (_, value) => { - let decodedValue = value->JSON.Decode.string - - switch decodedValue { - | Some(string) => string->String.toUpperCase->JSON.Encode.string - | None => value - } -} - -JSON.stringifyWithReplacer(json, replacer) -// {"foo":"BAR","hello":"WORLD","someNumber":42} -``` -*/ -@deprecated("Use `stringify` with optional parameter instead") @val -external stringifyWithReplacer: (t, (string, t) => t) => string = "JSON.stringify" - -/** -`stringifyWithReplacerAndIndent(json, replacer, indentation)` - -Converts a JSON object to a JSON string. The output will be indented. -The replacer describes how the value should be transformed. It is a function which receives a key and a value. -If you want to stringify any type, use `JSON.stringifyAnyWithReplacerAndIndent` instead. - -## Examples -```rescript -let json = - Dict.fromArray([ - ("foo", JSON.Encode.string("bar")), - ("hello", JSON.Encode.string("world")), - ("someNumber", JSON.Encode.int(42)), - ])->JSON.Encode.object - -let replacer = (_, value) => { - let decodedValue = value->JSON.Decode.string - - switch decodedValue { - | Some(string) => string->String.toUpperCase->JSON.Encode.string - | None => value - } -} - -JSON.stringifyWithReplacerAndIndent(json, replacer, 2) -// { -// "foo": "BAR", -// "hello": "WORLD", -// "someNumber": 42 -// } -``` -*/ -@deprecated("Use `stringify` with optional parameters instead") @val -external stringifyWithReplacerAndIndent: (t, (string, t) => t, int) => string = "JSON.stringify" - -/** -`stringifyWithFilter(json, filter)` - -Converts a JSON object to a JSON string. -The filter is an array of keys, which should be included in the output. -If you want to stringify any type, use `JSON.stringifyAnyWithFilter` instead. - -## Examples -```rescript -let json = - Dict.fromArray([ - ("foo", JSON.Encode.string("bar")), - ("hello", JSON.Encode.string("world")), - ("someNumber", JSON.Encode.int(42)), - ])->JSON.Encode.object - -JSON.stringifyWithFilter(json, ["foo", "someNumber"]) -// {"foo":"bar","someNumber":42} -``` -*/ -@deprecated("Use `stringify` with optional parameter instead") @val -external stringifyWithFilter: (t, array) => string = "JSON.stringify" - -/** -`stringifyWithFilterAndIndent(json, filter, indentation)` - -Converts a JSON object to a JSON string. The output will be indented. -The filter is an array of keys, which should be included in the output. -If you want to stringify any type, use `JSON.stringifyAnyWithFilterAndIndent` instead. - -## Examples -```rescript -let json = - Dict.fromArray([ - ("foo", JSON.Encode.string("bar")), - ("hello", JSON.Encode.string("world")), - ("someNumber", JSON.Encode.int(42)), - ])->JSON.Encode.object - -JSON.stringifyWithFilterAndIndent(json, ["foo", "someNumber"], 2) -// { -// "foo": "bar", -// "someNumber": 42 -// } -``` -*/ -@deprecated("Use `stringify` with optional parameters instead") @val -external stringifyWithFilterAndIndent: (t, array, int) => string = "JSON.stringify" - /** `stringifyAny(any, ~replacer=?, ~space=?)` @@ -403,255 +178,6 @@ switch BigInt.fromInt(0)->JSON.stringifyAny { external stringifyAny: ('a, ~replacer: replacer=?, ~space: int=?) => option = "JSON.stringify" -/** -`stringifyAnyWithIndent(any, indentation)` - -Converts any type to a JSON string. The output will be indented. -Stringifying a function or `undefined` will return `None`. -If the value contains circular references or `BigInt`s, the function will throw a JavaScript exception (TypeError). -If you want to stringify a JSON object, use `JSON.stringifyWithIndent` instead. - -## Examples - -```rescript -let dict = Dict.fromArray([ - ("foo", JSON.Encode.string("bar")), - ("hello", JSON.Encode.string("world")), - ("someNumber", JSON.Encode.int(42)), -]) - -dict -->JSON.stringifyAnyWithIndent(2) -->Option.getUnsafe == `{ - "foo": "bar", - "hello": "world", - "someNumber": 42 -}` - -JSON.stringifyAny(() => "hello world") == None - -switch BigInt.fromInt(0)->JSON.stringifyAny { -| exception _ => assert(true) -| _ => assert(false) -} -``` - -## Exceptions - -- Throws a TypeError if the value contains circular references. -- Throws a TypeError if the value contains `BigInt`s. -*/ -@deprecated("Use `stringifyAny` with optional parameter instead") @val -external stringifyAnyWithIndent: ('a, @as(json`null`) _, int) => option = "JSON.stringify" - -/** -`stringifyAnyWithReplacer(json, replacer)` - -Converts any type to a JSON string. -The replacer describes how the value should be transformed. It is a function which receives a key and a value. -Stringifying a function or `undefined` will return `None`. -If the value contains circular references or `BigInt`s, the function will throw a JavaScript exception (TypeError). -If you want to stringify a JSON object, use `JSON.stringifyWithReplacer` instead. - -## Examples -```rescript -let dict = Dict.fromArray([ - ("foo", JSON.Encode.string("bar")), - ("hello", JSON.Encode.string("world")), - ("someNumber", JSON.Encode.int(42)), -]) - -let replacer = (_, value) => { - let decodedValue = value->JSON.Decode.string - - switch decodedValue { - | Some(string) => string->String.toUpperCase->JSON.Encode.string - | None => value - } -} - -dict -->JSON.stringifyAnyWithReplacer(replacer) -->Option.getUnsafe == `{"foo":"BAR","hello":"WORLD","someNumber":42}` - -JSON.stringifyAny(() => "hello world") == None - -switch BigInt.fromInt(0)->JSON.stringifyAny { -| exception _ => assert(true) -| _ => assert(false) -} -``` - -## Exceptions - -- Throws a TypeError if the value contains circular references. -- Throws a TypeError if the value contains `BigInt`s. -*/ -@deprecated("Use `stringifyAny` with optional parameter instead") @val -external stringifyAnyWithReplacer: ('a, (string, t) => t) => option = "JSON.stringify" - -/** -`stringifyAnyWithReplacerAndIndent(json, replacer, indentation)` - -Converts any type to a JSON string. The output will be indented. -The replacer describes how the value should be transformed. It is a function which receives a key and a value. -Stringifying a function or `undefined` will return `None`. -If the value contains circular references or `BigInt`s, the function will throw a JavaScript exception (TypeError). -If you want to stringify a JSON object, use `JSON.stringifyWithReplacerAndIndent` instead. - -## Examples - -```rescript -let dict = Dict.fromArray([ - ("foo", JSON.Encode.string("bar")), - ("hello", JSON.Encode.string("world")), - ("someNumber", JSON.Encode.int(42)), -]) - -let replacer = (_, value) => { - let decodedValue = value->JSON.Decode.string - - switch decodedValue { - | Some(string) => string->String.toUpperCase->JSON.Encode.string - | None => value - } -} - -dict -->JSON.stringifyAnyWithReplacer(replacer) -->Option.getUnsafe == `{"foo":"BAR","hello":"WORLD","someNumber":42}` - -JSON.stringifyAny(() => "hello world") == None - -switch BigInt.fromInt(0)->JSON.stringifyAny { -| exception _ => assert(true) -| _ => assert(false) -} -``` - -## Exceptions - -- Throws a TypeError if the value contains circular references. -- Throws a TypeError if the value contains `BigInt`s. -*/ -@deprecated("Use `stringifyAny` with optional parameters instead") @val -external stringifyAnyWithReplacerAndIndent: ('a, (string, t) => t, int) => option = - "JSON.stringify" - -/** -`stringifyAnyWithFilter(json, filter)` - -Converts any type to a JSON string. -The filter is an array of keys, which should be included in the output. -Stringifying a function or `undefined` will return `None`. -If the value contains circular references or `BigInt`s, the function will throw a JavaScript exception (TypeError). -If you want to stringify a JSON object, use `JSON.stringifyWithFilter` instead. - -## Examples - -```rescript -let dict = Dict.fromArray([ - ("foo", JSON.Encode.string("bar")), - ("hello", JSON.Encode.string("world")), - ("someNumber", JSON.Encode.int(42)), -]) - -dict->JSON.stringifyAnyWithFilter(["foo", "someNumber"]) == `{"foo":"bar","someNumber":42}` - -JSON.stringifyAny(() => "hello world") == None - -switch BigInt.fromInt(0)->JSON.stringifyAny { -| exception _ => assert(true) -| _ => assert(false) -} -``` - -## Exceptions - -- Throws a TypeError if the value contains circular references. -- Throws a TypeError if the value contains `BigInt`s. -*/ -@deprecated("Use `stringifyAny` with optional parameter instead") @val -external stringifyAnyWithFilter: ('a, array) => string = "JSON.stringify" - -/** -`stringifyAnyWithFilterAndIndent(json, filter, indentation)` - -Converts any type to a JSON string. The output will be indented. -The filter is an array of keys, which should be included in the output. -Stringifying a function or `undefined` will return `None`. -If the value contains circular references or `BigInt`s, the function will throw a JavaScript exception (TypeError). -If you want to stringify a JSON object, use `JSON.stringifyWithFilterAndIndent` instead. - -## Examples - -```rescript -let dict = Dict.fromArray([ - ("foo", JSON.Encode.string("bar")), - ("hello", JSON.Encode.string("world")), - ("someNumber", JSON.Encode.int(42)), -]) - -dict -->JSON.stringifyAny -->Option.getUnsafe == `{"foo":"bar","hello":"world","someNumber":42}` - -dict -->JSON.stringifyAny(~space=2) -->Option.getUnsafe == `{ - "foo": "bar", - "hello": "world", - "someNumber": 42 -}` - -dict -->JSON.stringifyAny(~replacer=Keys(["foo", "someNumber"])) -->Option.getUnsafe == `{"foo":"bar","someNumber":42}` - -JSON.stringifyAny(() => "hello world") == None - -switch BigInt.fromInt(0)->JSON.stringifyAny { -| exception _ => assert(true) -| _ => assert(false) -} -``` - -## Exceptions - -- Throws a TypeError if the value contains circular references. -- Throws a TypeError if the value contains `BigInt`s. -*/ -@deprecated("Use `stringifyAny` with optional parameters instead") @val -external stringifyAnyWithFilterAndIndent: ('a, array, int) => string = "JSON.stringify" - -module Classify: { - /** - A type representing a JavaScript type. - */ - type t = - | Bool(bool) - | Null - | String(string) - | Number(float) - | Object(dict) - | Array(array) - - /** - Returns the JSON type of any value. - - ## Examples - ```rescript - JSON.Classify.classify("hello world") - // String("hello world") - - JSON.Classify.classify(42) - // Number(42) - ``` - */ - @deprecated("Directly switch on the JSON object instead") - let classify: 'a => t -} - module Encode: { /** Returns a boolean as JSON. diff --git a/packages/@rescript/runtime/Stdlib_JsExn.resi b/packages/@rescript/runtime/Stdlib_JsExn.resi index 0efaed31f8d..a498a944bcd 100644 --- a/packages/@rescript/runtime/Stdlib_JsExn.resi +++ b/packages/@rescript/runtime/Stdlib_JsExn.resi @@ -48,7 +48,7 @@ See [`Error.prototype.message`](https://developer.mozilla.org/en-US/docs/Web/Jav ## Example ```rescript try {JsError.SyntaxError.throwWithMessage("Some message here")} catch { -| JsExn(e) => e->JsExn.message->Option.getExn == "Some message here" +| JsExn(e) => e->JsExn.message->Option.getOrThrow == "Some message here" | _ => assert(false) } ``` @@ -63,7 +63,7 @@ See [`Error.prototype.name`](https://developer.mozilla.org/en-US/docs/Web/JavaSc ## Example ```rescript try {JsError.SyntaxError.throwWithMessage("Some message here")} catch { -| JsExn(e) => e->JsExn.name->Option.getExn == "SyntaxError" +| JsExn(e) => e->JsExn.name->Option.getOrThrow == "SyntaxError" | _ => assert(false) } ``` diff --git a/packages/@rescript/runtime/Stdlib_Lazy.res b/packages/@rescript/runtime/Stdlib_Lazy.res index 5758a74f48f..b0c30b405f3 100644 --- a/packages/@rescript/runtime/Stdlib_Lazy.res +++ b/packages/@rescript/runtime/Stdlib_Lazy.res @@ -19,7 +19,7 @@ external valToFn: 'a => unit => 'a = "%identity" external castToConcrete: t<'a> => internal<'a> = "%identity" external castFromConcrete: internal<'a> => t<'a> = "%identity" -let is_val = (type a, l: t): bool => castToConcrete(l).tag +let isEvaluated = (type a, l: t): bool => castToConcrete(l).tag exception Undefined @@ -43,14 +43,7 @@ let force_lazy_block = (type a, blk: internal): a => { } } -/* Assume [blk] is a block with tag lazy */ -let force_val_lazy_block = (type a, blk: internal): a => { - let closure = valToFn(blk.value) - blk.value = fnToVal(raise_undefined) - forward_with_closure(blk, closure) -} - -let force = (type a, lzv: t): a => { +let get = (type a, lzv: t): a => { let lzv: internal<_> = castToConcrete(lzv) if lzv.tag { lzv.value @@ -59,16 +52,7 @@ let force = (type a, lzv: t): a => { } } -let force_val = (type a, lzv: t): a => { - let lzv: internal<_> = castToConcrete(lzv) - if lzv.tag { - lzv.value - } else { - force_val_lazy_block(lzv) - } -} - -let from_fun = (type a, closure: unit => a): t => { +let make = (type a, closure: unit => a): t => { let blk = { tag: false, value: fnToVal(closure), @@ -76,16 +60,4 @@ let from_fun = (type a, closure: unit => a): t => { castFromConcrete(blk) } -let from_val = (type a, value: a): t => { - let blk = { - tag: true, - value, - } - castFromConcrete(blk) -} - -let make = from_fun -let get = force -let isEvaluated = is_val - external ignore: t<'a> => unit = "%ignore" diff --git a/packages/@rescript/runtime/Stdlib_Lazy.resi b/packages/@rescript/runtime/Stdlib_Lazy.resi index e5d5a930892..ad2a7ea1c3a 100644 --- a/packages/@rescript/runtime/Stdlib_Lazy.resi +++ b/packages/@rescript/runtime/Stdlib_Lazy.resi @@ -65,67 +65,6 @@ let isEvaluated: t<'a> => bool exception Undefined -/** - `force(x)` forces the suspension `x` and returns its result. - If `x` has already been forced, `Lazy.force(x)` returns the - same value again without recomputing it. If it threw an exception, - the same exception is thrown again. - Throw `Undefined` if the forcing of `x` tries to force `x` itself - recursively. -*/ -@deprecated({ - reason: "Use `Lazy.get` instead", - migrate: Lazy.get(), -}) -let force: t<'a> => 'a - -/** - `force_val(x)` forces the suspension `x` and returns its - result. If `x` has already been forced, `force_val(x)` - returns the same value again without recomputing it. - Throw `Undefined` if the forcing of `x` tries to force `x` itself - recursively. - If the computation of `x` throws an exception, it is unspecified - whether `force_val(x)` throws the same exception or `Undefined`. -*/ -@deprecated({ - reason: "Use `Lazy.get` instead", - migrate: Lazy.get(), -}) -let force_val: t<'a> => 'a - -/** - `Lazy.from_fun(f)` creates a lazy value from `f` which is the - computation to be deferred of type `unit => 'a`. - The function returns a lazy value of type `Lazy.t<'a>`. - The computation is not executed until the lazy value is accessed. -*/ -@deprecated({ - reason: "Use `Lazy.make` instead", - migrate: Lazy.make(), -}) -let from_fun: (unit => 'a) => t<'a> - -/** - `from_val(v)` returns an already-forced suspension of `v`. - This is for special purposes only. -*/ -@deprecated({ - reason: "Use `Lazy.make` instead", - migrate: Lazy.make(() => %insert.unlabelledArgument(0)), -}) -let from_val: 'a => t<'a> - -/** - `is_val(x)` returns `true` if `x has already been forced and - did not throw an exception. -*/ -@deprecated({ - reason: "Use `Lazy.isEvaluated` instead", - migrate: Lazy.isEvaluated(), -}) -let is_val: t<'a> => bool - /** `ignore(lazyValue)` ignores the provided lazy value and returns unit. diff --git a/packages/@rescript/runtime/Stdlib_List.res b/packages/@rescript/runtime/Stdlib_List.res index 46c60d7c4d5..1b5866f1858 100644 --- a/packages/@rescript/runtime/Stdlib_List.res +++ b/packages/@rescript/runtime/Stdlib_List.res @@ -94,8 +94,6 @@ let headOrThrow = x => | list{x, ..._} => x } -let headExn = headOrThrow - let tail = x => switch x { | list{} => None @@ -108,8 +106,6 @@ let tailOrThrow = x => | list{_, ...t} => t } -let tailExn = tailOrThrow - let add = (xs, x) => list{x, ...xs} /* Assume `n >=0` */ @@ -149,8 +145,6 @@ let getOrThrow = (x, n) => nthAuxAssert(x, n) } -let getExn = getOrThrow - let rec partitionAux = (p, cell, precX, precY) => switch cell { | list{} => () @@ -227,34 +221,6 @@ let rec copyAuxWitFilterMap = (f, cellX, prec) => } } -let rec removeAssocAuxWithMap = (cellX, x, prec, f) => - switch cellX { - | list{} => false - | list{(a, _) as h, ...t} => - if f(a, x) { - unsafeMutateTail(prec, t) - true - } else { - let next = mutableCell(h, list{}) - unsafeMutateTail(prec, next) - removeAssocAuxWithMap(t, x, next, f) - } - } - -let rec setAssocAuxWithMap = (cellX, x, k, prec, eq) => - switch cellX { - | list{} => false - | list{(a, _) as h, ...t} => - if eq(a, x) { - unsafeMutateTail(prec, list{(x, k), ...t}) - true - } else { - let next = mutableCell(h, list{}) - unsafeMutateTail(prec, next) - setAssocAuxWithMap(t, x, k, next, eq) - } - } - let rec copyAuxWithMap = (cellX, prec, f) => switch cellX { | list{} => () @@ -481,9 +447,6 @@ let shuffle = xs => { fromArray(v) } -@deprecated("Use `shuffle` instead") -let toShuffled = shuffle - let rec reverseConcat = (l1, l2) => switch l1 { | list{} => l2 @@ -673,73 +636,12 @@ let rec some2 = (l1, l2, p) => | (list{a1, ...l1}, list{a2, ...l2}) => p(a1, a2) || some2(l1, l2, p) } -let rec has = (xs, x, eq) => - switch xs { - | list{} => false - | list{a, ...l} => eq(a, x) || has(l, x, eq) - } - let rec includes = (xs, x) => switch xs { | list{} => false | list{a, ...l} => a === x || includes(l, x) } -@deprecated("Use a `Map` instead") -let rec getAssoc = (xs, x, eq) => - switch xs { - | list{} => None - | list{(a, b), ...l} => - if eq(a, x) { - Some(b) - } else { - getAssoc(l, x, eq) - } - } - -@deprecated("Use a `Map` instead") -let rec hasAssoc = (xs, x, eq) => - switch xs { - | list{} => false - | list{(a, _), ...l} => eq(a, x) || hasAssoc(l, x, eq) - } - -@deprecated("Use a `Map` instead") -let removeAssoc = (xs, x, eq) => - switch xs { - | list{} => list{} - | list{(a, _) as pair, ...l} => - if eq(a, x) { - l - } else { - let cell = mutableCell(pair, list{}) - let removed = removeAssocAuxWithMap(l, x, cell, eq) - if removed { - cell - } else { - xs - } - } - } - -@deprecated("Use a `Map` instead") -let setAssoc = (xs, x, k, eq) => - switch xs { - | list{} => list{(x, k)} - | list{(a, _) as pair, ...l} => - if eq(a, x) { - list{(x, k), ...l} - } else { - let cell = mutableCell(pair, list{}) - let replaced = setAssocAuxWithMap(l, x, k, cell, eq) - if replaced { - cell - } else { - list{(x, k), ...xs} - } - } - } - let sort = (xs, cmp) => { let arr = toArray(xs) Stdlib_Array.sort(arr, cmp) diff --git a/packages/@rescript/runtime/Stdlib_List.resi b/packages/@rescript/runtime/Stdlib_List.resi index ddd9721b1fc..2de11bfbd03 100644 --- a/packages/@rescript/runtime/Stdlib_List.resi +++ b/packages/@rescript/runtime/Stdlib_List.resi @@ -53,31 +53,6 @@ List.head(list{1, 2, 3}) == Some(1) */ let head: list<'a> => option<'a> -/** -`headExn(list)` same as [`head`](#head). - -## Examples - -```rescript -List.headExn(list{1, 2, 3}) == 1 - -switch List.headExn(list{}) { -| exception Not_found => assert(true) -| _ => assert(false) -} -``` - -## Exceptions - -- Throws an Error if list is empty. - -*/ -@deprecated({ - reason: "Use `headOrThrow` instead", - migrate: List.headOrThrow(), -}) -let headExn: list<'a> => 'a - /** `headOrThrow(list)` same as [`head`](#head). @@ -112,30 +87,6 @@ List.tail(list{}) == None */ let tail: list<'a> => option> -/** -`tailExn(list)` same as [`tail`](#tail). - -## Examples - -```rescript -List.tailExn(list{1, 2, 3}) == list{2, 3} - -switch List.tailExn(list{}) { -| exception Not_found => assert(true) -| _ => assert(false) -} -``` - -## Exceptions - -- Throws an Error if list is empty. -*/ -@deprecated({ - reason: "Use `tailOrThrow` instead", - migrate: List.tailOrThrow(), -}) -let tailExn: list<'a> => list<'a> - /** `tailOrThrow(list)` same as [`tail`](#tail). @@ -185,32 +136,6 @@ abc->List.get(4) == None */ let get: (list<'a>, int) => option<'a> -/** -`getExn(list, index)` same as [`get`](#get). - -## Examples - -```rescript -let abc = list{"A", "B", "C"} - -abc->List.getExn(1) == "B" - -switch abc->List.getExn(4) { -| exception Not_found => assert(true) -| _ => assert(false) -} -``` - -## Exceptions - -- Throws an Error if `index` is larger than the length of list. -*/ -@deprecated({ - reason: "Use `getOrThrow` instead", - migrate: List.getOrThrow(), -}) -let getExn: (list<'a>, int) => 'a - /** `getOrThrow(list, index)` same as [`get`](#get). @@ -270,21 +195,6 @@ List.shuffle(list{1, 2, 3}) // list{2, 1, 3} */ let shuffle: list<'a> => list<'a> -/** -`toShuffled(list)` returns a new list in random order. - -## Examples - -```rescript -List.toShuffled(list{1, 2, 3}) // list{2, 1, 3} -``` -*/ -@deprecated({ - reason: "Use `shuffle` instead", - migrate: List.shuffle(), -}) -let toShuffled: list<'a> => list<'a> - /** `drop(list, value)` return a new list, dropping the first `value` element. Returns `None` if `list` has fewer than `value` elements. @@ -755,25 +665,6 @@ List.equal(list{1, 2, 3}, list{-1, -2, -3}, (a, b) => Math.Int.abs(a) == Math.In */ let equal: (list<'a>, list<'a>, ('a, 'a) => bool) => bool -/** -`has(list, element, f)` returns `true` if the list contains at least one -`element` for which `f` returns \`true'. - -Use [`some`](#some) with a predicate instead. - -## Examples - -```rescript -list{1, 2, 3}->List.has(2, (a, b) => a == b) == true - -list{1, 2, 3}->List.has(4, (a, b) => a == b) == false - -list{-1, -2, -3}->List.has(2, (a, b) => Math.Int.abs(a) == Math.Int.abs(b)) == true -``` -*/ -@deprecated("Use `some` instead") -let has: (list<'a>, 'b, ('a, 'b) => bool) => bool - /** `includes(list, item)` checks whether `list` includes `item` using strict equality. @@ -893,88 +784,6 @@ List.unzip(list{("H", "W"), ("e", "o"), ("l", "r"), ("l", "l"), ("o", "d"), (" " */ let unzip: list<('a, 'b)> => (list<'a>, list<'b>) -/** -`getAssoc(list, k, f)` return the second element of a pair in `list` where -the first element equals `k` as per the predicate function `f`, or `None` if -not found. - -## Examples - -```rescript -list{(1, "a"), (2, "b"), (3, "c")}->List.getAssoc(3, (a, b) => a == b) // Some("c") - -list{(9, "morning"), (15, "afternoon"), (22, "night")}->List.getAssoc(15, (k, item) => - k /* 15 */ == item -) == Some("afternoon") -/* 9, 5, 22 */ -``` -*/ -@deprecated("Use a `Map` instead") -let getAssoc: (list<('a, 'c)>, 'b, ('a, 'b) => bool) => option<'c> - -/** -`hasAssoc(list, k, f)` returns `true` if there is a pair in `list` where the -first element equals `k` as per the predicate function `f`. - -## Examples - -```rescript -list{(1, "a"), (2, "b"), (3, "c")}->List.hasAssoc(1, (a, b) => a == b) // true - -list{(9, "morning"), (15, "afternoon"), (22, "night")}->List.hasAssoc(25, (k, item) => - k /* 25 */ == item -) == false -/* 9, 5, 22 */ -``` -*/ -@deprecated("Use a `Map` instead") -let hasAssoc: (list<('a, 'c)>, 'b, ('a, 'b) => bool) => bool - -/** -`removeAssoc(list, k, f)` return a list after removing the first pair whose -first value is `k` per the equality predicate `f`, if not found, return a new -list identical to `list`. - -## Examples - -```rescript -list{(1, "a"), (2, "b"), (3, "c")}->List.removeAssoc(1, (a, b) => a == b) // list{(2, "b"), (3, "c")} - -list{(9, "morning"), (15, "afternoon"), (22, "night")}->List.removeAssoc(9, (k, item) => - k /* 9 */ == item -) == list{(15, "afternoon"), (22, "night")} -/* 9, 5, 22 */ -``` -*/ -@deprecated("Use a `Map` instead") -let removeAssoc: (list<('a, 'c)>, 'b, ('a, 'b) => bool) => list<('a, 'c)> - -/** -`setAssoc(list, k, v, f)`. If `k` exists in `list` by satisfying the `f` -predicate, return a new list with the key and value replaced by the new `k` and -`v`, otherwise, return a new list with the pair `k`, `v` added to the head of -`list`. - -## Examples - -```rescript -list{(1, "a"), (2, "b"), (3, "c")}->List.setAssoc(2, "x", (a, b) => a == b) == - list{(1, "a"), (2, "x"), (3, "c")} - -list{(1, "a"), (3, "c")}->List.setAssoc(2, "b", (a, b) => a == b) == - list{(2, "b"), (1, "a"), (3, "c")} - -list{(9, "morning"), (3, "morning?!"), (22, "night")}->List.setAssoc(15, "afternoon", (a, b) => - mod(a, 12) == mod(b, 12) -) == list{(9, "morning"), (15, "afternoon"), (22, "night")} -``` - -**Please note**: In the last example, since: `15 mod 12` equals `3 mod 12`. Both -the key _and_ the value are replaced in the list. -*/ -@deprecated("Use a `Map` instead") -let setAssoc: (list<('a, 'c)>, 'a, 'c, ('a, 'a) => bool) => list<('a, 'c)> - /** `sort(list, f)` returns a sorted list. diff --git a/packages/@rescript/runtime/Stdlib_Null.res b/packages/@rescript/runtime/Stdlib_Null.res index 9ce0dc44674..cc9ee2f8a9f 100644 --- a/packages/@rescript/runtime/Stdlib_Null.res +++ b/packages/@rescript/runtime/Stdlib_Null.res @@ -27,16 +27,12 @@ let getOr = (value, default) => | None => default } -let getWithDefault = getOr - let getOrThrow: t<'a> => 'a = value => switch value->toOption { | Some(x) => x | None => throw(Invalid_argument("Null.getOrThrow: value is null")) } -let getExn = getOrThrow - external getUnsafe: t<'a> => 'a = "%identity" let forEach = (value, f) => @@ -57,8 +53,6 @@ let mapOr = (value, default, f) => | None => default } -let mapWithDefault = mapOr - let flatMap = (value, f) => switch value->toOption { | Some(x) => f(x) diff --git a/packages/@rescript/runtime/Stdlib_Null.resi b/packages/@rescript/runtime/Stdlib_Null.resi index c20f13142ba..6726c2c0c29 100644 --- a/packages/@rescript/runtime/Stdlib_Null.resi +++ b/packages/@rescript/runtime/Stdlib_Null.resi @@ -133,39 +133,6 @@ Null.null->Null.toOption->greet // "Greetings Anonymous" */ let getOr: (t<'a>, 'a) => 'a -@deprecated({ - reason: "Use getOr instead", - migrate: Null.getOr(), -}) -let getWithDefault: (t<'a>, 'a) => 'a - -/** -`getExn(value)` throws an exception if `null`, otherwise returns the value. - -```rescript -Null.getExn(Null.make(3)) == 3 - -switch Null.getExn(%raw("'ReScript'")) { -| exception Invalid_argument(_) => assert(false) -| value => value == "ReScript" -} - -switch Null.getExn(%raw("null")) { -| exception Invalid_argument(_) => assert(true) -| _ => assert(false) -} -``` - -## Exceptions - -- Throws `Invalid_argument` if `value` is `null` -*/ -@deprecated({ - reason: "Use `getOrThrow` instead", - migrate: Null.getOrThrow(), -}) -let getExn: t<'a> => 'a - /** `getOrThrow(value)` throws an exception if `null`, otherwise returns the value. @@ -247,12 +214,6 @@ noneValue->Null.mapOr(0, x => x + 5) // 0 */ let mapOr: (t<'a>, 'b, 'a => 'b) => 'b -@deprecated({ - reason: "Use mapOr instead", - migrate: Null.mapOr(), -}) -let mapWithDefault: (t<'a>, 'b, 'a => 'b) => 'b - /** `flatMap(value, f)` returns `f(value)` if `value` is not `null`, otherwise returns `value` unchanged. diff --git a/packages/@rescript/runtime/Stdlib_Nullable.res b/packages/@rescript/runtime/Stdlib_Nullable.res index 36eeac3b861..5bad47140ed 100644 --- a/packages/@rescript/runtime/Stdlib_Nullable.res +++ b/packages/@rescript/runtime/Stdlib_Nullable.res @@ -30,16 +30,12 @@ let getOr = (value, default) => | None => default } -let getWithDefault = getOr - let getOrThrow: t<'a> => 'a = value => switch value->toOption { | Some(x) => x | None => throw(Invalid_argument("Nullable.getOrThrow: value is null or undefined")) } -let getExn = getOrThrow - external getUnsafe: t<'a> => 'a = "%identity" let forEach = (value, f) => @@ -60,8 +56,6 @@ let mapOr = (value, default, f) => | None => default } -let mapWithDefault = mapOr - let flatMap = (value, f) => switch value->toOption { | Some(x) => f(x) diff --git a/packages/@rescript/runtime/Stdlib_Nullable.resi b/packages/@rescript/runtime/Stdlib_Nullable.resi index 493e6a38ed9..0fca9f47eca 100644 --- a/packages/@rescript/runtime/Stdlib_Nullable.resi +++ b/packages/@rescript/runtime/Stdlib_Nullable.resi @@ -130,42 +130,6 @@ Nullable.null->Nullable.toOption->greet // "Greetings Anonymous" */ let getOr: (t<'a>, 'a) => 'a -@deprecated({ - reason: "Use getOr instead", - migrate: Nullable.getOr(), -}) -let getWithDefault: (t<'a>, 'a) => 'a - -/** -`getExn(value)` throws an exception if `null` or `undefined`, otherwise returns the value. - -```rescript -switch Nullable.getExn(%raw("'Hello'")) { -| exception Invalid_argument(_) => assert(false) -| value => value == "Hello" -} - -switch Nullable.getExn(%raw("null")) { -| exception Invalid_argument(_) => assert(true) -| _ => assert(false) -} - -switch Nullable.getExn(%raw("undefined")) { -| exception Invalid_argument(_) => assert(true) -| _ => assert(false) -} -``` - -## Exceptions - -- Throws `Invalid_argument` if `value` is `null` or `undefined` -*/ -@deprecated({ - reason: "Use `getOrThrow` instead", - migrate: Nullable.getOrThrow(), -}) -let getExn: t<'a> => 'a - /** `getOrThrow(value)` throws an exception if `null` or `undefined`, otherwise returns the value. @@ -251,12 +215,6 @@ noneValue->Nullable.mapOr(0, x => x + 5) // 0 */ let mapOr: (t<'a>, 'b, 'a => 'b) => 'b -@deprecated({ - reason: "Use mapOr instead", - migrate: Nullable.mapOr(), -}) -let mapWithDefault: (t<'a>, 'b, 'a => 'b) => 'b - /** `flatMap(value, f)` returns `f(value)` if `value` is not `null` or `undefined`, otherwise returns `value` unchanged. diff --git a/packages/@rescript/runtime/Stdlib_Option.res b/packages/@rescript/runtime/Stdlib_Option.res index fde39b5e902..660f5a60a30 100644 --- a/packages/@rescript/runtime/Stdlib_Option.res +++ b/packages/@rescript/runtime/Stdlib_Option.res @@ -29,8 +29,6 @@ let getOrThrow = (x, ~message=?) => ) } -let getExn = getOrThrow - external getUnsafe: option<'a> => 'a = "%identity" let mapOr = (opt, default, f) => @@ -39,8 +37,6 @@ let mapOr = (opt, default, f) => | None => default } -let mapWithDefault = mapOr - let map = (opt, f) => switch opt { | Some(x) => Some(f(x)) @@ -59,8 +55,6 @@ let getOr = (opt, default) => | None => default } -let getWithDefault = getOr - let orElse = (opt, other) => switch opt { | Some(_) as some => some diff --git a/packages/@rescript/runtime/Stdlib_Option.resi b/packages/@rescript/runtime/Stdlib_Option.resi index 790f2e140f0..39e0e755b9c 100644 --- a/packages/@rescript/runtime/Stdlib_Option.resi +++ b/packages/@rescript/runtime/Stdlib_Option.resi @@ -52,33 +52,6 @@ Option.forEach(None, x => Console.log(x)) // returns () */ let forEach: (option<'a>, 'a => unit) => unit -/** -`getExn(opt, ~message=?)` returns `value` if `opt` is `Some(value)`, otherwise throws an exception with the message provided, or a generic message if no message was provided. - -```rescript -Option.getExn(Some(3)) == 3 - -switch Option.getExn(None) { -| exception _ => assert(true) -| _ => assert(false) -} - -switch Option.getExn(None, ~message="was None!") { -| exception _ => assert(true) // Throws a JsError with the message "was None!" -| _ => assert(false) -} -``` - -## Exceptions - -- Throws an error if `opt` is `None` -*/ -@deprecated({ - reason: "Use `getOrThrow` instead", - migrate: Option.getOrThrow(), -}) -let getExn: (option<'a>, ~message: string=?) => 'a - /** `getOrThrow(opt, ~message=?)` returns `value` if `opt` is `Some(value)`, otherwise throws an exception with the message provided, or a generic message if no message was provided. @@ -133,12 +106,6 @@ noneValue->Option.mapOr(0, x => x + 5) // 0 */ let mapOr: (option<'a>, 'b, 'a => 'b) => 'b -@deprecated({ - reason: "Use mapOr instead", - migrate: Option.mapOr(), -}) -let mapWithDefault: (option<'a>, 'b, 'a => 'b) => 'b - /** `map(opt, f)` returns `Some(f(value))` if `opt` is `Some(value)`, otherwise `None`. @@ -188,12 +155,6 @@ None->greet // "Greetings Anonymous" */ let getOr: (option<'a>, 'a) => 'a -@deprecated({ - reason: "Use getOr instead", - migrate: Option.getOr(), -}) -let getWithDefault: (option<'a>, 'a) => 'a - /** `orElse(opt1, opt2)` returns `opt2` if `opt1` is `None`, otherwise `opt1`. diff --git a/packages/@rescript/runtime/Stdlib_Promise.res b/packages/@rescript/runtime/Stdlib_Promise.res index a5b5e4b0293..be97e54ed43 100644 --- a/packages/@rescript/runtime/Stdlib_Promise.res +++ b/packages/@rescript/runtime/Stdlib_Promise.res @@ -109,6 +109,4 @@ external race: array> => t<'a> = "race" @scope("Promise") @val external any: array> => t<'a> = "any" -external done: promise<'a> => unit = "%ignore" - external ignore: promise<'a> => unit = "%ignore" diff --git a/packages/@rescript/runtime/Stdlib_Promise.resi b/packages/@rescript/runtime/Stdlib_Promise.resi index 6ea5d741580..49c681afed1 100644 --- a/packages/@rescript/runtime/Stdlib_Promise.resi +++ b/packages/@rescript/runtime/Stdlib_Promise.resi @@ -427,16 +427,6 @@ external allSettled6: ((t<'a>, t<'b>, t<'c>, t<'d>, t<'e>, t<'f>)) => t<( settledResult<'f>, )> = "allSettled" -/** -`done(p)` is a safe way to ignore a promise. If a value is anything else than a -promise, it will throw a type error. -*/ -@deprecated({ - reason: "Please use `Promise.ignore` instead", - migrate: Promise.ignore(), -}) -external done: promise<'a> => unit = "%ignore" - /** `ignore(promise)` ignores the provided promise and returns unit. diff --git a/packages/@rescript/runtime/Stdlib_RegExp.res b/packages/@rescript/runtime/Stdlib_RegExp.res index 3f5c9269a6d..1e37683f997 100644 --- a/packages/@rescript/runtime/Stdlib_RegExp.res +++ b/packages/@rescript/runtime/Stdlib_RegExp.res @@ -10,7 +10,6 @@ module Result = { } @new external fromString: (string, ~flags: string=?) => t = "RegExp" -@new external fromStringWithFlags: (string, ~flags: string) => t = "RegExp" external escape: string => string = "RegExp.escape" diff --git a/packages/@rescript/runtime/Stdlib_RegExp.resi b/packages/@rescript/runtime/Stdlib_RegExp.resi index 0d5b95e2f36..0254af0f573 100644 --- a/packages/@rescript/runtime/Stdlib_RegExp.resi +++ b/packages/@rescript/runtime/Stdlib_RegExp.resi @@ -102,29 +102,6 @@ switch regexp->RegExp.exec("FOO") { @new external fromString: (string, ~flags: string=?) => t = "RegExp" -/** -`fromStringWithFlags(string)` creates a `RegExp.t` from the provided string, using the provided `flags`. This can then be used to match on strings using `RegExp.exec`. - -See [`RegExp parameters`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/RegExp#parameters) on MDN. - -## Examples -```rescript -// Match the first word in a sentence -let regexp = RegExp.fromStringWithFlags("\\w+", ~flags="g") - -switch regexp->RegExp.exec("ReScript is pretty cool, right?") { -| None => Console.log("Nope, no match...") -| Some(result) => Console.log(result->RegExp.Result.fullMatch) // Prints "ReScript" -} -``` -*/ -@deprecated({ - reason: "Use `fromString` instead", - migrate: RegExp.fromString(~flags=%insert.labelledArgument("flags")), -}) -@new -external fromStringWithFlags: (string, ~flags: string) => t = "RegExp" - /** `escape(string)` escapes any potential regex syntax characters in a string. @@ -229,10 +206,10 @@ See [`RegExp.ignoreCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScrip ## Examples ```rescript -let regexp1 = RegExp.fromStringWithFlags("\\w+", ~flags="g") +let regexp1 = RegExp.fromString("\\w+", ~flags="g") Console.log(regexp1->RegExp.ignoreCase) // Logs `false`, since `i` is not set -let regexp2 = RegExp.fromStringWithFlags("\\w+", ~flags="i") +let regexp2 = RegExp.fromString("\\w+", ~flags="i") Console.log(regexp2->RegExp.ignoreCase) // Logs `true`, since `i` is set ``` */ @@ -246,10 +223,10 @@ See [`RegExp.global`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Re ## Examples ```rescript -let regexp1 = RegExp.fromStringWithFlags("\\w+", ~flags="g") +let regexp1 = RegExp.fromString("\\w+", ~flags="g") Console.log(regexp1->RegExp.global) // Logs `true`, since `g` is set -let regexp2 = RegExp.fromStringWithFlags("\\w+", ~flags="i") +let regexp2 = RegExp.fromString("\\w+", ~flags="i") Console.log(regexp2->RegExp.global) // Logs `false`, since `g` is not set ``` */ @@ -263,10 +240,10 @@ See [`RegExp.multiline`](https://developer.mozilla.org/en-US/docs/Web/JavaScript ## Examples ```rescript -let regexp1 = RegExp.fromStringWithFlags("\\w+", ~flags="g") +let regexp1 = RegExp.fromString("\\w+", ~flags="g") Console.log(regexp1->RegExp.multiline) // Logs `false`, since `m` is not set -let regexp2 = RegExp.fromStringWithFlags("\\w+", ~flags="mi") +let regexp2 = RegExp.fromString("\\w+", ~flags="mi") Console.log(regexp2->RegExp.multiline) // Logs `true`, since `m` is set ``` */ @@ -280,7 +257,7 @@ See [`RegExp.source`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Re ## Examples ```rescript -let regexp = RegExp.fromStringWithFlags("\\w+", ~flags="g") +let regexp = RegExp.fromString("\\w+", ~flags="g") Console.log(regexp->RegExp.source) // Logs `\w+`, the source text of the `RegExp` ``` */ @@ -294,10 +271,10 @@ See [`RegExp.sticky`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Re ## Examples ```rescript -let regexp1 = RegExp.fromStringWithFlags("\\w+", ~flags="g") +let regexp1 = RegExp.fromString("\\w+", ~flags="g") Console.log(regexp1->RegExp.unicode) // Logs `false`, since `y` is not set -let regexp2 = RegExp.fromStringWithFlags("\\w+", ~flags="my") +let regexp2 = RegExp.fromString("\\w+", ~flags="my") Console.log(regexp2->RegExp.unicode) // Logs `true`, since `y` is set ``` */ @@ -311,10 +288,10 @@ See [`RegExp.unicode`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/R ## Examples ```rescript -let regexp1 = RegExp.fromStringWithFlags("\\w+", ~flags="g") +let regexp1 = RegExp.fromString("\\w+", ~flags="g") Console.log(regexp1->RegExp.unicode) // Logs `false`, since `u` is not set -let regexp2 = RegExp.fromStringWithFlags("\\w+", ~flags="mu") +let regexp2 = RegExp.fromString("\\w+", ~flags="mu") Console.log(regexp2->RegExp.unicode) // Logs `true`, since `u` is set ``` */ diff --git a/packages/@rescript/runtime/Stdlib_Result.res b/packages/@rescript/runtime/Stdlib_Result.res index aaea0df5487..7df0f43a914 100644 --- a/packages/@rescript/runtime/Stdlib_Result.res +++ b/packages/@rescript/runtime/Stdlib_Result.res @@ -17,16 +17,12 @@ let getOrThrow = (x, ~message=?) => ) } -let getExn = getOrThrow - let mapOr = (opt, default, f) => switch opt { | Ok(x) => f(x) | Error(_) => default } -let mapWithDefault = mapOr - let map = (opt, f) => switch opt { | Ok(x) => Ok(f(x)) @@ -45,8 +41,6 @@ let getOr = (opt, default) => | Error(_) => default } -let getWithDefault = getOr - let isOk = x => switch x { | Ok(_) => true diff --git a/packages/@rescript/runtime/Stdlib_Result.resi b/packages/@rescript/runtime/Stdlib_Result.resi index f475b62ce10..9ca4b71d06a 100644 --- a/packages/@rescript/runtime/Stdlib_Result.resi +++ b/packages/@rescript/runtime/Stdlib_Result.resi @@ -29,29 +29,6 @@ query operation: */ type t<'res, 'err> = result<'res, 'err> = Ok('res) | Error('err) -/** - `getExn(res, ~message=?)` returns `n` if `res` is `Ok(n)`, otherwise throws an exception with the message provided, or a generic message if no message was provided. - - ```res example - Result.getExn(Result.Ok(42)) == 42 - - switch Result.getExn(Error("Invalid data")) { - | exception _ => true - | _ => false - } == true - - switch Result.getExn(Error("Invalid data"), ~message="was Error!") { - | exception _ => true // Throws a JsError with the message "was Error!" - | _ => false - } == true - ``` -*/ -@deprecated({ - reason: "Use 'getOrThrow' instead", - migrate: Result.getOrThrow(), -}) -let getExn: (result<'a, 'b>, ~message: string=?) => 'a - /** `getOrThrow(res, ~message=?)` returns `n` if `res` is `Ok(n)`, otherwise throws an exception with the message provided, or a generic message if no message was provided. @@ -86,12 +63,6 @@ Result.mapOr(error, 0, x => x / 2) == 0 */ let mapOr: (result<'a, 'c>, 'b, 'a => 'b) => 'b -@deprecated({ - reason: "Use mapOr instead", - migrate: Result.mapOr(), -}) -let mapWithDefault: (result<'a, 'c>, 'b, 'a => 'b) => 'b - /** `map(res, f)`: When res is `Ok(n)`, returns `Ok(f(n))`. Otherwise returns res unchanged. Function `f` takes a value of the same type as `n` and returns an @@ -146,12 +117,6 @@ Result.getOr(Error("Invalid Data"), 0) == 0 */ let getOr: (result<'a, 'b>, 'a) => 'a -@deprecated({ - reason: "Use getOr instead", - migrate: Result.getOr(), -}) -let getWithDefault: (result<'a, 'b>, 'a) => 'a - /** `isOk(res)`: Returns `true` if `res` is of the form `Ok(n)`, `false` if it is the `Error(e)` variant. */ diff --git a/packages/@rescript/runtime/Stdlib_String.res b/packages/@rescript/runtime/Stdlib_String.res index 40c533509ce..3860eb96367 100644 --- a/packages/@rescript/runtime/Stdlib_String.res +++ b/packages/@rescript/runtime/Stdlib_String.res @@ -67,41 +67,6 @@ type normalizeForm = [#NFC | #NFD | #NFKC | #NFKD] @send external replaceAll: (string, string, string) => string = "replaceAll" @send external replaceAllRegExp: (string, Stdlib_RegExp.t, string) => string = "replaceAll" -@send -external unsafeReplaceRegExpBy0: ( - string, - Stdlib_RegExp.t, - (~match: string, ~offset: int, ~input: string) => string, -) => string = "replace" - -@send -external unsafeReplaceRegExpBy1: ( - string, - Stdlib_RegExp.t, - (~match: string, ~group1: string, ~offset: int, ~input: string) => string, -) => string = "replace" - -@send -external unsafeReplaceRegExpBy2: ( - string, - Stdlib_RegExp.t, - (~match: string, ~group1: string, ~group2: string, ~offset: int, ~input: string) => string, -) => string = "replace" - -@send -external unsafeReplaceRegExpBy3: ( - string, - Stdlib_RegExp.t, - ( - ~match: string, - ~group1: string, - ~group2: string, - ~group3: string, - ~offset: int, - ~input: string, - ) => string, -) => string = "replace" - @send external replaceRegExpBy0Unsafe: ( string, @@ -145,12 +110,6 @@ let searchOpt = (s, re) => } @send external slice: (string, ~start: int, ~end: int=?) => string = "slice" -@deprecated({ - reason: "Use `slice` instead", - migrate: String.slice(), -}) -@send -external sliceToEnd: (string, ~start: int) => string = "slice" @send external split: (string, string) => array = "split" @send external splitAtMost: (string, string, ~limit: int) => array = "split" @@ -163,12 +122,6 @@ external splitByRegExpAtMost: (string, Stdlib_RegExp.t, ~limit: int) => array bool = "startsWith" @send external substring: (string, ~start: int, ~end: int=?) => string = "substring" -@deprecated({ - reason: "Use `substring` instead", - migrate: String.substring(), -}) -@send -external substringToEnd: (string, ~start: int) => string = "substring" @send external toLowerCase: string => string = "toLowerCase" @send external toLocaleLowerCase: string => string = "toLocaleLowerCase" @@ -196,7 +149,7 @@ let capitalize = s => if isEmpty(s) { s } else { - toUpperCase(getUnsafe(s, 0)) ++ sliceToEnd(s, ~start=1) + toUpperCase(getUnsafe(s, 0)) ++ slice(s, ~start=1) } external ignore: string => unit = "%ignore" diff --git a/packages/@rescript/runtime/Stdlib_String.resi b/packages/@rescript/runtime/Stdlib_String.resi index 275bdcd1646..b42ab332b8f 100644 --- a/packages/@rescript/runtime/Stdlib_String.resi +++ b/packages/@rescript/runtime/Stdlib_String.resi @@ -596,114 +596,6 @@ String.replaceAllRegExp("aabbcc", /b/g, ".") == "aa..cc" @send external replaceAllRegExp: (string, Stdlib_RegExp.t, string) => string = "replaceAll" -/** -`unsafeReplaceRegExpBy0(str, regex, f)` returns a new `string` with some or all -matches of a pattern with no capturing parentheses replaced by the value -returned from the given function. The function receives as its parameters the -matched string, the offset at which the match begins, and the whole string being -matched. -See [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) on MDN. - -## Examples - -```rescript -let str = "beautiful vowels" -let re = /[aeiou]/g -let matchFn = (~match, ~offset as _, ~input as _) => String.toUpperCase(match) -String.unsafeReplaceRegExpBy0(str, re, matchFn) == "bEAUtIfUl vOwEls" -``` -*/ -@deprecated({ - reason: "Use `replaceRegExpBy0Unsafe` instead", - migrate: String.replaceRegExpBy0Unsafe(), -}) -@send -external unsafeReplaceRegExpBy0: ( - string, - Stdlib_RegExp.t, - (~match: string, ~offset: int, ~input: string) => string, -) => string = "replace" - -/** -`unsafeReplaceRegExpBy1(str, regexp, f)`. Like `unsafeReplaceRegExpBy0`, but `f` -has `group1` parameter. -See [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) on MDN. - -## Examples - -```rescript -let str = "Jony is 40" -let re = /(Jony is )\d+/g -let matchFn = (~match as _, ~group1, ~offset as _, ~input as _) => { - group1 ++ "41" -} -String.unsafeReplaceRegExpBy1(str, re, matchFn) == "Jony is 41" -``` -*/ -@deprecated({ - reason: "Use `replaceRegExpBy1Unsafe` instead", - migrate: String.replaceRegExpBy1Unsafe(), -}) -@send -external unsafeReplaceRegExpBy1: ( - string, - Stdlib_RegExp.t, - (~match: string, ~group1: string, ~offset: int, ~input: string) => string, -) => string = "replace" - -/** -`unsafeReplaceRegExpBy2(str, regexp, f)`. Like `unsafeReplaceRegExpBy1`, but `f` -has two group parameters. -See [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) on MDN. - -## Examples - -```rescript -let str = "7 times 6" -let re = /(\d+) times (\d+)/ -let matchFn = (~match as _, ~group1, ~group2, ~offset as _, ~input as _) => { - switch (Int.fromString(group1), Int.fromString(group2)) { - | (Some(x), Some(y)) => Int.toString(x * y) - | _ => "???" - } -} -String.unsafeReplaceRegExpBy2(str, re, matchFn) == "42" -``` -*/ -@deprecated({ - reason: "Use `replaceRegExpBy2Unsafe` instead", - migrate: String.replaceRegExpBy2Unsafe(), -}) -@send -external unsafeReplaceRegExpBy2: ( - string, - Stdlib_RegExp.t, - (~match: string, ~group1: string, ~group2: string, ~offset: int, ~input: string) => string, -) => string = "replace" - -/** -`unsafeReplaceRegExpBy3(str, regexp, f)`. Like `unsafeReplaceRegExpBy2`, but `f` -has three group parameters. -See [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) on MDN. -*/ -@deprecated({ - reason: "Use `replaceRegExpBy3Unsafe` instead", - migrate: String.replaceRegExpBy3Unsafe(), -}) -@send -external unsafeReplaceRegExpBy3: ( - string, - Stdlib_RegExp.t, - ( - ~match: string, - ~group1: string, - ~group2: string, - ~group3: string, - ~offset: int, - ~input: string, - ) => string, -) => string = "replace" - /** `replaceRegExpBy0Unsafe(str, regex, f)` returns a new `string` with some or all matches of a pattern with no capturing parentheses replaced by the value @@ -877,28 +769,6 @@ String.slice("Hello World", ~start=6) == "World" @send external slice: (string, ~start: int, ~end: int=?) => string = "slice" -/** -`sliceToEnd(str, ~start)` returns the substring of `str` starting at character -`start` to the end of the string. -- If `start` is negative, then it is evaluated as `length(str - start)`. -- If `start` is greater than the length of `str`, then sliceToEnd returns the empty string. - See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN. - -## Examples - -```rescript -String.sliceToEnd("abcdefg", ~start=4) == "efg" -String.sliceToEnd("abcdefg", ~start=-2) == "fg" -String.sliceToEnd("abcdefg", ~start=7) == "" -``` -*/ -@deprecated({ - reason: "Use `slice` instead", - migrate: String.slice(), -}) -@send -external sliceToEnd: (string, ~start: int) => string = "slice" - /** `split(str, delimiter)` splits the given `str` at every occurrence of `delimiter` and returns an array of the resulting substrings. @@ -1022,29 +892,6 @@ String.substring("Hello World", ~start=6) == "World" @send external substring: (string, ~start: int, ~end: int=?) => string = "substring" -/** -`substringToEnd(str, ~start)` returns the substring of `str` from position -`start` to the end. -- If `start` is less than or equal to zero, the entire string is returned. -- If `start` is greater than or equal to the length of `str`, the empty string - is returned. - See [`String.substring`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring) on MDN. - -## Examples - -```rescript -String.substringToEnd("playground", ~start=4) == "ground" -String.substringToEnd("playground", ~start=-3) == "playground" -String.substringToEnd("playground", ~start=12) == "" -``` -*/ -@deprecated({ - reason: "Use `substring` instead", - migrate: String.substring(), -}) -@send -external substringToEnd: (string, ~start: int) => string = "substring" - /** `toLowerCase(str)` converts `str` to lower case using the locale-insensitive case mappings in the Unicode Character Database. Notice that the conversion can diff --git a/packages/@rescript/runtime/Stdlib_TypedArray.res b/packages/@rescript/runtime/Stdlib_TypedArray.res index 00fceea6ead..fb0e71bcdc3 100644 --- a/packages/@rescript/runtime/Stdlib_TypedArray.res +++ b/packages/@rescript/runtime/Stdlib_TypedArray.res @@ -127,28 +127,6 @@ TypedArray.toString(view) == "10,10,20" */ @send external copyAllWithin: (t<'a>, ~target: int) => array<'a> = "copyWithin" /** -`copyWithinToEnd(typedArray, ~target, ~start)` copies values from `start` through the end of the view into the range beginning at `target`. - -Beware this will *mutate* the typed array. - -See [`TypedArray.prototype.copyWithin`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/copyWithin) on MDN. - -## Examples - -```rescript -let view = (Int32Array.fromArray([1, 2, 3, 4]) :> TypedArray.t) -let _ = TypedArray.copyWithinToEnd(view, ~target=0, ~start=2) -TypedArray.toString(view) == "3,4,3,4" -``` -*/ -@deprecated({ - reason: "Use `copyWithin` instead", - migrate: TypedArray.copyWithin(), -}) -@send -@send -external copyWithinToEnd: (t<'a>, ~target: int, ~start: int) => array<'a> = "copyWithin" -/** `copyWithin(typedArray, ~target, ~start, ~end)` copies the section `[start, end)` onto the range beginning at `target`. Beware this will *mutate* the typed array. @@ -182,18 +160,6 @@ TypedArray.toString(view) == "9,9,9" ``` */ @send external fillAll: (t<'a>, 'a) => t<'a> = "fill" -/** -`fillToEnd(typedArray, value, ~start)` fills from `start` through the end with `value`. - -Beware this will *mutate* the typed array. -*/ -@deprecated({ - reason: "Use `fill` instead", - migrate: TypedArray.fill(), -}) -@send -@send -external fillToEnd: (t<'a>, 'a, ~start: int) => t<'a> = "fill" /** `fill(typedArray, value, ~start, ~end)` fills the half-open interval `[start, end)` with `value`. @@ -335,15 +301,6 @@ See [`TypedArray.prototype.slice`](https://developer.mozilla.org/en-US/docs/Web/ */ @send external slice: (t<'a>, ~start: int, ~end: int=?) => t<'a> = "slice" /** -`sliceToEnd(typedArray, ~start)` returns the elements from `start` through the end in a new typed array. -*/ -@deprecated({ - reason: "Use `slice` instead", - migrate: TypedArray.slice(), -}) -@send -external sliceToEnd: (t<'a>, ~start: int) => t<'a> = "slice" -/** `copy(typedArray)` produces a shallow copy of the typed array. */ @send external copy: t<'a> => t<'a> = "slice" @@ -354,15 +311,6 @@ external sliceToEnd: (t<'a>, ~start: int) => t<'a> = "slice" See [`TypedArray.prototype.subarray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray) on MDN. */ @send external subarray: (t<'a>, ~start: int, ~end: int=?) => t<'a> = "subarray" -/** -`subarrayToEnd(typedArray, ~start)` returns a new view from `start` to the end of the buffer. -*/ -@deprecated({ - reason: "Use `subarray` instead", - migrate: TypedArray.subarray(), -}) -@send -external subarrayToEnd: (t<'a>, ~start: int) => t<'a> = "subarray" /** `toString(typedArray)` returns a comma-separated string of the elements. diff --git a/packages/@rescript/runtime/Stdlib_Uint16Array.res b/packages/@rescript/runtime/Stdlib_Uint16Array.res index 7bd234b7f7d..5d3f8a60346 100644 --- a/packages/@rescript/runtime/Stdlib_Uint16Array.res +++ b/packages/@rescript/runtime/Stdlib_Uint16Array.res @@ -27,29 +27,6 @@ external fromArray: array => t = "Uint16Array" @new external fromBuffer: (Stdlib_ArrayBuffer.t, ~byteOffset: int=?, ~length: int=?) => t = "Uint16Array" -/** `fromBufferToEnd` creates a `Uint16Array` from an `ArrayBuffer.t`, starting at a particular offset and continuing through to the end. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array/Uint16Array) - -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. -*/ -@deprecated({ - reason: "Use `fromBuffer` instead", - migrate: Uint16Array.fromBuffer(), -}) -@new -external fromBufferToEnd: (Stdlib_ArrayBuffer.t, ~byteOffset: int) => t = "Uint16Array" - -/** `fromBufferWithRange` creates a `Uint16Array` from an `ArrayBuffer.t`, starting at a particular offset and consuming `length` **bytes**. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array/Uint16Array) - -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. -*/ -@deprecated({ - reason: "Use `fromBuffer` instead", - migrate: Uint16Array.fromBuffer(), -}) -@new -external fromBufferWithRange: (Stdlib_ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = - "Uint16Array" - /** `fromLength` creates a zero-initialized `Uint16Array` to hold the specified count of numbers; this is **not** a byte length. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array/Uint16Array) **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. @@ -62,18 +39,6 @@ external fromLength: int => t = "Uint16Array" @val external fromArrayLikeOrIterable: ('a, ~map: ('b, int) => int=?) => t = "Uint16Array.from" -/** `fromArrayLikeOrIterableWithMap` creates a `Uint16Array` from an array-like or iterable object and applies the mapping function to each item. The mapping function expects (value, index). See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from) -*/ -@deprecated({ - reason: "Use `fromArrayLikeOrIterable` instead", - migrate: Uint16Array.fromArrayLikeOrIterable( - %insert.unlabelledArgument(0), - ~map=%insert.unlabelledArgument(1), - ), -}) -@val -external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => int) => t = "Uint16Array.from" - /** `ignore(uintArray)` ignores the provided uintArray and returns unit. diff --git a/packages/@rescript/runtime/Stdlib_Uint32Array.res b/packages/@rescript/runtime/Stdlib_Uint32Array.res index 5b8d5f7ac42..c8b54a0d536 100644 --- a/packages/@rescript/runtime/Stdlib_Uint32Array.res +++ b/packages/@rescript/runtime/Stdlib_Uint32Array.res @@ -27,29 +27,6 @@ external fromArray: array => t = "Uint32Array" @new external fromBuffer: (Stdlib_ArrayBuffer.t, ~byteOffset: int=?, ~length: int=?) => t = "Uint32Array" -/** `fromBufferToEnd` creates a `Uint32Array` from an `ArrayBuffer.t`, starting at a particular offset and continuing through to the end. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array/Uint32Array) - -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. -*/ -@deprecated({ - reason: "Use `fromBuffer` instead", - migrate: Uint32Array.fromBuffer(), -}) -@new -external fromBufferToEnd: (Stdlib_ArrayBuffer.t, ~byteOffset: int) => t = "Uint32Array" - -/** `fromBufferWithRange` creates a `Uint32Array` from an `ArrayBuffer.t`, starting at a particular offset and consuming `length` **bytes**. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array/Uint32Array) - -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. -*/ -@deprecated({ - reason: "Use `fromBuffer` instead", - migrate: Uint32Array.fromBuffer(), -}) -@new -external fromBufferWithRange: (Stdlib_ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = - "Uint32Array" - /** `fromLength` creates a zero-initialized `Uint32Array` to hold the specified count of numbers; this is **not** a byte length. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array/Uint32Array) **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. @@ -62,18 +39,6 @@ external fromLength: int => t = "Uint32Array" @val external fromArrayLikeOrIterable: ('a, ~map: ('b, int) => int=?) => t = "Uint32Array.from" -/** `fromArrayLikeOrIterableWithMap` creates a `Uint32Array` from an array-like or iterable object and applies the mapping function to each item. The mapping function expects (value, index). See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from) -*/ -@deprecated({ - reason: "Use `fromArrayLikeOrIterable` instead", - migrate: Uint32Array.fromArrayLikeOrIterable( - %insert.unlabelledArgument(0), - ~map=%insert.unlabelledArgument(1), - ), -}) -@val -external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => int) => t = "Uint32Array.from" - /** `ignore(uintArray)` ignores the provided uintArray and returns unit. diff --git a/packages/@rescript/runtime/Stdlib_Uint8Array.res b/packages/@rescript/runtime/Stdlib_Uint8Array.res index 861a4b65541..796fc0259e5 100644 --- a/packages/@rescript/runtime/Stdlib_Uint8Array.res +++ b/packages/@rescript/runtime/Stdlib_Uint8Array.res @@ -27,29 +27,6 @@ external fromArray: array => t = "Uint8Array" @new external fromBuffer: (Stdlib_ArrayBuffer.t, ~byteOffset: int=?, ~length: int=?) => t = "Uint8Array" -/** `fromBufferToEnd` creates a `Uint8Array` from an `ArrayBuffer.t`, starting at a particular offset and continuing through to the end. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array/Uint8Array) - -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. -*/ -@deprecated({ - reason: "Use `fromBuffer` instead", - migrate: Uint8Array.fromBuffer(), -}) -@new -external fromBufferToEnd: (Stdlib_ArrayBuffer.t, ~byteOffset: int) => t = "Uint8Array" - -/** `fromBufferWithRange` creates a `Uint8Array` from an `ArrayBuffer.t`, starting at a particular offset and consuming `length` **bytes**. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array/Uint8Array) - -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. -*/ -@deprecated({ - reason: "Use `fromBuffer` instead", - migrate: Uint8Array.fromBuffer(), -}) -@new -external fromBufferWithRange: (Stdlib_ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = - "Uint8Array" - /** `fromLength` creates a zero-initialized `Uint8Array` to hold the specified count of numbers; this is **not** a byte length. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array/Uint8Array) **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. @@ -62,18 +39,6 @@ external fromLength: int => t = "Uint8Array" @val external fromArrayLikeOrIterable: ('a, ~map: ('b, int) => int=?) => t = "Uint8Array.from" -/** `fromArrayLikeOrIterableWithMap` creates a `Uint8Array` from an array-like or iterable object and applies the mapping function to each item. The mapping function expects (value, index). See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from) -*/ -@deprecated({ - reason: "Use `fromArrayLikeOrIterable` instead", - migrate: Uint8Array.fromArrayLikeOrIterable( - %insert.unlabelledArgument(0), - ~map=%insert.unlabelledArgument(1), - ), -}) -@val -external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => int) => t = "Uint8Array.from" - /** `ignore(uintArray)` ignores the provided uintArray and returns unit. diff --git a/packages/@rescript/runtime/Stdlib_Uint8ClampedArray.res b/packages/@rescript/runtime/Stdlib_Uint8ClampedArray.res index 1c8fe85164c..9976381962e 100644 --- a/packages/@rescript/runtime/Stdlib_Uint8ClampedArray.res +++ b/packages/@rescript/runtime/Stdlib_Uint8ClampedArray.res @@ -28,29 +28,6 @@ external fromArray: array => t = "Uint8ClampedArray" external fromBuffer: (Stdlib_ArrayBuffer.t, ~byteOffset: int=?, ~length: int=?) => t = "Uint8ClampedArray" -/** `fromBufferToEnd` creates a `Uint8ClampedArray` from an `ArrayBuffer.t`, starting at a particular offset and continuing through to the end. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray/Uint8ClampedArray) - -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. -*/ -@deprecated({ - reason: "Use `fromBuffer` instead", - migrate: Uint8ClampedArray.fromBuffer(), -}) -@new -external fromBufferToEnd: (Stdlib_ArrayBuffer.t, ~byteOffset: int) => t = "Uint8ClampedArray" - -/** `fromBufferWithRange` creates a `Uint8ClampedArray` from an `ArrayBuffer.t`, starting at a particular offset and consuming `length` **bytes**. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray/Uint8ClampedArray) - -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. -*/ -@deprecated({ - reason: "Use `fromBuffer` instead", - migrate: Uint8ClampedArray.fromBuffer(), -}) -@new -external fromBufferWithRange: (Stdlib_ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = - "Uint8ClampedArray" - /** `fromLength` creates a zero-initialized `Uint8ClampedArray` to hold the specified count of numbers; this is **not** a byte length. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray/Uint8ClampedArray) **Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. @@ -63,18 +40,6 @@ external fromLength: int => t = "Uint8ClampedArray" @val external fromArrayLikeOrIterable: ('a, ~map: ('b, int) => int=?) => t = "Uint8ClampedArray.from" -/** `fromArrayLikeOrIterableWithMap` creates a `Uint8ClampedArray` from an array-like or iterable object and applies the mapping function to each item. The mapping function expects (value, index). See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from) -*/ -@deprecated({ - reason: "Use `fromArrayLikeOrIterable` instead", - migrate: Uint8ClampedArray.fromArrayLikeOrIterable( - %insert.unlabelledArgument(0), - ~map=%insert.unlabelledArgument(1), - ), -}) -@val -external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => int) => t = "Uint8ClampedArray.from" - /** `ignore(uintArray)` ignores the provided uintArray and returns unit. diff --git a/packages/@rescript/runtime/lib/es6/Pervasives.mjs b/packages/@rescript/runtime/lib/es6/Pervasives.mjs index 94da1e06856..ae1b9f17e65 100644 --- a/packages/@rescript/runtime/lib/es6/Pervasives.mjs +++ b/packages/@rescript/runtime/lib/es6/Pervasives.mjs @@ -1,28 +1 @@ - - -import * as Primitive_exceptions from "./Primitive_exceptions.mjs"; - -function failwith(s) { - throw { - RE_EXN_ID: "Failure", - _1: s, - Error: new Error() - }; -} - -function invalid_arg(s) { - throw { - RE_EXN_ID: "Invalid_argument", - _1: s, - Error: new Error() - }; -} - -let Exit = /* @__PURE__ */Primitive_exceptions.create("Pervasives.Exit"); - -export { - failwith, - invalid_arg, - Exit, -} -/* No side effect */ +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/packages/@rescript/runtime/lib/es6/Stdlib.mjs b/packages/@rescript/runtime/lib/es6/Stdlib.mjs index a59df608684..d68c9b5596c 100644 --- a/packages/@rescript/runtime/lib/es6/Stdlib.mjs +++ b/packages/@rescript/runtime/lib/es6/Stdlib.mjs @@ -12,7 +12,7 @@ function assertEqual(a, b) { RE_EXN_ID: "Assert_failure", _1: [ "Stdlib.res", - 163, + 157, 4 ], Error: new Error() @@ -39,10 +39,6 @@ let $$Date; let Dict; -let Exn; - -let $$Error; - let File; let Float; @@ -154,8 +150,6 @@ export { $$DataView, $$Date, Dict, - Exn, - $$Error, File, Float, Int, diff --git a/packages/@rescript/runtime/lib/es6/Stdlib_Bool.mjs b/packages/@rescript/runtime/lib/es6/Stdlib_Bool.mjs index cc03a9357ee..ae2e71a15fa 100644 --- a/packages/@rescript/runtime/lib/es6/Stdlib_Bool.mjs +++ b/packages/@rescript/runtime/lib/es6/Stdlib_Bool.mjs @@ -35,12 +35,9 @@ function fromStringOrThrow(param) { } } -let fromStringExn = fromStringOrThrow; - export { toString, fromString, fromStringOrThrow, - fromStringExn, } /* No side effect */ diff --git a/packages/@rescript/runtime/lib/es6/Stdlib_Error.mjs b/packages/@rescript/runtime/lib/es6/Stdlib_Error.mjs deleted file mode 100644 index 10dd999fec7..00000000000 --- a/packages/@rescript/runtime/lib/es6/Stdlib_Error.mjs +++ /dev/null @@ -1,38 +0,0 @@ - - -import * as Stdlib_Exn from "./Stdlib_Exn.mjs"; -import * as Primitive_option from "./Primitive_option.mjs"; - -function fromException(exn) { - if (exn.RE_EXN_ID === Stdlib_Exn.$$Error) { - return Primitive_option.some(exn._1); - } -} - -let $$EvalError = {}; - -let $$RangeError = {}; - -let $$ReferenceError = {}; - -let $$SyntaxError = {}; - -let $$TypeError = {}; - -let $$URIError = {}; - -function panic(msg) { - throw new Error(`Panic! ${msg}`); -} - -export { - fromException, - $$EvalError, - $$RangeError, - $$ReferenceError, - $$SyntaxError, - $$TypeError, - $$URIError, - panic, -} -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/es6/Stdlib_Exn.mjs b/packages/@rescript/runtime/lib/es6/Stdlib_Exn.mjs deleted file mode 100644 index f4836a1476c..00000000000 --- a/packages/@rescript/runtime/lib/es6/Stdlib_Exn.mjs +++ /dev/null @@ -1,56 +0,0 @@ - - -import * as Primitive_option from "./Primitive_option.mjs"; -import * as Primitive_exceptions from "./Primitive_exceptions.mjs"; - -let $$Error = "JsExn"; - -function asJsExn(exn) { - if (exn.RE_EXN_ID === $$Error) { - return Primitive_option.some(exn._1); - } -} - -let anyToExnInternal = Primitive_exceptions.internalToException; - -function raiseError(str) { - throw new Error(str); -} - -function raiseEvalError(str) { - throw new EvalError(str); -} - -function raiseRangeError(str) { - throw new RangeError(str); -} - -function raiseReferenceError(str) { - throw new ReferenceError(str); -} - -function raiseSyntaxError(str) { - throw new SyntaxError(str); -} - -function raiseTypeError(str) { - throw new TypeError(str); -} - -function raiseUriError(str) { - throw new URIError(str); -} - -export { - $$Error, - asJsExn, - anyToExnInternal, - raiseError, - raiseEvalError, - raiseRangeError, - raiseReferenceError, - raiseSyntaxError, - raiseTypeError, - raiseUriError, -} -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/es6/Stdlib_Int.mjs b/packages/@rescript/runtime/lib/es6/Stdlib_Int.mjs index e93e65af227..60d4f1c5cd2 100644 --- a/packages/@rescript/runtime/lib/es6/Stdlib_Int.mjs +++ b/packages/@rescript/runtime/lib/es6/Stdlib_Int.mjs @@ -54,10 +54,6 @@ function range(start, end, optionsOpt) { return Stdlib_Array.fromInitializer(length, i => start + (i * step | 0) | 0); } -function rangeWithOptions(start, end, options) { - return range(start, end, options); -} - function clamp(min, max, value) { let value$1 = max !== undefined && max < value ? max : value; if (min !== undefined && min > value$1) { @@ -67,14 +63,6 @@ function clamp(min, max, value) { } } -function lnot(x) { - return x ^ -1; -} - -let Bitwise = { - lnot: lnot -}; - let Constants = { minValue: -2147483648, maxValue: 2147483647 @@ -84,8 +72,6 @@ export { Constants, fromString, range, - rangeWithOptions, clamp, - Bitwise, } /* No side effect */ diff --git a/packages/@rescript/runtime/lib/es6/Stdlib_JSON.mjs b/packages/@rescript/runtime/lib/es6/Stdlib_JSON.mjs index bb11e9baf4b..99ba5f7aa68 100644 --- a/packages/@rescript/runtime/lib/es6/Stdlib_JSON.mjs +++ b/packages/@rescript/runtime/lib/es6/Stdlib_JSON.mjs @@ -1,43 +1,6 @@ -function classify(value) { - let match = Object.prototype.toString.call(value); - switch (match) { - case "[object Array]" : - return { - TAG: "Array", - _0: value - }; - case "[object Boolean]" : - return { - TAG: "Bool", - _0: value - }; - case "[object Null]" : - return "Null"; - case "[object Number]" : - return { - TAG: "Number", - _0: value - }; - case "[object String]" : - return { - TAG: "String", - _0: value - }; - default: - return { - TAG: "Object", - _0: value - }; - } -} - -let Classify = { - classify: classify -}; - let Encode = {}; function bool(json) { @@ -86,7 +49,6 @@ let Decode = { }; export { - Classify, Encode, Decode, } diff --git a/packages/@rescript/runtime/lib/es6/Stdlib_Lazy.mjs b/packages/@rescript/runtime/lib/es6/Stdlib_Lazy.mjs index 4be55454161..5f4053ff7ec 100644 --- a/packages/@rescript/runtime/lib/es6/Stdlib_Lazy.mjs +++ b/packages/@rescript/runtime/lib/es6/Stdlib_Lazy.mjs @@ -2,19 +2,12 @@ import * as Primitive_exceptions from "./Primitive_exceptions.mjs"; -function is_val(l) { +function isEvaluated(l) { return l.LAZY_DONE; } let Undefined = /* @__PURE__ */Primitive_exceptions.create("Stdlib_Lazy.Undefined"); -function forward_with_closure(blk, closure) { - let result = closure(); - blk.VAL = result; - blk.LAZY_DONE = true; - return result; -} - function raise_undefined() { throw { RE_EXN_ID: Undefined, @@ -22,14 +15,17 @@ function raise_undefined() { }; } -function force(lzv) { +function get(lzv) { if (lzv.LAZY_DONE) { return lzv.VAL; } else { let closure = lzv.VAL; lzv.VAL = raise_undefined; try { - return forward_with_closure(lzv, closure); + let result = closure(); + lzv.VAL = result; + lzv.LAZY_DONE = true; + return result; } catch (e) { lzv.VAL = () => { throw e; @@ -39,45 +35,17 @@ function force(lzv) { } } -function force_val(lzv) { - if (lzv.LAZY_DONE) { - return lzv.VAL; - } else { - let closure = lzv.VAL; - lzv.VAL = raise_undefined; - return forward_with_closure(lzv, closure); - } -} - -function from_fun(closure) { +function make(closure) { return { LAZY_DONE: false, VAL: closure }; } -function from_val(value) { - return { - LAZY_DONE: true, - VAL: value - }; -} - -let make = from_fun; - -let get = force; - -let isEvaluated = is_val; - export { make, get, isEvaluated, Undefined, - force, - force_val, - from_fun, - from_val, - is_val, } /* No side effect */ diff --git a/packages/@rescript/runtime/lib/es6/Stdlib_List.mjs b/packages/@rescript/runtime/lib/es6/Stdlib_List.mjs index a579fc495b5..0a919324031 100644 --- a/packages/@rescript/runtime/lib/es6/Stdlib_List.mjs +++ b/packages/@rescript/runtime/lib/es6/Stdlib_List.mjs @@ -214,51 +214,6 @@ function copyAuxWitFilterMap(f, _cellX, _prec) { }; } -function removeAssocAuxWithMap(_cellX, x, _prec, f) { - while (true) { - let prec = _prec; - let cellX = _cellX; - if (cellX === 0) { - return false; - } - let t = cellX.tl; - let h = cellX.hd; - if (f(h[0], x)) { - prec.tl = t; - return true; - } - let next = {hd: h, tl: /* [] */0}; - prec.tl = next; - _prec = next; - _cellX = t; - continue; - }; -} - -function setAssocAuxWithMap(_cellX, x, k, _prec, eq) { - while (true) { - let prec = _prec; - let cellX = _cellX; - if (cellX === 0) { - return false; - } - let t = cellX.tl; - let h = cellX.hd; - if (eq(h[0], x)) { - prec.tl = {hd: [ - x, - k - ], tl: t}; - return true; - } - let next = {hd: h, tl: /* [] */0}; - prec.tl = next; - _prec = next; - _cellX = t; - continue; - }; -} - function copyAuxWithMap(_cellX, _prec, f) { while (true) { let prec = _prec; @@ -933,20 +888,6 @@ function some2(_l1, _l2, p) { }; } -function has(_xs, x, eq) { - while (true) { - let xs = _xs; - if (xs === 0) { - return false; - } - if (eq(xs.hd, x)) { - return true; - } - _xs = xs.tl; - continue; - }; -} - function includes(_xs, x) { while (true) { let xs = _xs; @@ -961,80 +902,6 @@ function includes(_xs, x) { }; } -function getAssoc(_xs, x, eq) { - while (true) { - let xs = _xs; - if (xs === 0) { - return; - } - let match = xs.hd; - if (eq(match[0], x)) { - return Primitive_option.some(match[1]); - } - _xs = xs.tl; - continue; - }; -} - -function hasAssoc(_xs, x, eq) { - while (true) { - let xs = _xs; - if (xs === 0) { - return false; - } - if (eq(xs.hd[0], x)) { - return true; - } - _xs = xs.tl; - continue; - }; -} - -function removeAssoc(xs, x, eq) { - if (xs === 0) { - return /* [] */0; - } - let l = xs.tl; - let pair = xs.hd; - if (eq(pair[0], x)) { - return l; - } - let cell = {hd: pair, tl: /* [] */0}; - let removed = removeAssocAuxWithMap(l, x, cell, eq); - if (removed) { - return cell; - } else { - return xs; - } -} - -function setAssoc(xs, x, k, eq) { - if (xs === 0) { - return {hd: [ - x, - k - ], tl: /* [] */0}; - } - let l = xs.tl; - let pair = xs.hd; - if (eq(pair[0], x)) { - return {hd: [ - x, - k - ], tl: l}; - } - let cell = {hd: pair, tl: /* [] */0}; - let replaced = setAssocAuxWithMap(l, x, k, cell, eq); - if (replaced) { - return cell; - } else { - return {hd: [ - x, - k - ], tl: xs}; - } -} - function sort(xs, cmp) { let arr = toArray(xs); arr.sort(cmp); @@ -1173,31 +1040,19 @@ function zip(l1, l2) { let size = length; -let headExn = headOrThrow; - -let tailExn = tailOrThrow; - -let getExn = getOrThrow; - -let toShuffled = shuffle; - export { length, size, head, - headExn, headOrThrow, tail, - tailExn, tailOrThrow, add, get, - getExn, getOrThrow, make, fromInitializer, shuffle, - toShuffled, drop, take, splitAt, @@ -1229,7 +1084,6 @@ export { compareLength, compare, equal, - has, includes, find, filter, @@ -1237,10 +1091,6 @@ export { filterMap, partition, unzip, - getAssoc, - hasAssoc, - removeAssoc, - setAssoc, sort, } /* No side effect */ diff --git a/packages/@rescript/runtime/lib/es6/Stdlib_Null.mjs b/packages/@rescript/runtime/lib/es6/Stdlib_Null.mjs index d40c39055e6..5079e309fc2 100644 --- a/packages/@rescript/runtime/lib/es6/Stdlib_Null.mjs +++ b/packages/@rescript/runtime/lib/es6/Stdlib_Null.mjs @@ -68,24 +68,15 @@ function flatMap(value, f) { } } -let getWithDefault = getOr; - -let getExn = getOrThrow; - -let mapWithDefault = mapOr; - export { equal, compare, fromOption, getOr, - getWithDefault, - getExn, getOrThrow, forEach, map, mapOr, - mapWithDefault, flatMap, } /* No side effect */ diff --git a/packages/@rescript/runtime/lib/es6/Stdlib_Nullable.mjs b/packages/@rescript/runtime/lib/es6/Stdlib_Nullable.mjs index cddd8e8931e..4e67a8e33e2 100644 --- a/packages/@rescript/runtime/lib/es6/Stdlib_Nullable.mjs +++ b/packages/@rescript/runtime/lib/es6/Stdlib_Nullable.mjs @@ -66,24 +66,15 @@ function flatMap(value, f) { } } -let getWithDefault = getOr; - -let getExn = getOrThrow; - -let mapWithDefault = mapOr; - export { equal, compare, fromOption, getOr, - getWithDefault, - getExn, getOrThrow, forEach, map, mapOr, - mapWithDefault, flatMap, } /* No side effect */ diff --git a/packages/@rescript/runtime/lib/es6/Stdlib_Option.mjs b/packages/@rescript/runtime/lib/es6/Stdlib_Option.mjs index 641d5d11299..25164dbf2df 100644 --- a/packages/@rescript/runtime/lib/es6/Stdlib_Option.mjs +++ b/packages/@rescript/runtime/lib/es6/Stdlib_Option.mjs @@ -187,23 +187,14 @@ function all6(param) { } } -let getExn = getOrThrow; - -let mapWithDefault = mapOr; - -let getWithDefault = getOr; - export { filter, forEach, - getExn, getOrThrow, mapOr, - mapWithDefault, map, flatMap, getOr, - getWithDefault, orElse, isSome, isNone, diff --git a/packages/@rescript/runtime/lib/es6/Stdlib_Result.mjs b/packages/@rescript/runtime/lib/es6/Stdlib_Result.mjs index b93ac4d4c1d..19b29026f6d 100644 --- a/packages/@rescript/runtime/lib/es6/Stdlib_Result.mjs +++ b/packages/@rescript/runtime/lib/es6/Stdlib_Result.mjs @@ -395,21 +395,12 @@ async function flatMapErrorAsync(res, f) { } } -let getExn = getOrThrow; - -let mapWithDefault = mapOr; - -let getWithDefault = getOr; - export { - getExn, getOrThrow, mapOr, - mapWithDefault, map, flatMap, getOr, - getWithDefault, isOk, isError, equal, diff --git a/packages/@rescript/runtime/lib/js/Pervasives.cjs b/packages/@rescript/runtime/lib/js/Pervasives.cjs index 608a207f367..ae1b9f17e65 100644 --- a/packages/@rescript/runtime/lib/js/Pervasives.cjs +++ b/packages/@rescript/runtime/lib/js/Pervasives.cjs @@ -1,26 +1 @@ -'use strict'; - -let Primitive_exceptions = require("./Primitive_exceptions.cjs"); - -function failwith(s) { - throw { - RE_EXN_ID: "Failure", - _1: s, - Error: new Error() - }; -} - -function invalid_arg(s) { - throw { - RE_EXN_ID: "Invalid_argument", - _1: s, - Error: new Error() - }; -} - -let Exit = /* @__PURE__ */Primitive_exceptions.create("Pervasives.Exit"); - -exports.failwith = failwith; -exports.invalid_arg = invalid_arg; -exports.Exit = Exit; -/* No side effect */ +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/packages/@rescript/runtime/lib/js/Stdlib.cjs b/packages/@rescript/runtime/lib/js/Stdlib.cjs index a8136f07d3b..1ed8543be9c 100644 --- a/packages/@rescript/runtime/lib/js/Stdlib.cjs +++ b/packages/@rescript/runtime/lib/js/Stdlib.cjs @@ -12,7 +12,7 @@ function assertEqual(a, b) { RE_EXN_ID: "Assert_failure", _1: [ "Stdlib.res", - 163, + 157, 4 ], Error: new Error() @@ -39,10 +39,6 @@ let $$Date; let Dict; -let Exn; - -let $$Error; - let File; let Float; @@ -153,8 +149,6 @@ exports.Console = Console; exports.$$DataView = $$DataView; exports.$$Date = $$Date; exports.Dict = Dict; -exports.Exn = Exn; -exports.$$Error = $$Error; exports.File = File; exports.Float = Float; exports.Int = Int; diff --git a/packages/@rescript/runtime/lib/js/Stdlib_Bool.cjs b/packages/@rescript/runtime/lib/js/Stdlib_Bool.cjs index 02995bc7214..9f385ebf92e 100644 --- a/packages/@rescript/runtime/lib/js/Stdlib_Bool.cjs +++ b/packages/@rescript/runtime/lib/js/Stdlib_Bool.cjs @@ -35,10 +35,7 @@ function fromStringOrThrow(param) { } } -let fromStringExn = fromStringOrThrow; - exports.toString = toString; exports.fromString = fromString; exports.fromStringOrThrow = fromStringOrThrow; -exports.fromStringExn = fromStringExn; /* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Stdlib_Error.cjs b/packages/@rescript/runtime/lib/js/Stdlib_Error.cjs deleted file mode 100644 index 46b3fbde47a..00000000000 --- a/packages/@rescript/runtime/lib/js/Stdlib_Error.cjs +++ /dev/null @@ -1,36 +0,0 @@ -'use strict'; - -let Stdlib_Exn = require("./Stdlib_Exn.cjs"); -let Primitive_option = require("./Primitive_option.cjs"); - -function fromException(exn) { - if (exn.RE_EXN_ID === Stdlib_Exn.$$Error) { - return Primitive_option.some(exn._1); - } -} - -let $$EvalError = {}; - -let $$RangeError = {}; - -let $$ReferenceError = {}; - -let $$SyntaxError = {}; - -let $$TypeError = {}; - -let $$URIError = {}; - -function panic(msg) { - throw new Error(`Panic! ${msg}`); -} - -exports.fromException = fromException; -exports.$$EvalError = $$EvalError; -exports.$$RangeError = $$RangeError; -exports.$$ReferenceError = $$ReferenceError; -exports.$$SyntaxError = $$SyntaxError; -exports.$$TypeError = $$TypeError; -exports.$$URIError = $$URIError; -exports.panic = panic; -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Stdlib_Exn.cjs b/packages/@rescript/runtime/lib/js/Stdlib_Exn.cjs deleted file mode 100644 index 2bf7a7a90f1..00000000000 --- a/packages/@rescript/runtime/lib/js/Stdlib_Exn.cjs +++ /dev/null @@ -1,54 +0,0 @@ -'use strict'; - -let Primitive_option = require("./Primitive_option.cjs"); -let Primitive_exceptions = require("./Primitive_exceptions.cjs"); - -let $$Error = "JsExn"; - -function asJsExn(exn) { - if (exn.RE_EXN_ID === $$Error) { - return Primitive_option.some(exn._1); - } -} - -let anyToExnInternal = Primitive_exceptions.internalToException; - -function raiseError(str) { - throw new Error(str); -} - -function raiseEvalError(str) { - throw new EvalError(str); -} - -function raiseRangeError(str) { - throw new RangeError(str); -} - -function raiseReferenceError(str) { - throw new ReferenceError(str); -} - -function raiseSyntaxError(str) { - throw new SyntaxError(str); -} - -function raiseTypeError(str) { - throw new TypeError(str); -} - -function raiseUriError(str) { - throw new URIError(str); -} - -exports.$$Error = $$Error; -exports.asJsExn = asJsExn; -exports.anyToExnInternal = anyToExnInternal; -exports.raiseError = raiseError; -exports.raiseEvalError = raiseEvalError; -exports.raiseRangeError = raiseRangeError; -exports.raiseReferenceError = raiseReferenceError; -exports.raiseSyntaxError = raiseSyntaxError; -exports.raiseTypeError = raiseTypeError; -exports.raiseUriError = raiseUriError; -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Stdlib_Int.cjs b/packages/@rescript/runtime/lib/js/Stdlib_Int.cjs index 18c9ac245c5..a2ae31511c8 100644 --- a/packages/@rescript/runtime/lib/js/Stdlib_Int.cjs +++ b/packages/@rescript/runtime/lib/js/Stdlib_Int.cjs @@ -54,10 +54,6 @@ function range(start, end, optionsOpt) { return Stdlib_Array.fromInitializer(length, i => start + (i * step | 0) | 0); } -function rangeWithOptions(start, end, options) { - return range(start, end, options); -} - function clamp(min, max, value) { let value$1 = max !== undefined && max < value ? max : value; if (min !== undefined && min > value$1) { @@ -67,14 +63,6 @@ function clamp(min, max, value) { } } -function lnot(x) { - return x ^ -1; -} - -let Bitwise = { - lnot: lnot -}; - let Constants = { minValue: -2147483648, maxValue: 2147483647 @@ -83,7 +71,5 @@ let Constants = { exports.Constants = Constants; exports.fromString = fromString; exports.range = range; -exports.rangeWithOptions = rangeWithOptions; exports.clamp = clamp; -exports.Bitwise = Bitwise; /* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Stdlib_JSON.cjs b/packages/@rescript/runtime/lib/js/Stdlib_JSON.cjs index 614b7098ef1..e1f17ca4609 100644 --- a/packages/@rescript/runtime/lib/js/Stdlib_JSON.cjs +++ b/packages/@rescript/runtime/lib/js/Stdlib_JSON.cjs @@ -1,43 +1,6 @@ 'use strict'; -function classify(value) { - let match = Object.prototype.toString.call(value); - switch (match) { - case "[object Array]" : - return { - TAG: "Array", - _0: value - }; - case "[object Boolean]" : - return { - TAG: "Bool", - _0: value - }; - case "[object Null]" : - return "Null"; - case "[object Number]" : - return { - TAG: "Number", - _0: value - }; - case "[object String]" : - return { - TAG: "String", - _0: value - }; - default: - return { - TAG: "Object", - _0: value - }; - } -} - -let Classify = { - classify: classify -}; - let Encode = {}; function bool(json) { @@ -85,7 +48,6 @@ let Decode = { array: array }; -exports.Classify = Classify; exports.Encode = Encode; exports.Decode = Decode; /* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Stdlib_Lazy.cjs b/packages/@rescript/runtime/lib/js/Stdlib_Lazy.cjs index 840261a05d7..ee8ff397baa 100644 --- a/packages/@rescript/runtime/lib/js/Stdlib_Lazy.cjs +++ b/packages/@rescript/runtime/lib/js/Stdlib_Lazy.cjs @@ -2,19 +2,12 @@ let Primitive_exceptions = require("./Primitive_exceptions.cjs"); -function is_val(l) { +function isEvaluated(l) { return l.LAZY_DONE; } let Undefined = /* @__PURE__ */Primitive_exceptions.create("Stdlib_Lazy.Undefined"); -function forward_with_closure(blk, closure) { - let result = closure(); - blk.VAL = result; - blk.LAZY_DONE = true; - return result; -} - function raise_undefined() { throw { RE_EXN_ID: Undefined, @@ -22,14 +15,17 @@ function raise_undefined() { }; } -function force(lzv) { +function get(lzv) { if (lzv.LAZY_DONE) { return lzv.VAL; } else { let closure = lzv.VAL; lzv.VAL = raise_undefined; try { - return forward_with_closure(lzv, closure); + let result = closure(); + lzv.VAL = result; + lzv.LAZY_DONE = true; + return result; } catch (e) { lzv.VAL = () => { throw e; @@ -39,43 +35,15 @@ function force(lzv) { } } -function force_val(lzv) { - if (lzv.LAZY_DONE) { - return lzv.VAL; - } else { - let closure = lzv.VAL; - lzv.VAL = raise_undefined; - return forward_with_closure(lzv, closure); - } -} - -function from_fun(closure) { +function make(closure) { return { LAZY_DONE: false, VAL: closure }; } -function from_val(value) { - return { - LAZY_DONE: true, - VAL: value - }; -} - -let make = from_fun; - -let get = force; - -let isEvaluated = is_val; - exports.make = make; exports.get = get; exports.isEvaluated = isEvaluated; exports.Undefined = Undefined; -exports.force = force; -exports.force_val = force_val; -exports.from_fun = from_fun; -exports.from_val = from_val; -exports.is_val = is_val; /* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Stdlib_List.cjs b/packages/@rescript/runtime/lib/js/Stdlib_List.cjs index 54207784812..0563a3a3760 100644 --- a/packages/@rescript/runtime/lib/js/Stdlib_List.cjs +++ b/packages/@rescript/runtime/lib/js/Stdlib_List.cjs @@ -214,51 +214,6 @@ function copyAuxWitFilterMap(f, _cellX, _prec) { }; } -function removeAssocAuxWithMap(_cellX, x, _prec, f) { - while (true) { - let prec = _prec; - let cellX = _cellX; - if (cellX === 0) { - return false; - } - let t = cellX.tl; - let h = cellX.hd; - if (f(h[0], x)) { - prec.tl = t; - return true; - } - let next = {hd: h, tl: /* [] */0}; - prec.tl = next; - _prec = next; - _cellX = t; - continue; - }; -} - -function setAssocAuxWithMap(_cellX, x, k, _prec, eq) { - while (true) { - let prec = _prec; - let cellX = _cellX; - if (cellX === 0) { - return false; - } - let t = cellX.tl; - let h = cellX.hd; - if (eq(h[0], x)) { - prec.tl = {hd: [ - x, - k - ], tl: t}; - return true; - } - let next = {hd: h, tl: /* [] */0}; - prec.tl = next; - _prec = next; - _cellX = t; - continue; - }; -} - function copyAuxWithMap(_cellX, _prec, f) { while (true) { let prec = _prec; @@ -933,20 +888,6 @@ function some2(_l1, _l2, p) { }; } -function has(_xs, x, eq) { - while (true) { - let xs = _xs; - if (xs === 0) { - return false; - } - if (eq(xs.hd, x)) { - return true; - } - _xs = xs.tl; - continue; - }; -} - function includes(_xs, x) { while (true) { let xs = _xs; @@ -961,80 +902,6 @@ function includes(_xs, x) { }; } -function getAssoc(_xs, x, eq) { - while (true) { - let xs = _xs; - if (xs === 0) { - return; - } - let match = xs.hd; - if (eq(match[0], x)) { - return Primitive_option.some(match[1]); - } - _xs = xs.tl; - continue; - }; -} - -function hasAssoc(_xs, x, eq) { - while (true) { - let xs = _xs; - if (xs === 0) { - return false; - } - if (eq(xs.hd[0], x)) { - return true; - } - _xs = xs.tl; - continue; - }; -} - -function removeAssoc(xs, x, eq) { - if (xs === 0) { - return /* [] */0; - } - let l = xs.tl; - let pair = xs.hd; - if (eq(pair[0], x)) { - return l; - } - let cell = {hd: pair, tl: /* [] */0}; - let removed = removeAssocAuxWithMap(l, x, cell, eq); - if (removed) { - return cell; - } else { - return xs; - } -} - -function setAssoc(xs, x, k, eq) { - if (xs === 0) { - return {hd: [ - x, - k - ], tl: /* [] */0}; - } - let l = xs.tl; - let pair = xs.hd; - if (eq(pair[0], x)) { - return {hd: [ - x, - k - ], tl: l}; - } - let cell = {hd: pair, tl: /* [] */0}; - let replaced = setAssocAuxWithMap(l, x, k, cell, eq); - if (replaced) { - return cell; - } else { - return {hd: [ - x, - k - ], tl: xs}; - } -} - function sort(xs, cmp) { let arr = toArray(xs); arr.sort(cmp); @@ -1173,30 +1040,18 @@ function zip(l1, l2) { let size = length; -let headExn = headOrThrow; - -let tailExn = tailOrThrow; - -let getExn = getOrThrow; - -let toShuffled = shuffle; - exports.length = length; exports.size = size; exports.head = head; -exports.headExn = headExn; exports.headOrThrow = headOrThrow; exports.tail = tail; -exports.tailExn = tailExn; exports.tailOrThrow = tailOrThrow; exports.add = add; exports.get = get; -exports.getExn = getExn; exports.getOrThrow = getOrThrow; exports.make = make; exports.fromInitializer = fromInitializer; exports.shuffle = shuffle; -exports.toShuffled = toShuffled; exports.drop = drop; exports.take = take; exports.splitAt = splitAt; @@ -1228,7 +1083,6 @@ exports.some2 = some2; exports.compareLength = compareLength; exports.compare = compare; exports.equal = equal; -exports.has = has; exports.includes = includes; exports.find = find; exports.filter = filter; @@ -1236,9 +1090,5 @@ exports.filterWithIndex = filterWithIndex; exports.filterMap = filterMap; exports.partition = partition; exports.unzip = unzip; -exports.getAssoc = getAssoc; -exports.hasAssoc = hasAssoc; -exports.removeAssoc = removeAssoc; -exports.setAssoc = setAssoc; exports.sort = sort; /* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Stdlib_Null.cjs b/packages/@rescript/runtime/lib/js/Stdlib_Null.cjs index 454d27391cb..9a80f1eab7f 100644 --- a/packages/@rescript/runtime/lib/js/Stdlib_Null.cjs +++ b/packages/@rescript/runtime/lib/js/Stdlib_Null.cjs @@ -68,22 +68,13 @@ function flatMap(value, f) { } } -let getWithDefault = getOr; - -let getExn = getOrThrow; - -let mapWithDefault = mapOr; - exports.equal = equal; exports.compare = compare; exports.fromOption = fromOption; exports.getOr = getOr; -exports.getWithDefault = getWithDefault; -exports.getExn = getExn; exports.getOrThrow = getOrThrow; exports.forEach = forEach; exports.map = map; exports.mapOr = mapOr; -exports.mapWithDefault = mapWithDefault; exports.flatMap = flatMap; /* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Stdlib_Nullable.cjs b/packages/@rescript/runtime/lib/js/Stdlib_Nullable.cjs index 8690ef201ad..d2992c07c5f 100644 --- a/packages/@rescript/runtime/lib/js/Stdlib_Nullable.cjs +++ b/packages/@rescript/runtime/lib/js/Stdlib_Nullable.cjs @@ -66,22 +66,13 @@ function flatMap(value, f) { } } -let getWithDefault = getOr; - -let getExn = getOrThrow; - -let mapWithDefault = mapOr; - exports.equal = equal; exports.compare = compare; exports.fromOption = fromOption; exports.getOr = getOr; -exports.getWithDefault = getWithDefault; -exports.getExn = getExn; exports.getOrThrow = getOrThrow; exports.forEach = forEach; exports.map = map; exports.mapOr = mapOr; -exports.mapWithDefault = mapWithDefault; exports.flatMap = flatMap; /* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Stdlib_Option.cjs b/packages/@rescript/runtime/lib/js/Stdlib_Option.cjs index 3dcde51fceb..ab9beb65f56 100644 --- a/packages/@rescript/runtime/lib/js/Stdlib_Option.cjs +++ b/packages/@rescript/runtime/lib/js/Stdlib_Option.cjs @@ -187,22 +187,13 @@ function all6(param) { } } -let getExn = getOrThrow; - -let mapWithDefault = mapOr; - -let getWithDefault = getOr; - exports.filter = filter; exports.forEach = forEach; -exports.getExn = getExn; exports.getOrThrow = getOrThrow; exports.mapOr = mapOr; -exports.mapWithDefault = mapWithDefault; exports.map = map; exports.flatMap = flatMap; exports.getOr = getOr; -exports.getWithDefault = getWithDefault; exports.orElse = orElse; exports.isSome = isSome; exports.isNone = isNone; diff --git a/packages/@rescript/runtime/lib/js/Stdlib_Result.cjs b/packages/@rescript/runtime/lib/js/Stdlib_Result.cjs index 590300c7f34..50819650e9e 100644 --- a/packages/@rescript/runtime/lib/js/Stdlib_Result.cjs +++ b/packages/@rescript/runtime/lib/js/Stdlib_Result.cjs @@ -395,20 +395,11 @@ async function flatMapErrorAsync(res, f) { } } -let getExn = getOrThrow; - -let mapWithDefault = mapOr; - -let getWithDefault = getOr; - -exports.getExn = getExn; exports.getOrThrow = getOrThrow; exports.mapOr = mapOr; -exports.mapWithDefault = mapWithDefault; exports.map = map; exports.flatMap = flatMap; exports.getOr = getOr; -exports.getWithDefault = getWithDefault; exports.isOk = isOk; exports.isError = isError; exports.equal = equal; diff --git a/packages/artifacts.json b/packages/artifacts.json index cc322449ddd..5b0ba1aff3a 100644 --- a/packages/artifacts.json +++ b/packages/artifacts.json @@ -70,8 +70,6 @@ "lib/es6/Stdlib_DataView.mjs", "lib/es6/Stdlib_Date.mjs", "lib/es6/Stdlib_Dict.mjs", - "lib/es6/Stdlib_Error.mjs", - "lib/es6/Stdlib_Exn.mjs", "lib/es6/Stdlib_File.mjs", "lib/es6/Stdlib_Float.mjs", "lib/es6/Stdlib_Float32Array.mjs", @@ -174,8 +172,6 @@ "lib/js/Stdlib_DataView.cjs", "lib/js/Stdlib_Date.cjs", "lib/js/Stdlib_Dict.cjs", - "lib/js/Stdlib_Error.cjs", - "lib/js/Stdlib_Exn.cjs", "lib/js/Stdlib_File.cjs", "lib/js/Stdlib_Float.cjs", "lib/js/Stdlib_Float32Array.cjs", @@ -460,18 +456,6 @@ "lib/ocaml/Stdlib_Dict.cmti", "lib/ocaml/Stdlib_Dict.res", "lib/ocaml/Stdlib_Dict.resi", - "lib/ocaml/Stdlib_Error.cmi", - "lib/ocaml/Stdlib_Error.cmj", - "lib/ocaml/Stdlib_Error.cmt", - "lib/ocaml/Stdlib_Error.cmti", - "lib/ocaml/Stdlib_Error.res", - "lib/ocaml/Stdlib_Error.resi", - "lib/ocaml/Stdlib_Exn.cmi", - "lib/ocaml/Stdlib_Exn.cmj", - "lib/ocaml/Stdlib_Exn.cmt", - "lib/ocaml/Stdlib_Exn.cmti", - "lib/ocaml/Stdlib_Exn.res", - "lib/ocaml/Stdlib_Exn.resi", "lib/ocaml/Stdlib_File.cmi", "lib/ocaml/Stdlib_File.cmj", "lib/ocaml/Stdlib_File.cmt", From 9ef4fe269e0dbe4f4da7f23dab064125c2692301 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Mon, 26 Oct 2026 09:57:02 +0000 Subject: [PATCH 2/4] Replace the stdlib migration fixtures with a self-contained one The StdlibMigration_* fixtures exercised the templates of the removed stdlib APIs. DeprecatedTemplates declares the same template shapes locally, so the migration tool keeps its coverage. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013ZYFYMu3AE9P1xFVCR34d1 Signed-off-by: Christoph Knittel --- .../expected/DeprecatedTemplates.res.expected | 17 ++++++ .../DeprecatedTemplates.resi.expected | 45 ++++++++++++++++ .../expected/Migrate_Templates.res.expected | 29 +++++++++++ .../StdlibMigration_DataView.res.expected | 2 - .../StdlibMigration_Error.res.expected | 34 ------------ .../expected/StdlibMigration_Exn.res.expected | 50 ------------------ .../expected/StdlibMigration_Int.res.expected | 7 --- .../StdlibMigration_JSON_Stdlib.res.expected | 14 ----- .../StdlibMigration_Pervasives.res.expected | 1 - .../StdlibMigration_StdlibArray.res.expected | 20 ------- ...gration_StdlibListLazyPromise.res.expected | 13 ----- ...ration_StdlibOptionResultNull.res.expected | 15 ------ ...libMigration_StdlibPrimitives.res.expected | 18 ------- .../StdlibMigration_StdlibString.res.expected | 37 ------------- ...gration_TypedArray_Operations.res.expected | 6 --- ...ibMigration_TypedArray_Stdlib.res.expected | 3 -- .../src/migrate/DeprecatedTemplates.res | 17 ++++++ .../src/migrate/DeprecatedTemplates.resi | 45 ++++++++++++++++ .../src/migrate/Migrate_Templates.res | 29 +++++++++++ .../src/migrate/StdlibMigration_DataView.res | 2 - .../src/migrate/StdlibMigration_Error.res | 34 ------------ .../src/migrate/StdlibMigration_Exn.res | 50 ------------------ .../src/migrate/StdlibMigration_Int.res | 7 --- .../migrate/StdlibMigration_JSON_Stdlib.res | 14 ----- .../migrate/StdlibMigration_Pervasives.res | 1 - .../migrate/StdlibMigration_StdlibArray.res | 20 ------- .../StdlibMigration_StdlibListLazyPromise.res | 13 ----- ...StdlibMigration_StdlibOptionResultNull.res | 15 ------ .../StdlibMigration_StdlibPrimitives.res | 18 ------- .../migrate/StdlibMigration_StdlibString.res | 37 ------------- .../StdlibMigration_TypedArray_Operations.res | 6 --- .../StdlibMigration_TypedArray_Stdlib.res | 3 -- .../migrated/Migrated_Migrate_Templates.res | 31 +++++++++++ .../Migrated_StdlibMigration_DataView.res | 4 -- .../Migrated_StdlibMigration_Error.res | 36 ------------- .../migrated/Migrated_StdlibMigration_Exn.res | 52 ------------------- .../migrated/Migrated_StdlibMigration_Int.res | 9 ---- .../Migrated_StdlibMigration_JSON_Stdlib.res | 16 ------ .../Migrated_StdlibMigration_Pervasives.res | 3 -- .../Migrated_StdlibMigration_StdlibArray.res | 22 -------- ..._StdlibMigration_StdlibListLazyPromise.res | 15 ------ ...StdlibMigration_StdlibOptionResultNull.res | 17 ------ ...rated_StdlibMigration_StdlibPrimitives.res | 20 ------- .../Migrated_StdlibMigration_StdlibString.res | 39 -------------- ..._StdlibMigration_TypedArray_Operations.res | 8 --- ...ated_StdlibMigration_TypedArray_Stdlib.res | 5 -- tests/tools_tests/test.sh | 2 +- 47 files changed, 214 insertions(+), 687 deletions(-) create mode 100644 tests/tools_tests/src/expected/DeprecatedTemplates.res.expected create mode 100644 tests/tools_tests/src/expected/DeprecatedTemplates.resi.expected create mode 100644 tests/tools_tests/src/expected/Migrate_Templates.res.expected delete mode 100644 tests/tools_tests/src/expected/StdlibMigration_DataView.res.expected delete mode 100644 tests/tools_tests/src/expected/StdlibMigration_Error.res.expected delete mode 100644 tests/tools_tests/src/expected/StdlibMigration_Exn.res.expected delete mode 100644 tests/tools_tests/src/expected/StdlibMigration_Int.res.expected delete mode 100644 tests/tools_tests/src/expected/StdlibMigration_JSON_Stdlib.res.expected delete mode 100644 tests/tools_tests/src/expected/StdlibMigration_Pervasives.res.expected delete mode 100644 tests/tools_tests/src/expected/StdlibMigration_StdlibArray.res.expected delete mode 100644 tests/tools_tests/src/expected/StdlibMigration_StdlibListLazyPromise.res.expected delete mode 100644 tests/tools_tests/src/expected/StdlibMigration_StdlibOptionResultNull.res.expected delete mode 100644 tests/tools_tests/src/expected/StdlibMigration_StdlibPrimitives.res.expected delete mode 100644 tests/tools_tests/src/expected/StdlibMigration_StdlibString.res.expected delete mode 100644 tests/tools_tests/src/expected/StdlibMigration_TypedArray_Operations.res.expected delete mode 100644 tests/tools_tests/src/expected/StdlibMigration_TypedArray_Stdlib.res.expected create mode 100644 tests/tools_tests/src/migrate/DeprecatedTemplates.res create mode 100644 tests/tools_tests/src/migrate/DeprecatedTemplates.resi create mode 100644 tests/tools_tests/src/migrate/Migrate_Templates.res delete mode 100644 tests/tools_tests/src/migrate/StdlibMigration_DataView.res delete mode 100644 tests/tools_tests/src/migrate/StdlibMigration_Error.res delete mode 100644 tests/tools_tests/src/migrate/StdlibMigration_Exn.res delete mode 100644 tests/tools_tests/src/migrate/StdlibMigration_Int.res delete mode 100644 tests/tools_tests/src/migrate/StdlibMigration_JSON_Stdlib.res delete mode 100644 tests/tools_tests/src/migrate/StdlibMigration_Pervasives.res delete mode 100644 tests/tools_tests/src/migrate/StdlibMigration_StdlibArray.res delete mode 100644 tests/tools_tests/src/migrate/StdlibMigration_StdlibListLazyPromise.res delete mode 100644 tests/tools_tests/src/migrate/StdlibMigration_StdlibOptionResultNull.res delete mode 100644 tests/tools_tests/src/migrate/StdlibMigration_StdlibPrimitives.res delete mode 100644 tests/tools_tests/src/migrate/StdlibMigration_StdlibString.res delete mode 100644 tests/tools_tests/src/migrate/StdlibMigration_TypedArray_Operations.res delete mode 100644 tests/tools_tests/src/migrate/StdlibMigration_TypedArray_Stdlib.res create mode 100644 tests/tools_tests/src/migrate/migrated/Migrated_Migrate_Templates.res delete mode 100644 tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_DataView.res delete mode 100644 tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Error.res delete mode 100644 tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Exn.res delete mode 100644 tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Int.res delete mode 100644 tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_JSON_Stdlib.res delete mode 100644 tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Pervasives.res delete mode 100644 tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_StdlibArray.res delete mode 100644 tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_StdlibListLazyPromise.res delete mode 100644 tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_StdlibOptionResultNull.res delete mode 100644 tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_StdlibPrimitives.res delete mode 100644 tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_StdlibString.res delete mode 100644 tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_TypedArray_Operations.res delete mode 100644 tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_TypedArray_Stdlib.res diff --git a/tests/tools_tests/src/expected/DeprecatedTemplates.res.expected b/tests/tools_tests/src/expected/DeprecatedTemplates.res.expected new file mode 100644 index 00000000000..baeedc97348 --- /dev/null +++ b/tests/tools_tests/src/expected/DeprecatedTemplates.res.expected @@ -0,0 +1,17 @@ +module Target = { + type t = {value: int} + type options = {step: int} + exception Failed(string) + let make = (value, ~start=0) => {value: value + start} + let fromOptions = (value, ~options={step: 1}) => {value: value * options.step} + let delay = f => {value: f()} +} + +type t = Target.t + +exception Failed = Target.Failed + +let makeFromZero = value => Target.make(value, ~start=0) +let fromOptionsPositional = (value, options) => Target.fromOptions(value, ~options) +let ofValue = value => Target.delay(() => value) +let add = (a, b) => a + b diff --git a/tests/tools_tests/src/expected/DeprecatedTemplates.resi.expected b/tests/tools_tests/src/expected/DeprecatedTemplates.resi.expected new file mode 100644 index 00000000000..d328e145369 --- /dev/null +++ b/tests/tools_tests/src/expected/DeprecatedTemplates.resi.expected @@ -0,0 +1,45 @@ +module Target: { + type t = {value: int} + type options = {step: int} + exception Failed(string) + let make: (int, ~start: int=?) => t + let fromOptions: (int, ~options: options=?) => t + let delay: (unit => int) => t +} + +@deprecated({ + reason: "Use `Target.t` instead", + migrate: %replace.type(: DeprecatedTemplates.Target.t), +}) +type t = Target.t + +type exn += + | @deprecated({ + reason: "Use `Target.Failed` instead", + migrate: %replace.constructor(DeprecatedTemplates.Target.Failed), + }) + Failed(string) + +@deprecated({ + reason: "Use `Target.make` instead", + migrate: DeprecatedTemplates.Target.make(~start=0), +}) +let makeFromZero: int => Target.t + +@deprecated({ + reason: "Use `Target.fromOptions` instead", + migrate: DeprecatedTemplates.Target.fromOptions(~options=%insert.unlabelledArgument(1)), +}) +let fromOptionsPositional: (int, Target.options) => Target.t + +@deprecated({ + reason: "Use `Target.delay` instead", + migrate: DeprecatedTemplates.Target.delay(() => %insert.unlabelledArgument(0)), +}) +let ofValue: int => Target.t + +@deprecated({ + reason: "Use the `+` operator instead", + migrate: %insert.unlabelledArgument(0) + %insert.unlabelledArgument(1), +}) +let add: (int, int) => int diff --git a/tests/tools_tests/src/expected/Migrate_Templates.res.expected b/tests/tools_tests/src/expected/Migrate_Templates.res.expected new file mode 100644 index 00000000000..1f9d93c3ddd --- /dev/null +++ b/tests/tools_tests/src/expected/Migrate_Templates.res.expected @@ -0,0 +1,29 @@ +// Uses the deprecated items of DeprecatedTemplates to validate each kind of migration template. + +// %replace.type +let value: DeprecatedTemplates.Target.t = DeprecatedTemplates.Target.make(1) + +// A fixed labelled argument +let fromZero1 = DeprecatedTemplates.Target.make(1, ~start=0) +let fromZero2 = 1->DeprecatedTemplates.Target.make(~start=0) + +// An unlabelled argument inserted as a labelled one +let options1 = DeprecatedTemplates.Target.fromOptions(2, ~options={step: 3}) +let options2 = 2->DeprecatedTemplates.Target.fromOptions(~options={step: 3}) + +// An unlabelled argument inserted into a function +let delayed = DeprecatedTemplates.Target.delay(() => 4) + +// An operator built from unlabelled arguments +let sum1 = 1 + 2 + +// %replace.constructor +let caught = switch throw(DeprecatedTemplates.Target.Failed("boom")) { +| exception DeprecatedTemplates.Target.Failed(message) => message +| () => "" +} + +let matched = switch DeprecatedTemplates.Target.Failed("boom") { +| DeprecatedTemplates.Target.Failed(message) => message +| _ => "" +} diff --git a/tests/tools_tests/src/expected/StdlibMigration_DataView.res.expected b/tests/tools_tests/src/expected/StdlibMigration_DataView.res.expected deleted file mode 100644 index 36dd9099a68..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_DataView.res.expected +++ /dev/null @@ -1,2 +0,0 @@ -let a = DataView.fromBuffer(ArrayBuffer.make(8), ~byteOffset=2) -let b = DataView.fromBuffer(ArrayBuffer.make(8), ~byteOffset=2, ~length=4) diff --git a/tests/tools_tests/src/expected/StdlibMigration_Error.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Error.res.expected deleted file mode 100644 index debce14da3a..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Error.res.expected +++ /dev/null @@ -1,34 +0,0 @@ -// Use deprecated Error APIs to validate migration to JsError/JsExn - -external someExn: exn = "whatever" - -let fromExn1 = someExn->JsExn.fromException -let fromExn2 = JsExn.fromException(someExn) - -let err = JsError.make("Some message here") - -let stack1 = err->JsError.stack -let stack2 = JsError.stack(err) - -let message1 = err->JsError.message -let message2 = JsError.message(err) - -let name1 = err->JsError.name -let name2 = JsError.name(err) - -let fileName1 = err->JsError.fileName -let fileName2 = JsError.fileName(err) - -// Type alias migration -let errT: JsError.t = JsError.make("Another message") - -// Sub-error constructors -let evalErr = JsError.EvalError.make("eval error") -let rangeErr = JsError.RangeError.make("range error") -let refErr = JsError.ReferenceError.make("reference error") -let synErr = JsError.SyntaxError.make("syntax error") -let typeErr = JsError.TypeError.make("type error") -let uriErr = JsError.URIError.make("uri error") - -let ignore1 = err->JsError.ignore -let ignore2 = JsError.ignore(err) diff --git a/tests/tools_tests/src/expected/StdlibMigration_Exn.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Exn.res.expected deleted file mode 100644 index 68db77bf8f4..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Exn.res.expected +++ /dev/null @@ -1,50 +0,0 @@ -// Use deprecated Exn APIs to validate migration to JsExn/JsError - -external someExn: exn = "whatever" -external someJsExn: JsExn.t = "whatever" - -// fromException (asJsExn) -let fromExn1 = someExn->JsExn.fromException -let fromExn2 = JsExn.fromException(someExn) - -// Property accessors on Exn.t -let stack1 = someJsExn->JsExn.stack -let stack2 = JsExn.stack(someJsExn) - -let message1 = someJsExn->JsExn.message -let message2 = JsExn.message(someJsExn) - -let name1 = someJsExn->JsExn.name -let name2 = JsExn.name(someJsExn) - -let fileName1 = someJsExn->JsExn.fileName -let fileName2 = JsExn.fileName(someJsExn) - -// Type alias migration -let exnT: JsExn.t = someJsExn - -// anyToExnInternal -let _coerced = JsExn.anyToExnInternal(1) - -// ignore -let ignore1 = someJsExn->JsExn.ignore -let ignore2 = JsExn.ignore(someJsExn) - -// Raise helpers -let throws1 = () => JsError.throwWithMessage("err") -let throws2 = () => JsError.EvalError.throwWithMessage("err") -let throws3 = () => JsError.RangeError.throwWithMessage("err") -let throws4 = () => JsError.ReferenceError.throwWithMessage("err") -let throws5 = () => JsError.SyntaxError.throwWithMessage("err") -let throws6 = () => JsError.TypeError.throwWithMessage("err") -let throws7 = () => JsError.URIError.throwWithMessage("err") - -let someThrowingJsCode = () => Some("bar") -let catchingExnErrorWithSwitch = switch someThrowingJsCode() { -| exception JsExn(e) => e->JsExn.message -| s => s -} - -let catchingExnErrorWithTryCatch = try {someThrowingJsCode()} catch { -| JsExn(e) => e->JsExn.message -} diff --git a/tests/tools_tests/src/expected/StdlibMigration_Int.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Int.res.expected deleted file mode 100644 index 41682970e94..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Int.res.expected +++ /dev/null @@ -1,7 +0,0 @@ -let result1 = Int.bitwiseAnd(1, 2) -let result2 = Int.bitwiseOr(1, 2) -let result3 = Int.bitwiseXor(1, 2) -let result4 = Int.shiftLeft(1, 2) -let result5 = Int.shiftRightUnsigned(1, 2) -let result6 = Int.shiftRight(1, 2) -let result7 = Int.bitwiseNot(0) diff --git a/tests/tools_tests/src/expected/StdlibMigration_JSON_Stdlib.res.expected b/tests/tools_tests/src/expected/StdlibMigration_JSON_Stdlib.res.expected deleted file mode 100644 index 70f0686c61d..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_JSON_Stdlib.res.expected +++ /dev/null @@ -1,14 +0,0 @@ -let p1 = JSON.parseExn("{}", ~reviver=(_k, v) => v) -let p2 = JSON.parseExnWithReviver("{}", (_k, v) => v) - -let s1 = JSON.stringifyWithIndent(JSON.Object(dict{}), 2) -let s2 = JSON.stringifyWithReplacer(JSON.Number(1.), (_k, v) => v) -let s3 = JSON.stringifyWithReplacerAndIndent(JSON.Boolean(true), (_k, v) => v, 2) -let s4 = JSON.stringifyWithFilter(JSON.Array([JSON.Number(1.)]), ["a"]) -let s5 = JSON.stringifyWithFilterAndIndent(JSON.Array([JSON.Number(1.)]), ["a"], 2) - -let a1 = JSON.stringifyAnyWithIndent(1, 2) -let a2 = JSON.stringifyAnyWithReplacer(1, (_k, v) => v) -let a3 = JSON.stringifyAnyWithReplacerAndIndent(1, (_k, v) => v, 2) -let a4 = JSON.stringifyAnyWithFilter(1, ["a"]) -let a5 = JSON.stringifyAnyWithFilterAndIndent(1, ["a"], 2) diff --git a/tests/tools_tests/src/expected/StdlibMigration_Pervasives.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Pervasives.res.expected deleted file mode 100644 index 3baf0867238..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Pervasives.res.expected +++ /dev/null @@ -1 +0,0 @@ -throw(Failure("test")) diff --git a/tests/tools_tests/src/expected/StdlibMigration_StdlibArray.res.expected b/tests/tools_tests/src/expected/StdlibMigration_StdlibArray.res.expected deleted file mode 100644 index b24fc0cf737..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_StdlibArray.res.expected +++ /dev/null @@ -1,20 +0,0 @@ -let ba1 = [1, 2, 3, 4, 5]->Array.copyWithin(~target=2, ~start=0) -let ba2 = Array.copyWithin([1, 2, 3, 4, 5], ~target=2, ~start=0) - -let b1 = [1, 2, 3, 4]->Array.copyWithin(~target=0, ~start=2) -let b2 = Array.copyWithin([1, 2, 3, 4], ~target=0, ~start=2) - -let c1 = [1, 2, 3]->Array.fill(0) -let c2 = [1, 2, 3, 4]->Array.fill(9, ~start=1) - -let d1 = [1, 2, 1, 2]->Array.indexOf(2, ~from=2) -let d2 = Array.indexOf([1, 2, 1, 2], 2, ~from=2) - -let e1 = ["a", "b"]->Array.join("-") -let e2 = [1, 2]->Array.joinUnsafe(",") - -let f1 = [1, 2, 3, 4]->Array.slice(~start=2) - -let g1 = [1, 2]->Array.lastIndexOf(1, ~from=1) - -let h1 = [1, 2]->Array.getUnsafe(1) diff --git a/tests/tools_tests/src/expected/StdlibMigration_StdlibListLazyPromise.res.expected b/tests/tools_tests/src/expected/StdlibMigration_StdlibListLazyPromise.res.expected deleted file mode 100644 index b24bde02a98..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_StdlibListLazyPromise.res.expected +++ /dev/null @@ -1,13 +0,0 @@ -let l1 = List.headOrThrow(list{1}) -let l2 = List.tailOrThrow(list{1}) -let l3 = List.getOrThrow(list{"a", "b"}, 0) -let l4 = List.shuffle(list{1, 2}) - -let lazy1 = Lazy.make(() => 1) -let lazy2 = Lazy.make(() => 2) -let v1 = Lazy.get(lazy1) -let v2 = Lazy.get(lazy2) -let b1 = Lazy.isEvaluated(lazy1) - -let p = Promise.resolve(5) -let _ = Promise.ignore(p) diff --git a/tests/tools_tests/src/expected/StdlibMigration_StdlibOptionResultNull.res.expected b/tests/tools_tests/src/expected/StdlibMigration_StdlibOptionResultNull.res.expected deleted file mode 100644 index 8920cb87d64..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_StdlibOptionResultNull.res.expected +++ /dev/null @@ -1,15 +0,0 @@ -let o1 = Option.getOrThrow(Some(3)) -let o2 = Option.mapOr(Some(3), 0, x => x + 1) -let o3 = Option.getOr(None, 0) - -let r1 = Result.getOrThrow(Ok(1)) -let r2 = Result.mapOr(Ok(1), 0, x => x + 1) -let r3 = Result.getOr(Error("e"), 0) - -let n1 = Null.getOrThrow(Null.make(3)) -let n2 = Null.getOr(Null.null, 0) -let n3 = Null.mapOr(Null.make(3), 0, x => x) - -let nb1 = Nullable.getOrThrow(Nullable.make(3)) -let nb2 = Nullable.getOr(Nullable.null, 0) -let nb3 = Nullable.mapOr(Nullable.make(3), 0, x => x) diff --git a/tests/tools_tests/src/expected/StdlibMigration_StdlibPrimitives.res.expected b/tests/tools_tests/src/expected/StdlibMigration_StdlibPrimitives.res.expected deleted file mode 100644 index 9f61a989b2d..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_StdlibPrimitives.res.expected +++ /dev/null @@ -1,18 +0,0 @@ -let i1 = Int.toExponential(77, ~digits=2) -let i2 = Int.toFixed(300, ~digits=1) -let i3 = Int.toPrecision(100, ~digits=2) -let i4 = Int.toString(6, ~radix=2) -let i5 = Int.range(1, 5, ~options={step: 2}) - -let f1 = Float.parseInt("10.0", ~radix=2) -let f2 = Float.toExponential(77.0, ~digits=2) -let f3 = Float.toFixed(300.0, ~digits=1) -let f4 = Float.toPrecision(100.0, ~digits=2) -let f5 = Float.toString(6.0, ~radix=2) - -let b1 = Bool.fromStringOrThrow("true") - -let buf = ArrayBuffer.make(8) -let ab1 = buf->ArrayBuffer.slice(~start=2) - -let re1 = RegExp.fromString("\\w+", ~flags="g") diff --git a/tests/tools_tests/src/expected/StdlibMigration_StdlibString.res.expected b/tests/tools_tests/src/expected/StdlibMigration_StdlibString.res.expected deleted file mode 100644 index 1d73ca294dd..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_StdlibString.res.expected +++ /dev/null @@ -1,37 +0,0 @@ -let s1 = "abcde"->String.slice(~start=1) -let s2 = "abcde"->String.substring(~start=1) - -let r0 = - "vowels"->String.replaceRegExpBy0Unsafe(/a|e|i|o|u/g, (~match, ~offset as _, ~input as _) => - match - ) -let r1 = - "Jony is 40"->String.replaceRegExpBy1Unsafe(/(Jony is )\d+/g, ( - ~match as _, - ~group1, - ~offset as _, - ~input as _, - ) => group1) - -let r2 = "7 times 6"->String.replaceRegExpBy2Unsafe(/(\d+) times (\d+)/, ( - ~match as _, - ~group1, - ~group2, - ~offset as _, - ~input as _, -) => - switch (Int.fromString(group1), Int.fromString(group2)) { - | (Some(x), Some(y)) => Int.toString(x * y) - | _ => "???" - } -) - -let r3 = - "abc"->String.replaceRegExpBy3Unsafe(/(a)(b)(c)/, ( - ~match as _, - ~group1, - ~group2, - ~group3, - ~offset as _, - ~input as _, - ) => group1 ++ group2 ++ group3) diff --git a/tests/tools_tests/src/expected/StdlibMigration_TypedArray_Operations.res.expected b/tests/tools_tests/src/expected/StdlibMigration_TypedArray_Operations.res.expected deleted file mode 100644 index c55769d4627..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_TypedArray_Operations.res.expected +++ /dev/null @@ -1,6 +0,0 @@ -let ta = (Uint8Array.fromArray([1, 2, 3, 4]) :> TypedArray.t) - -let a1 = ta->TypedArray.copyWithin(~target=1, ~start=2) -let a2 = ta->TypedArray.fill(9, ~start=1) -let a3 = ta->TypedArray.slice(~start=1) -let a4 = ta->TypedArray.subarray(~start=1) diff --git a/tests/tools_tests/src/expected/StdlibMigration_TypedArray_Stdlib.res.expected b/tests/tools_tests/src/expected/StdlibMigration_TypedArray_Stdlib.res.expected deleted file mode 100644 index d07090fc296..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_TypedArray_Stdlib.res.expected +++ /dev/null @@ -1,3 +0,0 @@ -let a = Uint8Array.fromBuffer(ArrayBuffer.make(8), ~byteOffset=2) -let b = Uint8Array.fromBuffer(ArrayBuffer.make(8), ~byteOffset=2, ~length=2) -let c = Uint8Array.fromArrayLikeOrIterable([1, 2], ~map=(v, _i) => v) diff --git a/tests/tools_tests/src/migrate/DeprecatedTemplates.res b/tests/tools_tests/src/migrate/DeprecatedTemplates.res new file mode 100644 index 00000000000..baeedc97348 --- /dev/null +++ b/tests/tools_tests/src/migrate/DeprecatedTemplates.res @@ -0,0 +1,17 @@ +module Target = { + type t = {value: int} + type options = {step: int} + exception Failed(string) + let make = (value, ~start=0) => {value: value + start} + let fromOptions = (value, ~options={step: 1}) => {value: value * options.step} + let delay = f => {value: f()} +} + +type t = Target.t + +exception Failed = Target.Failed + +let makeFromZero = value => Target.make(value, ~start=0) +let fromOptionsPositional = (value, options) => Target.fromOptions(value, ~options) +let ofValue = value => Target.delay(() => value) +let add = (a, b) => a + b diff --git a/tests/tools_tests/src/migrate/DeprecatedTemplates.resi b/tests/tools_tests/src/migrate/DeprecatedTemplates.resi new file mode 100644 index 00000000000..d328e145369 --- /dev/null +++ b/tests/tools_tests/src/migrate/DeprecatedTemplates.resi @@ -0,0 +1,45 @@ +module Target: { + type t = {value: int} + type options = {step: int} + exception Failed(string) + let make: (int, ~start: int=?) => t + let fromOptions: (int, ~options: options=?) => t + let delay: (unit => int) => t +} + +@deprecated({ + reason: "Use `Target.t` instead", + migrate: %replace.type(: DeprecatedTemplates.Target.t), +}) +type t = Target.t + +type exn += + | @deprecated({ + reason: "Use `Target.Failed` instead", + migrate: %replace.constructor(DeprecatedTemplates.Target.Failed), + }) + Failed(string) + +@deprecated({ + reason: "Use `Target.make` instead", + migrate: DeprecatedTemplates.Target.make(~start=0), +}) +let makeFromZero: int => Target.t + +@deprecated({ + reason: "Use `Target.fromOptions` instead", + migrate: DeprecatedTemplates.Target.fromOptions(~options=%insert.unlabelledArgument(1)), +}) +let fromOptionsPositional: (int, Target.options) => Target.t + +@deprecated({ + reason: "Use `Target.delay` instead", + migrate: DeprecatedTemplates.Target.delay(() => %insert.unlabelledArgument(0)), +}) +let ofValue: int => Target.t + +@deprecated({ + reason: "Use the `+` operator instead", + migrate: %insert.unlabelledArgument(0) + %insert.unlabelledArgument(1), +}) +let add: (int, int) => int diff --git a/tests/tools_tests/src/migrate/Migrate_Templates.res b/tests/tools_tests/src/migrate/Migrate_Templates.res new file mode 100644 index 00000000000..45b6a301fa3 --- /dev/null +++ b/tests/tools_tests/src/migrate/Migrate_Templates.res @@ -0,0 +1,29 @@ +// Uses the deprecated items of DeprecatedTemplates to validate each kind of migration template. + +// %replace.type +let value: DeprecatedTemplates.t = DeprecatedTemplates.Target.make(1) + +// A fixed labelled argument +let fromZero1 = DeprecatedTemplates.makeFromZero(1) +let fromZero2 = 1->DeprecatedTemplates.makeFromZero + +// An unlabelled argument inserted as a labelled one +let options1 = DeprecatedTemplates.fromOptionsPositional(2, {step: 3}) +let options2 = 2->DeprecatedTemplates.fromOptionsPositional({step: 3}) + +// An unlabelled argument inserted into a function +let delayed = DeprecatedTemplates.ofValue(4) + +// An operator built from unlabelled arguments +let sum1 = DeprecatedTemplates.add(1, 2) + +// %replace.constructor +let caught = switch throw(DeprecatedTemplates.Target.Failed("boom")) { +| exception DeprecatedTemplates.Failed(message) => message +| () => "" +} + +let matched = switch DeprecatedTemplates.Target.Failed("boom") { +| DeprecatedTemplates.Failed(message) => message +| _ => "" +} diff --git a/tests/tools_tests/src/migrate/StdlibMigration_DataView.res b/tests/tools_tests/src/migrate/StdlibMigration_DataView.res deleted file mode 100644 index 21a9969b726..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_DataView.res +++ /dev/null @@ -1,2 +0,0 @@ -let a = DataView.fromBufferToEnd(ArrayBuffer.make(8), ~byteOffset=2) -let b = DataView.fromBufferWithRange(ArrayBuffer.make(8), ~byteOffset=2, ~length=4) diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Error.res b/tests/tools_tests/src/migrate/StdlibMigration_Error.res deleted file mode 100644 index b4cf75855e4..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Error.res +++ /dev/null @@ -1,34 +0,0 @@ -// Use deprecated Error APIs to validate migration to JsError/JsExn - -external someExn: exn = "whatever" - -let fromExn1 = someExn->Error.fromException -let fromExn2 = Error.fromException(someExn) - -let err = Error.make("Some message here") - -let stack1 = err->Error.stack -let stack2 = Error.stack(err) - -let message1 = err->Error.message -let message2 = Error.message(err) - -let name1 = err->Error.name -let name2 = Error.name(err) - -let fileName1 = err->Error.fileName -let fileName2 = Error.fileName(err) - -// Type alias migration -let errT: Error.t = Error.make("Another message") - -// Sub-error constructors -let evalErr = Error.EvalError.make("eval error") -let rangeErr = Error.RangeError.make("range error") -let refErr = Error.ReferenceError.make("reference error") -let synErr = Error.SyntaxError.make("syntax error") -let typeErr = Error.TypeError.make("type error") -let uriErr = Error.URIError.make("uri error") - -let ignore1 = err->Error.ignore -let ignore2 = Error.ignore(err) diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Exn.res b/tests/tools_tests/src/migrate/StdlibMigration_Exn.res deleted file mode 100644 index 47d8e0f2af6..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Exn.res +++ /dev/null @@ -1,50 +0,0 @@ -// Use deprecated Exn APIs to validate migration to JsExn/JsError - -external someExn: exn = "whatever" -external someJsExn: Exn.t = "whatever" - -// fromException (asJsExn) -let fromExn1 = someExn->Exn.asJsExn -let fromExn2 = Exn.asJsExn(someExn) - -// Property accessors on Exn.t -let stack1 = someJsExn->Exn.stack -let stack2 = Exn.stack(someJsExn) - -let message1 = someJsExn->Exn.message -let message2 = Exn.message(someJsExn) - -let name1 = someJsExn->Exn.name -let name2 = Exn.name(someJsExn) - -let fileName1 = someJsExn->Exn.fileName -let fileName2 = Exn.fileName(someJsExn) - -// Type alias migration -let exnT: Exn.t = someJsExn - -// anyToExnInternal -let _coerced = Exn.anyToExnInternal(1) - -// ignore -let ignore1 = someJsExn->Exn.ignore -let ignore2 = Exn.ignore(someJsExn) - -// Raise helpers -let throws1 = () => Exn.raiseError("err") -let throws2 = () => Exn.raiseEvalError("err") -let throws3 = () => Exn.raiseRangeError("err") -let throws4 = () => Exn.raiseReferenceError("err") -let throws5 = () => Exn.raiseSyntaxError("err") -let throws6 = () => Exn.raiseTypeError("err") -let throws7 = () => Exn.raiseUriError("err") - -let someThrowingJsCode = () => Some("bar") -let catchingExnErrorWithSwitch = switch someThrowingJsCode() { -| exception Exn.Error(e) => e->Exn.message -| s => s -} - -let catchingExnErrorWithTryCatch = try {someThrowingJsCode()} catch { -| Exn.Error(e) => e->Exn.message -} diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Int.res b/tests/tools_tests/src/migrate/StdlibMigration_Int.res deleted file mode 100644 index b76172c1a16..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Int.res +++ /dev/null @@ -1,7 +0,0 @@ -let result1 = Int.Bitwise.land(1, 2) -let result2 = Int.Bitwise.lor(1, 2) -let result3 = Int.Bitwise.lxor(1, 2) -let result4 = Int.Bitwise.lsl(1, 2) -let result5 = Int.Bitwise.lsr(1, 2) -let result6 = Int.Bitwise.asr(1, 2) -let result7 = Int.Bitwise.lnot(0) diff --git a/tests/tools_tests/src/migrate/StdlibMigration_JSON_Stdlib.res b/tests/tools_tests/src/migrate/StdlibMigration_JSON_Stdlib.res deleted file mode 100644 index 70f0686c61d..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_JSON_Stdlib.res +++ /dev/null @@ -1,14 +0,0 @@ -let p1 = JSON.parseExn("{}", ~reviver=(_k, v) => v) -let p2 = JSON.parseExnWithReviver("{}", (_k, v) => v) - -let s1 = JSON.stringifyWithIndent(JSON.Object(dict{}), 2) -let s2 = JSON.stringifyWithReplacer(JSON.Number(1.), (_k, v) => v) -let s3 = JSON.stringifyWithReplacerAndIndent(JSON.Boolean(true), (_k, v) => v, 2) -let s4 = JSON.stringifyWithFilter(JSON.Array([JSON.Number(1.)]), ["a"]) -let s5 = JSON.stringifyWithFilterAndIndent(JSON.Array([JSON.Number(1.)]), ["a"], 2) - -let a1 = JSON.stringifyAnyWithIndent(1, 2) -let a2 = JSON.stringifyAnyWithReplacer(1, (_k, v) => v) -let a3 = JSON.stringifyAnyWithReplacerAndIndent(1, (_k, v) => v, 2) -let a4 = JSON.stringifyAnyWithFilter(1, ["a"]) -let a5 = JSON.stringifyAnyWithFilterAndIndent(1, ["a"], 2) diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Pervasives.res b/tests/tools_tests/src/migrate/StdlibMigration_Pervasives.res deleted file mode 100644 index fe8195cbc89..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Pervasives.res +++ /dev/null @@ -1 +0,0 @@ -raise(Failure("test")) diff --git a/tests/tools_tests/src/migrate/StdlibMigration_StdlibArray.res b/tests/tools_tests/src/migrate/StdlibMigration_StdlibArray.res deleted file mode 100644 index a280f164fc0..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_StdlibArray.res +++ /dev/null @@ -1,20 +0,0 @@ -let ba1 = [1, 2, 3, 4, 5]->Array.copyAllWithin(~target=2) -let ba2 = Array.copyAllWithin([1, 2, 3, 4, 5], ~target=2) - -let b1 = [1, 2, 3, 4]->Array.copyWithinToEnd(~target=0, ~start=2) -let b2 = Array.copyWithinToEnd([1, 2, 3, 4], ~target=0, ~start=2) - -let c1 = [1, 2, 3]->Array.fillAll(0) -let c2 = [1, 2, 3, 4]->Array.fillToEnd(9, ~start=1) - -let d1 = [1, 2, 1, 2]->Array.indexOfFrom(2, 2) -let d2 = Array.indexOfFrom([1, 2, 1, 2], 2, 2) - -let e1 = ["a", "b"]->Array.joinWith("-") -let e2 = [1, 2]->Array.joinWithUnsafe(",") - -let f1 = [1, 2, 3, 4]->Array.sliceToEnd(~start=2) - -let g1 = [1, 2]->Array.lastIndexOfFrom(1, 1) - -let h1 = [1, 2]->Array.getUnsafe(1) diff --git a/tests/tools_tests/src/migrate/StdlibMigration_StdlibListLazyPromise.res b/tests/tools_tests/src/migrate/StdlibMigration_StdlibListLazyPromise.res deleted file mode 100644 index a1b091ee230..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_StdlibListLazyPromise.res +++ /dev/null @@ -1,13 +0,0 @@ -let l1 = List.headExn(list{1}) -let l2 = List.tailExn(list{1}) -let l3 = List.getExn(list{"a", "b"}, 0) -let l4 = List.toShuffled(list{1, 2}) - -let lazy1 = Lazy.from_fun(() => 1) -let lazy2 = Lazy.from_val(2) -let v1 = Lazy.force(lazy1) -let v2 = Lazy.force_val(lazy2) -let b1 = Lazy.is_val(lazy1) - -let p = Promise.resolve(5) -let _ = Promise.done(p) diff --git a/tests/tools_tests/src/migrate/StdlibMigration_StdlibOptionResultNull.res b/tests/tools_tests/src/migrate/StdlibMigration_StdlibOptionResultNull.res deleted file mode 100644 index 119d8fcb4a7..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_StdlibOptionResultNull.res +++ /dev/null @@ -1,15 +0,0 @@ -let o1 = Option.getExn(Some(3)) -let o2 = Option.mapWithDefault(Some(3), 0, x => x + 1) -let o3 = Option.getWithDefault(None, 0) - -let r1 = Result.getExn(Ok(1)) -let r2 = Result.mapWithDefault(Ok(1), 0, x => x + 1) -let r3 = Result.getWithDefault(Error("e"), 0) - -let n1 = Null.getExn(Null.make(3)) -let n2 = Null.getWithDefault(Null.null, 0) -let n3 = Null.mapWithDefault(Null.make(3), 0, x => x) - -let nb1 = Nullable.getExn(Nullable.make(3)) -let nb2 = Nullable.getWithDefault(Nullable.null, 0) -let nb3 = Nullable.mapWithDefault(Nullable.make(3), 0, x => x) diff --git a/tests/tools_tests/src/migrate/StdlibMigration_StdlibPrimitives.res b/tests/tools_tests/src/migrate/StdlibMigration_StdlibPrimitives.res deleted file mode 100644 index d3ef05d364d..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_StdlibPrimitives.res +++ /dev/null @@ -1,18 +0,0 @@ -let i1 = Int.toExponentialWithPrecision(77, ~digits=2) -let i2 = Int.toFixedWithPrecision(300, ~digits=1) -let i3 = Int.toPrecisionWithPrecision(100, ~digits=2) -let i4 = Int.toStringWithRadix(6, ~radix=2) -let i5 = Int.rangeWithOptions(1, 5, {step: 2}) - -let f1 = Float.parseIntWithRadix("10.0", ~radix=2) -let f2 = Float.toExponentialWithPrecision(77.0, ~digits=2) -let f3 = Float.toFixedWithPrecision(300.0, ~digits=1) -let f4 = Float.toPrecisionWithPrecision(100.0, ~digits=2) -let f5 = Float.toStringWithRadix(6.0, ~radix=2) - -let b1 = Bool.fromStringExn("true") - -let buf = ArrayBuffer.make(8) -let ab1 = buf->ArrayBuffer.sliceToEnd(~start=2) - -let re1 = RegExp.fromStringWithFlags("\\w+", ~flags="g") diff --git a/tests/tools_tests/src/migrate/StdlibMigration_StdlibString.res b/tests/tools_tests/src/migrate/StdlibMigration_StdlibString.res deleted file mode 100644 index bffbb862355..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_StdlibString.res +++ /dev/null @@ -1,37 +0,0 @@ -let s1 = "abcde"->String.sliceToEnd(~start=1) -let s2 = "abcde"->String.substringToEnd(~start=1) - -let r0 = - "vowels"->String.unsafeReplaceRegExpBy0(/a|e|i|o|u/g, (~match, ~offset as _, ~input as _) => - match - ) -let r1 = - "Jony is 40"->String.unsafeReplaceRegExpBy1(/(Jony is )\d+/g, ( - ~match as _, - ~group1, - ~offset as _, - ~input as _, - ) => group1) - -let r2 = "7 times 6"->String.unsafeReplaceRegExpBy2(/(\d+) times (\d+)/, ( - ~match as _, - ~group1, - ~group2, - ~offset as _, - ~input as _, -) => - switch (Int.fromString(group1), Int.fromString(group2)) { - | (Some(x), Some(y)) => Int.toString(x * y) - | _ => "???" - } -) - -let r3 = - "abc"->String.unsafeReplaceRegExpBy3(/(a)(b)(c)/, ( - ~match as _, - ~group1, - ~group2, - ~group3, - ~offset as _, - ~input as _, - ) => group1 ++ group2 ++ group3) diff --git a/tests/tools_tests/src/migrate/StdlibMigration_TypedArray_Operations.res b/tests/tools_tests/src/migrate/StdlibMigration_TypedArray_Operations.res deleted file mode 100644 index 1aed614db9a..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_TypedArray_Operations.res +++ /dev/null @@ -1,6 +0,0 @@ -let ta = (Uint8Array.fromArray([1, 2, 3, 4]) :> TypedArray.t) - -let a1 = ta->TypedArray.copyWithinToEnd(~target=1, ~start=2) -let a2 = ta->TypedArray.fillToEnd(9, ~start=1) -let a3 = ta->TypedArray.sliceToEnd(~start=1) -let a4 = ta->TypedArray.subarrayToEnd(~start=1) diff --git a/tests/tools_tests/src/migrate/StdlibMigration_TypedArray_Stdlib.res b/tests/tools_tests/src/migrate/StdlibMigration_TypedArray_Stdlib.res deleted file mode 100644 index 10a4e6fb95a..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_TypedArray_Stdlib.res +++ /dev/null @@ -1,3 +0,0 @@ -let a = Uint8Array.fromBufferToEnd(ArrayBuffer.make(8), ~byteOffset=2) -let b = Uint8Array.fromBufferWithRange(ArrayBuffer.make(8), ~byteOffset=2, ~length=2) -let c = Uint8Array.fromArrayLikeOrIterableWithMap([1, 2], (v, _i) => v) diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_Migrate_Templates.res b/tests/tools_tests/src/migrate/migrated/Migrated_Migrate_Templates.res new file mode 100644 index 00000000000..270c01f3f05 --- /dev/null +++ b/tests/tools_tests/src/migrate/migrated/Migrated_Migrate_Templates.res @@ -0,0 +1,31 @@ +// This file is autogenerated so it can be type checked. +// It's the migrated version of src/migrate/Migrate_Templates.res. +// Uses the deprecated items of DeprecatedTemplates to validate each kind of migration template. + +// %replace.type +let value: DeprecatedTemplates.Target.t = DeprecatedTemplates.Target.make(1) + +// A fixed labelled argument +let fromZero1 = DeprecatedTemplates.Target.make(1, ~start=0) +let fromZero2 = 1->DeprecatedTemplates.Target.make(~start=0) + +// An unlabelled argument inserted as a labelled one +let options1 = DeprecatedTemplates.Target.fromOptions(2, ~options={step: 3}) +let options2 = 2->DeprecatedTemplates.Target.fromOptions(~options={step: 3}) + +// An unlabelled argument inserted into a function +let delayed = DeprecatedTemplates.Target.delay(() => 4) + +// An operator built from unlabelled arguments +let sum1 = 1 + 2 + +// %replace.constructor +let caught = switch throw(DeprecatedTemplates.Target.Failed("boom")) { +| exception DeprecatedTemplates.Target.Failed(message) => message +| () => "" +} + +let matched = switch DeprecatedTemplates.Target.Failed("boom") { +| DeprecatedTemplates.Target.Failed(message) => message +| _ => "" +} diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_DataView.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_DataView.res deleted file mode 100644 index a0ddcc6d1a3..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_DataView.res +++ /dev/null @@ -1,4 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_DataView.res. -let a = DataView.fromBuffer(ArrayBuffer.make(8), ~byteOffset=2) -let b = DataView.fromBuffer(ArrayBuffer.make(8), ~byteOffset=2, ~length=4) diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Error.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Error.res deleted file mode 100644 index 114ac55b780..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Error.res +++ /dev/null @@ -1,36 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Error.res. -// Use deprecated Error APIs to validate migration to JsError/JsExn - -external someExn: exn = "whatever" - -let fromExn1 = someExn->JsExn.fromException -let fromExn2 = JsExn.fromException(someExn) - -let err = JsError.make("Some message here") - -let stack1 = err->JsError.stack -let stack2 = JsError.stack(err) - -let message1 = err->JsError.message -let message2 = JsError.message(err) - -let name1 = err->JsError.name -let name2 = JsError.name(err) - -let fileName1 = err->JsError.fileName -let fileName2 = JsError.fileName(err) - -// Type alias migration -let errT: JsError.t = JsError.make("Another message") - -// Sub-error constructors -let evalErr = JsError.EvalError.make("eval error") -let rangeErr = JsError.RangeError.make("range error") -let refErr = JsError.ReferenceError.make("reference error") -let synErr = JsError.SyntaxError.make("syntax error") -let typeErr = JsError.TypeError.make("type error") -let uriErr = JsError.URIError.make("uri error") - -let ignore1 = err->JsError.ignore -let ignore2 = JsError.ignore(err) diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Exn.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Exn.res deleted file mode 100644 index 9577412043e..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Exn.res +++ /dev/null @@ -1,52 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Exn.res. -// Use deprecated Exn APIs to validate migration to JsExn/JsError - -external someExn: exn = "whatever" -external someJsExn: JsExn.t = "whatever" - -// fromException (asJsExn) -let fromExn1 = someExn->JsExn.fromException -let fromExn2 = JsExn.fromException(someExn) - -// Property accessors on Exn.t -let stack1 = someJsExn->JsExn.stack -let stack2 = JsExn.stack(someJsExn) - -let message1 = someJsExn->JsExn.message -let message2 = JsExn.message(someJsExn) - -let name1 = someJsExn->JsExn.name -let name2 = JsExn.name(someJsExn) - -let fileName1 = someJsExn->JsExn.fileName -let fileName2 = JsExn.fileName(someJsExn) - -// Type alias migration -let exnT: JsExn.t = someJsExn - -// anyToExnInternal -let _coerced = JsExn.anyToExnInternal(1) - -// ignore -let ignore1 = someJsExn->JsExn.ignore -let ignore2 = JsExn.ignore(someJsExn) - -// Raise helpers -let throws1 = () => JsError.throwWithMessage("err") -let throws2 = () => JsError.EvalError.throwWithMessage("err") -let throws3 = () => JsError.RangeError.throwWithMessage("err") -let throws4 = () => JsError.ReferenceError.throwWithMessage("err") -let throws5 = () => JsError.SyntaxError.throwWithMessage("err") -let throws6 = () => JsError.TypeError.throwWithMessage("err") -let throws7 = () => JsError.URIError.throwWithMessage("err") - -let someThrowingJsCode = () => Some("bar") -let catchingExnErrorWithSwitch = switch someThrowingJsCode() { -| exception JsExn(e) => e->JsExn.message -| s => s -} - -let catchingExnErrorWithTryCatch = try {someThrowingJsCode()} catch { -| JsExn(e) => e->JsExn.message -} diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Int.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Int.res deleted file mode 100644 index 43b70137c8f..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Int.res +++ /dev/null @@ -1,9 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Int.res. -let result1 = Int.bitwiseAnd(1, 2) -let result2 = Int.bitwiseOr(1, 2) -let result3 = Int.bitwiseXor(1, 2) -let result4 = Int.shiftLeft(1, 2) -let result5 = Int.shiftRightUnsigned(1, 2) -let result6 = Int.shiftRight(1, 2) -let result7 = Int.bitwiseNot(0) diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_JSON_Stdlib.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_JSON_Stdlib.res deleted file mode 100644 index a5c3e925c83..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_JSON_Stdlib.res +++ /dev/null @@ -1,16 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_JSON_Stdlib.res. -let p1 = JSON.parseExn("{}", ~reviver=(_k, v) => v) -let p2 = JSON.parseExnWithReviver("{}", (_k, v) => v) - -let s1 = JSON.stringifyWithIndent(JSON.Object(dict{}), 2) -let s2 = JSON.stringifyWithReplacer(JSON.Number(1.), (_k, v) => v) -let s3 = JSON.stringifyWithReplacerAndIndent(JSON.Boolean(true), (_k, v) => v, 2) -let s4 = JSON.stringifyWithFilter(JSON.Array([JSON.Number(1.)]), ["a"]) -let s5 = JSON.stringifyWithFilterAndIndent(JSON.Array([JSON.Number(1.)]), ["a"], 2) - -let a1 = JSON.stringifyAnyWithIndent(1, 2) -let a2 = JSON.stringifyAnyWithReplacer(1, (_k, v) => v) -let a3 = JSON.stringifyAnyWithReplacerAndIndent(1, (_k, v) => v, 2) -let a4 = JSON.stringifyAnyWithFilter(1, ["a"]) -let a5 = JSON.stringifyAnyWithFilterAndIndent(1, ["a"], 2) diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Pervasives.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Pervasives.res deleted file mode 100644 index fef6b587c93..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Pervasives.res +++ /dev/null @@ -1,3 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Pervasives.res. -throw(Failure("test")) diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_StdlibArray.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_StdlibArray.res deleted file mode 100644 index 03c5b7c14a6..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_StdlibArray.res +++ /dev/null @@ -1,22 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_StdlibArray.res. -let ba1 = [1, 2, 3, 4, 5]->Array.copyWithin(~target=2, ~start=0) -let ba2 = Array.copyWithin([1, 2, 3, 4, 5], ~target=2, ~start=0) - -let b1 = [1, 2, 3, 4]->Array.copyWithin(~target=0, ~start=2) -let b2 = Array.copyWithin([1, 2, 3, 4], ~target=0, ~start=2) - -let c1 = [1, 2, 3]->Array.fill(0) -let c2 = [1, 2, 3, 4]->Array.fill(9, ~start=1) - -let d1 = [1, 2, 1, 2]->Array.indexOf(2, ~from=2) -let d2 = Array.indexOf([1, 2, 1, 2], 2, ~from=2) - -let e1 = ["a", "b"]->Array.join("-") -let e2 = [1, 2]->Array.joinUnsafe(",") - -let f1 = [1, 2, 3, 4]->Array.slice(~start=2) - -let g1 = [1, 2]->Array.lastIndexOf(1, ~from=1) - -let h1 = [1, 2]->Array.getUnsafe(1) diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_StdlibListLazyPromise.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_StdlibListLazyPromise.res deleted file mode 100644 index 297dce36f74..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_StdlibListLazyPromise.res +++ /dev/null @@ -1,15 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_StdlibListLazyPromise.res. -let l1 = List.headOrThrow(list{1}) -let l2 = List.tailOrThrow(list{1}) -let l3 = List.getOrThrow(list{"a", "b"}, 0) -let l4 = List.shuffle(list{1, 2}) - -let lazy1 = Lazy.make(() => 1) -let lazy2 = Lazy.make(() => 2) -let v1 = Lazy.get(lazy1) -let v2 = Lazy.get(lazy2) -let b1 = Lazy.isEvaluated(lazy1) - -let p = Promise.resolve(5) -let _ = Promise.ignore(p) diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_StdlibOptionResultNull.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_StdlibOptionResultNull.res deleted file mode 100644 index 79f981af5d5..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_StdlibOptionResultNull.res +++ /dev/null @@ -1,17 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_StdlibOptionResultNull.res. -let o1 = Option.getOrThrow(Some(3)) -let o2 = Option.mapOr(Some(3), 0, x => x + 1) -let o3 = Option.getOr(None, 0) - -let r1 = Result.getOrThrow(Ok(1)) -let r2 = Result.mapOr(Ok(1), 0, x => x + 1) -let r3 = Result.getOr(Error("e"), 0) - -let n1 = Null.getOrThrow(Null.make(3)) -let n2 = Null.getOr(Null.null, 0) -let n3 = Null.mapOr(Null.make(3), 0, x => x) - -let nb1 = Nullable.getOrThrow(Nullable.make(3)) -let nb2 = Nullable.getOr(Nullable.null, 0) -let nb3 = Nullable.mapOr(Nullable.make(3), 0, x => x) diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_StdlibPrimitives.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_StdlibPrimitives.res deleted file mode 100644 index 54758d538c3..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_StdlibPrimitives.res +++ /dev/null @@ -1,20 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_StdlibPrimitives.res. -let i1 = Int.toExponential(77, ~digits=2) -let i2 = Int.toFixed(300, ~digits=1) -let i3 = Int.toPrecision(100, ~digits=2) -let i4 = Int.toString(6, ~radix=2) -let i5 = Int.range(1, 5, ~options={step: 2}) - -let f1 = Float.parseInt("10.0", ~radix=2) -let f2 = Float.toExponential(77.0, ~digits=2) -let f3 = Float.toFixed(300.0, ~digits=1) -let f4 = Float.toPrecision(100.0, ~digits=2) -let f5 = Float.toString(6.0, ~radix=2) - -let b1 = Bool.fromStringOrThrow("true") - -let buf = ArrayBuffer.make(8) -let ab1 = buf->ArrayBuffer.slice(~start=2) - -let re1 = RegExp.fromString("\\w+", ~flags="g") diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_StdlibString.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_StdlibString.res deleted file mode 100644 index 3bc9c59b261..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_StdlibString.res +++ /dev/null @@ -1,39 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_StdlibString.res. -let s1 = "abcde"->String.slice(~start=1) -let s2 = "abcde"->String.substring(~start=1) - -let r0 = - "vowels"->String.replaceRegExpBy0Unsafe(/a|e|i|o|u/g, (~match, ~offset as _, ~input as _) => - match - ) -let r1 = - "Jony is 40"->String.replaceRegExpBy1Unsafe(/(Jony is )\d+/g, ( - ~match as _, - ~group1, - ~offset as _, - ~input as _, - ) => group1) - -let r2 = "7 times 6"->String.replaceRegExpBy2Unsafe(/(\d+) times (\d+)/, ( - ~match as _, - ~group1, - ~group2, - ~offset as _, - ~input as _, -) => - switch (Int.fromString(group1), Int.fromString(group2)) { - | (Some(x), Some(y)) => Int.toString(x * y) - | _ => "???" - } -) - -let r3 = - "abc"->String.replaceRegExpBy3Unsafe(/(a)(b)(c)/, ( - ~match as _, - ~group1, - ~group2, - ~group3, - ~offset as _, - ~input as _, - ) => group1 ++ group2 ++ group3) diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_TypedArray_Operations.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_TypedArray_Operations.res deleted file mode 100644 index 46bb22556e4..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_TypedArray_Operations.res +++ /dev/null @@ -1,8 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_TypedArray_Operations.res. -let ta = (Uint8Array.fromArray([1, 2, 3, 4]) :> TypedArray.t) - -let a1 = ta->TypedArray.copyWithin(~target=1, ~start=2) -let a2 = ta->TypedArray.fill(9, ~start=1) -let a3 = ta->TypedArray.slice(~start=1) -let a4 = ta->TypedArray.subarray(~start=1) diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_TypedArray_Stdlib.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_TypedArray_Stdlib.res deleted file mode 100644 index fd287000229..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_TypedArray_Stdlib.res +++ /dev/null @@ -1,5 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_TypedArray_Stdlib.res. -let a = Uint8Array.fromBuffer(ArrayBuffer.make(8), ~byteOffset=2) -let b = Uint8Array.fromBuffer(ArrayBuffer.make(8), ~byteOffset=2, ~length=2) -let c = Uint8Array.fromArrayLikeOrIterable([1, 2], ~map=(v, _i) => v) diff --git a/tests/tools_tests/test.sh b/tests/tools_tests/test.sh index 928e575663f..36ed4af46a7 100755 --- a/tests/tools_tests/test.sh +++ b/tests/tools_tests/test.sh @@ -103,7 +103,7 @@ for stale_file in src/migrate/FileToMigrate.res src/migrate/DeprecatedStuff.resi done # Move migrated files to expected directory so they can be compiled in the project -for file in src/migrate/StdlibMigration_*.res; do +for file in src/migrate/Migrate_*.res; do expected_file="src/expected/$(basename $file).expected" output="src/migrate/migrated/Migrated_$(basename $file)" echo "// This file is autogenerated so it can be type checked. From fd9924f2392f75ce421431f6150c43f85992f311 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Mon, 26 Oct 2026 09:57:02 +0000 Subject: [PATCH 3/4] Migrate tests to the replacement APIs Tests and fixtures that used the removed APIs now use the replacements their migration templates name; snapshots are regenerated. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013ZYFYMu3AE9P1xFVCR34d1 Signed-off-by: Christoph Knittel --- .../deadcode/expected/deadcode.txt | 2 +- .../deadcode/src/DeadValueTest.res | 2 +- .../deadcode/src/exception/Exn.res | 6 +- .../deadcode/src/exception/StdlibTest.res | 8 +- .../tests/src/DotPipeCompletionSpec.res | 4 +- .../tests/src/expected/Completion.res.txt | 222 +-------------- .../tests/src/expected/CompletionChar.res.txt | 11 - .../expected/CompletionDictPattern.res.txt | 33 --- .../expected/CompletionExpressions.res.txt | 10 +- .../expected/CompletionInferValues.res.txt | 176 ------------ .../tests/src/expected/CompletionJsx.res.txt | 204 ++------------ .../expected/CompletionNullNullable.res.txt | 132 --------- .../src/expected/CompletionPattern.res.txt | 2 +- .../src/expected/CompletionPipeChain.res.txt | 44 --- .../src/expected/CompletionRegexp.res.txt | 12 +- .../expected/DotPipeCompletionSpec.res.txt | 54 ++-- tests/belt_tests/src/ticker.mjs | 260 ++++++++++++------ tests/belt_tests/src/ticker.res | 7 +- tests/build_tests/source_map/input.js | 6 +- tests/build_tests/source_map/src/Demo.res | 4 +- tests/build_tests/source_map/src/Helper.res | 2 +- ...ss_deprecated_with_automigration.expected} | 7 +- .../Legacy.res | 2 + .../Legacy.resi | 7 + .../User.res} | 2 +- tests/tests/src/UntaggedVariants.res | 4 +- tests/tests/src/bench.mjs | 7 +- tests/tests/src/bench.res | 2 +- tests/tests/src/bigint_test.res | 8 +- .../src/conditional/cond_a_load_test.mjs | 19 +- .../src/conditional/cond_a_load_test.res | 4 +- tests/tests/src/const_defs_test.mjs | 7 +- tests/tests/src/const_defs_test.res | 2 +- tests/tests/src/defunctor_make_test.mjs | 33 ++- tests/tests/src/defunctor_make_test.res | 8 +- tests/tests/src/earger_curry_test.mjs | 7 +- tests/tests/src/earger_curry_test.res | 2 +- tests/tests/src/exception_alias.mjs | 9 - tests/tests/src/exception_raise_test.mjs | 4 +- tests/tests/src/exception_raise_test.res | 2 +- tests/tests/src/ext_array_test.mjs | 19 +- tests/tests/src/ext_array_test.res | 4 +- tests/tests/src/flexible_array_test.mjs | 29 +- tests/tests/src/flexible_array_test.res | 8 +- tests/tests/src/gpr_2316_test.mjs | 17 +- tests/tests/src/gpr_2316_test.res | 4 +- tests/tests/src/gpr_2608_test.mjs | 4 +- tests/tests/src/gpr_2608_test.res | 4 +- tests/tests/src/gpr_3697_test.mjs | 6 +- tests/tests/src/gpr_3697_test.res | 6 +- tests/tests/src/inline_map2_test.mjs | 115 ++++++-- tests/tests/src/inline_map2_test.res | 10 +- tests/tests/src/inline_map_test.mjs | 33 ++- tests/tests/src/inline_map_test.res | 10 +- tests/tests/src/lazy_test.mjs | 26 +- tests/tests/src/lazy_test.res | 20 +- tests/tests/src/mario_game.mjs | 43 ++- tests/tests/src/mario_game.res | 14 +- tests/tests/src/mpr_6033_test.mjs | 2 +- tests/tests/src/mpr_6033_test.res | 2 +- tests/tests/src/recursive_records_test.mjs | 4 +- tests/tests/src/recursive_records_test.res | 4 +- tests/tests/src/set_gen.mjs | 7 +- tests/tests/src/set_gen.res | 2 +- tests/tests/src/stdlib/Stdlib_IntTests.mjs | 7 +- tests/tests/src/stdlib/Stdlib_IntTests.res | 2 +- tests/tests/src/stdlib/Stdlib_PromiseTest.mjs | 6 +- tests/tests/src/stdlib/Stdlib_PromiseTest.res | 4 +- tests/tests/src/stdlib/Stdlib_RegExpTest.res | 4 +- tests/tests/src/stdlib/Stdlib_TempTests.mjs | 11 +- tests/tests/src/stdlib/Stdlib_TempTests.res | 16 +- .../src/stdlib/Stdlib_TypedArrayTests.mjs | 14 +- .../src/stdlib/Stdlib_TypedArrayTests.res | 22 +- tests/tests/src/stdlib/Test.mjs | 2 +- tests/tests/src/stdlib/Test.res | 2 +- tests/tests/src/test_ari.mjs | 27 -- tests/tests/src/test_include.mjs | 27 -- tests/tests/src/test_list.mjs | 235 ++++++++++------ tests/tests/src/test_list.res | 24 +- tests/tests/src/test_pervasive.mjs | 19 +- tests/tests/src/test_pervasives3.mjs | 69 +---- tests/tests/src/test_set.mjs | 39 ++- tests/tests/src/test_set.res | 10 +- tests/tests/src/topsort_test.mjs | 12 +- tests/tests/src/topsort_test.res | 12 +- tests/tests/src/unsafe_ppx_test.mjs | 9 +- tests/tests/src/unsafe_ppx_test.res | 2 +- 87 files changed, 874 insertions(+), 1431 deletions(-) rename tests/build_tests/{super_errors/expected/deprecated_with_automigration.res.expected => super_errors_multi/expected/Cross_deprecated_with_automigration.expected} (66%) create mode 100644 tests/build_tests/super_errors_multi/fixtures/Cross_deprecated_with_automigration/Legacy.res create mode 100644 tests/build_tests/super_errors_multi/fixtures/Cross_deprecated_with_automigration/Legacy.resi rename tests/build_tests/{super_errors/fixtures/deprecated_with_automigration.res => super_errors_multi/fixtures/Cross_deprecated_with_automigration/User.res} (66%) diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/expected/deadcode.txt b/tests/analysis_tests/tests-reanalyze/deadcode/expected/deadcode.txt index 2768e0af73b..678ca9ed6ce 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/expected/deadcode.txt +++ b/tests/analysis_tests/tests-reanalyze/deadcode/expected/deadcode.txt @@ -2200,7 +2200,7 @@ valueOnlyInImplementation is never used Warning Dead Value - DeadValueTest.res:6:1-260 + DeadValueTest.res:6:1-266 subList is never used Warning Dead Value diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/DeadValueTest.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/DeadValueTest.res index 04689d45bac..338c6fa7a39 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/DeadValueTest.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/DeadValueTest.res @@ -5,7 +5,7 @@ let valueOnlyInImplementation = 3 let rec subList = (b, e, l) => switch l { - | list{} => failwith("subList") + | list{} => throw(Failure("subList")) | list{h, ...t} => let tail = if e == 0 { list{} diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/Exn.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/Exn.res index dd7bb400a08..801ff67ff9d 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/Exn.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/Exn.res @@ -120,9 +120,9 @@ let bar = () => JSON.parseOrThrow("!!!") let severalCases = cases => switch cases { - | "one" => failwith("one") - | "two" => failwith("two") - | "three" => failwith("three") + | "one" => throw(Failure("one")) + | "two" => throw(Failure("two")) + | "three" => throw(Failure("three")) | _ => () } diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/StdlibTest.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/StdlibTest.res index 79585f7db6a..63868d7a7e8 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/StdlibTest.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/StdlibTest.res @@ -1,11 +1,11 @@ @throws(JsExn) -let optionGetExn = o => o->Option.getExn +let optionGetOrThrow = o => o->Option.getOrThrow -@throws(Not_found) -let resultGetExn = r => r->Result.getExn +@throws(JsExn) +let resultGetOrThrow = r => r->Result.getOrThrow @throws(Invalid_argument) -let nullGetExn = n => n->Null.getExn +let nullGetOrThrow = n => n->Null.getOrThrow @throws(JsExn) let bigIntFromStringExn = s => s->BigInt.fromStringOrThrow diff --git a/tests/analysis_tests/tests/src/DotPipeCompletionSpec.res b/tests/analysis_tests/tests/src/DotPipeCompletionSpec.res index b5a55ac94a4..c90803d4a8a 100644 --- a/tests/analysis_tests/tests/src/DotPipeCompletionSpec.res +++ b/tests/analysis_tests/tests/src/DotPipeCompletionSpec.res @@ -87,8 +87,8 @@ let xxxx = [1, 2] // xxxx->Array.filter(v => v > 10).filt // ^com -// xxxx->Array.filter(v => v > 10)->Array.joinWith(",").includ -// ^com +// xxxx->Array.filter(v => v > 10)->Array.join(",").includ +// ^com let str = "hello" diff --git a/tests/analysis_tests/tests/src/expected/Completion.res.txt b/tests/analysis_tests/tests/src/expected/Completion.res.txt index ad314a633fb..446bdac5984 100644 --- a/tests/analysis_tests/tests/src/expected/Completion.res.txt +++ b/tests/analysis_tests/tests/src/expected/Completion.res.txt @@ -148,28 +148,6 @@ Path Array. "label": "concatMany", "tags": [] }, - { - "deprecated": true, - "detail": "(array, string) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `join` instead\n\n\n`joinWith(array, separator)` produces a string where all items of `array` are printed, separated by `separator`. Array items must be strings, to join number or other arrays, use `joinWithUnsafe`. Under the hood this will run JavaScript's `toString` on all the array items.\n\n## Examples\n\n```rescript\n[\"One\", \"Two\", \"Three\"]->Array.joinWith(\" -- \") == \"One -- Two -- Three\"\n```\n" - }, - "kind": 12, - "label": "joinWith", - "tags": [ 1 ] - }, - { - "deprecated": true, - "detail": "(array<'a>, string) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `joinUnsafe` instead\n\n\n`joinWithUnsafe(array, separator)` produces a string where all items of `array` are printed, separated by `separator`. Under the hood this will run JavaScript's `toString` on all the array items.\n\n## Examples\n\n```rescript\n[1, 2, 3]->Array.joinWithUnsafe(\" -- \") == \"1 -- 2 -- 3\"\n```\n" - }, - "kind": 12, - "label": "joinWithUnsafe", - "tags": [ 1 ] - }, { "detail": "(array<'a>, 'b, ('b, 'a) => 'b) => 'b", "documentation": { @@ -300,17 +278,6 @@ Path Array. "label": "zip", "tags": [] }, - { - "deprecated": true, - "detail": "(array<'a>, 'a, ~start: int) => unit", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `fill` instead\n\n\n`fillToEnd(array, value, ~start)` fills `array` with `value` from the `start` index.\n\nBeware this will *mutate* the array.\n\nSee [`Array.fill`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill) on MDN.\n\n## Examples\n\n```rescript\nlet myArray = [1, 2, 3, 4]\nmyArray->Array.fillToEnd(9, ~start=1)\nmyArray == [1, 9, 9, 9]\n```\n" - }, - "kind": 12, - "label": "fillToEnd", - "tags": [ 1 ] - }, { "detail": "(array<'a>, 'a) => bool", "documentation": { @@ -361,17 +328,6 @@ Path Array. "label": "make", "tags": [] }, - { - "deprecated": true, - "detail": "(array<'a>, 'a, int) => int", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `lastIndexOf` instead\n\n" - }, - "kind": 12, - "label": "lastIndexOfFrom", - "tags": [ 1 ] - }, { "detail": "array<'a> => string", "documentation": { @@ -718,17 +674,6 @@ Path Array. "label": "reduce", "tags": [] }, - { - "deprecated": true, - "detail": "(array<'a>, ~start: int) => array<'a>", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `slice` instead\n\n\n`sliceToEnd(array, start)` creates a new array from `array`, with all items from `array` starting from `start`.\n\nSee [`Array.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice) on MDN.\n\n## Examples\n\n```rescript\n[1, 2, 3, 4]->Array.sliceToEnd(~start=1) == [2, 3, 4]\n```\n" - }, - "kind": 12, - "label": "sliceToEnd", - "tags": [ 1 ] - }, { "detail": "(arrayLike<'a>, 'a => 'b) => array<'b>", "documentation": { @@ -739,17 +684,6 @@ Path Array. "label": "fromArrayLikeWithMap", "tags": [] }, - { - "deprecated": true, - "detail": "(array<'a>, 'a) => unit", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `fill` instead\n\n\n`fillAll(array, value)` fills the entire `array` with `value`.\n\nBeware this will *mutate* the array.\n\nSee [`Array.fill`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill) on MDN.\n\n## Examples\n\n```rescript\nlet myArray = [1, 2, 3, 4]\nmyArray->Array.fillAll(9)\nmyArray == [9, 9, 9, 9]\n```\n" - }, - "kind": 12, - "label": "fillAll", - "tags": [ 1 ] - }, { "detail": "(array<'a>, int, 'a) => unit", "documentation": { @@ -850,17 +784,6 @@ Path Array. "label": "flatMapWithIndex", "tags": [] }, - { - "deprecated": true, - "detail": "(array<'a>, ~target: int, ~start: int) => array<'a>", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `copyWithin` instead\n\n\n`copyWithinToEnd(array, ~target, ~start)` copies starting at element `start` in the given array to the designated `target` position, returning the resulting array.\n\nBeware this will *mutate* the array.\n\nSee [`Array.copyWithin`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin) on MDN.\n\n## Examples\n\n```rescript\nlet arr = [100, 101, 102, 103, 104]\narr->Array.copyWithinToEnd(~target=0, ~start=2) == [102, 103, 104, 103, 104]\narr == [102, 103, 104, 103, 104]\n```\n" - }, - "kind": 12, - "label": "copyWithinToEnd", - "tags": [ 1 ] - }, { "detail": "(array<'a>, 'a) => unit", "documentation": { @@ -931,17 +854,6 @@ Path Array. "label": "partition", "tags": [] }, - { - "deprecated": true, - "detail": "(array<'a>, ~target: int) => array<'a>", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `copyWithin` instead\n\n\n`isEmpty(array)` returns `true` if the array is empty (has length 0), `false` otherwise.\n\n## Examples\n\n```rescript\nlet arr = [100, 101, 102, 103, 104]\narr->Array.copyAllWithin(~target=2) == [100, 101, 100, 101, 102]\narr == [100, 101, 100, 101, 102]\n```\n" - }, - "kind": 12, - "label": "copyAllWithin", - "tags": [ 1 ] - }, { "detail": "array> => array<'a>", "documentation": { @@ -1061,17 +973,6 @@ Path Array. "kind": 12, "label": "fromArrayLike", "tags": [] - }, - { - "deprecated": true, - "detail": "(array<'a>, 'a, int) => int", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `indexOf` instead\n\n" - }, - "kind": 12, - "label": "indexOfFrom", - "tags": [ 1 ] } ] @@ -2470,7 +2371,7 @@ Hover src/Completion.res 349:14 { "contents": { "kind": "markdown", - "value": "```rescript\nJsxDOM.domProps\n```\n\n---\n\n```\n \n```\n```rescript\ntype JsxDOM.domProps = {\n key?: string,\n children?: Jsx.element,\n ref?: domRef,\n allow?: string,\n ariaCurrent?: [\n | #date\n | #\"false\"\n | #location\n | #page\n | #step\n | #time\n | #\"true\"\n ],\n ariaDetails?: string,\n ariaDisabled?: bool,\n ariaHidden?: bool,\n ariaInvalid?: [#\"false\" | #grammar | #spelling | #\"true\"],\n ariaKeyshortcuts?: string,\n ariaLabel?: string,\n ariaRoledescription?: string,\n ariaAutocomplete?: [#both | #inline | #list | #none],\n ariaChecked?: [#\"false\" | #mixed | #\"true\"],\n ariaExpanded?: bool,\n ariaHaspopup?: [\n | #dialog\n | #\"false\"\n | #grid\n | #listbox\n | #menu\n | #tree\n | #\"true\"\n ],\n ariaLevel?: int,\n ariaModal?: bool,\n ariaMultiline?: bool,\n ariaMultiselectable?: bool,\n ariaOrientation?: [#horizontal | #undefined | #vertical],\n ariaPlaceholder?: string,\n ariaPressed?: [#\"false\" | #mixed | #\"true\"],\n ariaReadonly?: bool,\n ariaRequired?: bool,\n ariaSelected?: bool,\n ariaSort?: string,\n ariaValuemax?: float,\n ariaValuemin?: float,\n ariaValuenow?: float,\n ariaValuetext?: string,\n ariaAtomic?: bool,\n ariaBusy?: bool,\n ariaLive?: [#assertive | #off | #polite | #rude],\n ariaRelevant?: string,\n ariaDropeffect?: [\n | #copy\n | #execute\n | #link\n | #move\n | #none\n | #popup\n ],\n ariaGrabbed?: bool,\n ariaActivedescendant?: string,\n ariaColcount?: int,\n ariaColindex?: int,\n ariaColspan?: int,\n ariaControls?: string,\n ariaDescribedby?: string,\n ariaErrormessage?: string,\n ariaFlowto?: string,\n ariaLabelledby?: string,\n ariaOwns?: string,\n ariaPosinset?: int,\n ariaRowcount?: int,\n ariaRowindex?: int,\n ariaRowspan?: int,\n ariaSetsize?: int,\n defaultChecked?: bool,\n defaultValue?: string,\n accessKey?: string,\n capture?: [#environment | #user],\n className?: string,\n contentEditable?: bool,\n contextMenu?: string,\n dataTestId?: string,\n dir?: string,\n draggable?: bool,\n hidden?: bool,\n id?: string,\n inert?: bool,\n lang?: string,\n popover?: popover,\n popoverTarget?: string,\n popoverTargetAction?: popoverTargetAction,\n role?: string,\n style?: style,\n spellCheck?: bool,\n tabIndex?: int,\n title?: string,\n itemID?: string,\n itemProp?: string,\n itemRef?: string,\n itemScope?: bool,\n itemType?: string,\n accept?: string,\n acceptCharset?: string,\n action?: string,\n allowFullScreen?: bool,\n alt?: string,\n as_?: string,\n async?: bool,\n autoComplete?: string,\n autoCapitalize?: string,\n autoFocus?: bool,\n autoPlay?: bool,\n challenge?: string,\n charSet?: string,\n checked?: bool,\n cite?: string,\n crossOrigin?: string,\n cols?: int,\n colSpan?: int,\n content?: string,\n controls?: bool,\n coords?: string,\n data?: string,\n dateTime?: string,\n default?: bool,\n defer?: bool,\n disabled?: bool,\n download?: string,\n encType?: string,\n form?: string,\n formAction?: string,\n formTarget?: string,\n formMethod?: string,\n frameBorder?: int,\n headers?: string,\n height?: string,\n high?: int,\n href?: string,\n hrefLang?: string,\n htmlFor?: string,\n httpEquiv?: string,\n icon?: string,\n inputMode?: string,\n integrity?: string,\n keyType?: string,\n kind?: string,\n label?: string,\n list?: string,\n loading?: [#eager | #lazy],\n loop?: bool,\n low?: int,\n manifest?: string,\n max?: string,\n maxLength?: int,\n media?: string,\n mediaGroup?: string,\n method?: string,\n min?: string,\n minLength?: int,\n multiple?: bool,\n muted?: bool,\n name?: string,\n nonce?: string,\n noValidate?: bool,\n open_?: bool,\n optimum?: int,\n pattern?: string,\n placeholder?: string,\n playsInline?: bool,\n poster?: string,\n preload?: string,\n radioGroup?: string,\n readOnly?: bool,\n rel?: string,\n required?: bool,\n reversed?: bool,\n rows?: int,\n rowSpan?: int,\n sandbox?: string,\n scope?: string,\n scoped?: bool,\n scrolling?: string,\n selected?: bool,\n shape?: string,\n size?: int,\n sizes?: string,\n span?: int,\n src?: string,\n srcDoc?: string,\n srcLang?: string,\n srcSet?: string,\n start?: int,\n step?: float,\n summary?: string,\n target?: string,\n type_?: string,\n useMap?: string,\n value?: string,\n width?: string,\n wrap?: string,\n onCopy?: JsxEvent.Clipboard.t => unit,\n onCut?: JsxEvent.Clipboard.t => unit,\n onPaste?: JsxEvent.Clipboard.t => unit,\n onCompositionEnd?: JsxEvent.Composition.t => unit,\n onCompositionStart?: JsxEvent.Composition.t => unit,\n onCompositionUpdate?: JsxEvent.Composition.t => unit,\n onKeyDown?: JsxEvent.Keyboard.t => unit,\n onKeyPress?: JsxEvent.Keyboard.t => unit,\n onKeyUp?: JsxEvent.Keyboard.t => unit,\n onFocus?: JsxEvent.Focus.t => unit,\n onBlur?: JsxEvent.Focus.t => unit,\n onBeforeInput?: JsxEvent.Form.t => unit,\n onChange?: JsxEvent.Form.t => unit,\n onInput?: JsxEvent.Form.t => unit,\n onReset?: JsxEvent.Form.t => unit,\n onSubmit?: JsxEvent.Form.t => unit,\n onInvalid?: JsxEvent.Form.t => unit,\n onClick?: JsxEvent.Mouse.t => unit,\n onContextMenu?: JsxEvent.Mouse.t => unit,\n onDoubleClick?: JsxEvent.Mouse.t => unit,\n onDrag?: JsxEvent.Mouse.t => unit,\n onDragEnd?: JsxEvent.Mouse.t => unit,\n onDragEnter?: JsxEvent.Mouse.t => unit,\n onDragExit?: JsxEvent.Mouse.t => unit,\n onDragLeave?: JsxEvent.Mouse.t => unit,\n onDragOver?: JsxEvent.Mouse.t => unit,\n onDragStart?: JsxEvent.Mouse.t => unit,\n onDrop?: JsxEvent.Mouse.t => unit,\n onMouseDown?: JsxEvent.Mouse.t => unit,\n onMouseEnter?: JsxEvent.Mouse.t => unit,\n onMouseLeave?: JsxEvent.Mouse.t => unit,\n onMouseMove?: JsxEvent.Mouse.t => unit,\n onMouseOut?: JsxEvent.Mouse.t => unit,\n onMouseOver?: JsxEvent.Mouse.t => unit,\n onMouseUp?: JsxEvent.Mouse.t => unit,\n onSelect?: JsxEvent.Selection.t => unit,\n onTouchCancel?: JsxEvent.Touch.t => unit,\n onTouchEnd?: JsxEvent.Touch.t => unit,\n onTouchMove?: JsxEvent.Touch.t => unit,\n onTouchStart?: JsxEvent.Touch.t => unit,\n onPointerOver?: JsxEvent.Pointer.t => unit,\n onPointerEnter?: JsxEvent.Pointer.t => unit,\n onPointerDown?: JsxEvent.Pointer.t => unit,\n onPointerMove?: JsxEvent.Pointer.t => unit,\n onPointerUp?: JsxEvent.Pointer.t => unit,\n onPointerCancel?: JsxEvent.Pointer.t => unit,\n onPointerOut?: JsxEvent.Pointer.t => unit,\n onPointerLeave?: JsxEvent.Pointer.t => unit,\n onGotPointerCapture?: JsxEvent.Pointer.t => unit,\n onLostPointerCapture?: JsxEvent.Pointer.t => unit,\n onScroll?: JsxEvent.UI.t => unit,\n onWheel?: JsxEvent.Wheel.t => unit,\n onAbort?: JsxEvent.Media.t => unit,\n onCanPlay?: JsxEvent.Media.t => unit,\n onCanPlayThrough?: JsxEvent.Media.t => unit,\n onDurationChange?: JsxEvent.Media.t => unit,\n onEmptied?: JsxEvent.Media.t => unit,\n onEncrypted?: JsxEvent.Media.t => unit,\n onEnded?: JsxEvent.Media.t => unit,\n onError?: JsxEvent.Media.t => unit,\n onLoadedData?: JsxEvent.Media.t => unit,\n onLoadedMetadata?: JsxEvent.Media.t => unit,\n onLoadStart?: JsxEvent.Media.t => unit,\n onPause?: JsxEvent.Media.t => unit,\n onPlay?: JsxEvent.Media.t => unit,\n onPlaying?: JsxEvent.Media.t => unit,\n onProgress?: JsxEvent.Media.t => unit,\n onRateChange?: JsxEvent.Media.t => unit,\n onSeeked?: JsxEvent.Media.t => unit,\n onSeeking?: JsxEvent.Media.t => unit,\n onStalled?: JsxEvent.Media.t => unit,\n onSuspend?: JsxEvent.Media.t => unit,\n onTimeUpdate?: JsxEvent.Media.t => unit,\n onVolumeChange?: JsxEvent.Media.t => unit,\n onWaiting?: JsxEvent.Media.t => unit,\n onLoad?: JsxEvent.Image.t => unit,\n onAnimationStart?: JsxEvent.Animation.t => unit,\n onAnimationEnd?: JsxEvent.Animation.t => unit,\n onAnimationIteration?: JsxEvent.Animation.t => unit,\n onTransitionEnd?: JsxEvent.Transition.t => unit,\n accentHeight?: string,\n accumulate?: string,\n additive?: string,\n alignmentBaseline?: string,\n allowReorder?: string,\n alphabetic?: string,\n amplitude?: string,\n arabicForm?: string,\n ascent?: string,\n attributeName?: string,\n attributeType?: string,\n autoReverse?: string,\n azimuth?: string,\n baseFrequency?: string,\n baseProfile?: string,\n baselineShift?: string,\n bbox?: string,\n begin?: string,\n begin_?: string,\n bias?: string,\n by?: string,\n calcMode?: string,\n capHeight?: string,\n clip?: string,\n clipPath?: string,\n clipPathUnits?: string,\n clipRule?: string,\n colorInterpolation?: string,\n colorInterpolationFilters?: string,\n colorProfile?: string,\n colorRendering?: string,\n contentScriptType?: string,\n contentStyleType?: string,\n cursor?: string,\n cx?: string,\n cy?: string,\n d?: string,\n decelerate?: string,\n descent?: string,\n diffuseConstant?: string,\n direction?: string,\n display?: string,\n divisor?: string,\n dominantBaseline?: string,\n dur?: string,\n dx?: string,\n dy?: string,\n edgeMode?: string,\n elevation?: string,\n enableBackground?: string,\n end?: string,\n end_?: string,\n exponent?: string,\n externalResourcesRequired?: string,\n fill?: string,\n fillOpacity?: string,\n fillRule?: string,\n filter?: string,\n filterRes?: string,\n filterUnits?: string,\n floodColor?: string,\n floodOpacity?: string,\n focusable?: string,\n fontFamily?: string,\n fontSize?: string,\n fontSizeAdjust?: string,\n fontStretch?: string,\n fontStyle?: string,\n fontVariant?: string,\n fontWeight?: string,\n fomat?: string,\n from?: string,\n fx?: string,\n fy?: string,\n g1?: string,\n g2?: string,\n glyphName?: string,\n glyphOrientationHorizontal?: string,\n glyphOrientationVertical?: string,\n glyphRef?: string,\n gradientTransform?: string,\n gradientUnits?: string,\n hanging?: string,\n horizAdvX?: string,\n horizOriginX?: string,\n ideographic?: string,\n imageRendering?: string,\n in_?: string,\n in2?: string,\n intercept?: string,\n k?: string,\n k1?: string,\n k2?: string,\n k3?: string,\n k4?: string,\n kernelMatrix?: string,\n kernelUnitLength?: string,\n kerning?: string,\n keyPoints?: string,\n keySplines?: string,\n keyTimes?: string,\n lengthAdjust?: string,\n letterSpacing?: string,\n lightingColor?: string,\n limitingConeAngle?: string,\n local?: string,\n markerEnd?: string,\n markerHeight?: string,\n markerMid?: string,\n markerStart?: string,\n markerUnits?: string,\n markerWidth?: string,\n mask?: string,\n maskContentUnits?: string,\n maskUnits?: string,\n mathematical?: string,\n mode?: string,\n numOctaves?: string,\n offset?: string,\n opacity?: string,\n operator?: string,\n order?: string,\n orient?: string,\n orientation?: string,\n origin?: string,\n overflow?: string,\n overflowX?: string,\n overflowY?: string,\n overlinePosition?: string,\n overlineThickness?: string,\n paintOrder?: string,\n panose1?: string,\n pathLength?: string,\n patternContentUnits?: string,\n patternTransform?: string,\n patternUnits?: string,\n pointerEvents?: string,\n points?: string,\n pointsAtX?: string,\n pointsAtY?: string,\n pointsAtZ?: string,\n preserveAlpha?: string,\n preserveAspectRatio?: string,\n primitiveUnits?: string,\n r?: string,\n radius?: string,\n referrerPolicy?: string,\n refX?: string,\n refY?: string,\n renderingIntent?: string,\n repeatCount?: string,\n repeatDur?: string,\n requiredExtensions?: string,\n requiredFeatures?: string,\n restart?: string,\n result?: string,\n rotate?: string,\n rx?: string,\n ry?: string,\n scale?: string,\n seed?: string,\n shapeRendering?: string,\n slope?: string,\n slot?: string,\n spacing?: string,\n specularConstant?: string,\n specularExponent?: string,\n speed?: string,\n spreadMethod?: string,\n startOffset?: string,\n stdDeviation?: string,\n stemh?: string,\n stemv?: string,\n stitchTiles?: string,\n stopColor?: string,\n stopOpacity?: string,\n strikethroughPosition?: string,\n strikethroughThickness?: string,\n string?: string,\n stroke?: string,\n strokeDasharray?: string,\n strokeDashoffset?: string,\n strokeLinecap?: string,\n strokeLinejoin?: string,\n strokeMiterlimit?: string,\n strokeOpacity?: string,\n strokeWidth?: string,\n surfaceScale?: string,\n systemLanguage?: string,\n tableValues?: string,\n targetX?: string,\n targetY?: string,\n textAnchor?: string,\n textDecoration?: string,\n textLength?: string,\n textRendering?: string,\n to?: string,\n to_?: string,\n transform?: string,\n u1?: string,\n u2?: string,\n underlinePosition?: string,\n underlineThickness?: string,\n unicode?: string,\n unicodeBidi?: string,\n unicodeRange?: string,\n unitsPerEm?: string,\n vAlphabetic?: string,\n vHanging?: string,\n vIdeographic?: string,\n vMathematical?: string,\n values?: string,\n vectorEffect?: string,\n version?: string,\n vertAdvX?: string,\n vertAdvY?: string,\n vertOriginX?: string,\n vertOriginY?: string,\n viewBox?: string,\n viewTarget?: string,\n visibility?: string,\n widths?: string,\n wordSpacing?: string,\n writingMode?: string,\n x?: string,\n x1?: string,\n x2?: string,\n xChannelSelector?: string,\n xHeight?: string,\n xlinkActuate?: string,\n xlinkArcrole?: string,\n xlinkHref?: string,\n xlinkRole?: string,\n xlinkShow?: string,\n xlinkTitle?: string,\n xlinkType?: string,\n xmlns?: string,\n xmlnsXlink?: string,\n xmlBase?: string,\n xmlLang?: string,\n xmlSpace?: string,\n y?: string,\n y1?: string,\n y2?: string,\n yChannelSelector?: string,\n z?: string,\n zoomAndPan?: string,\n about?: string,\n datatype?: string,\n inlist?: string,\n prefix?: string,\n property?: string,\n resource?: string,\n typeof?: string,\n vocab?: string,\n dangerouslySetInnerHTML?: {\"__html\": string},\n suppressContentEditableWarning?: bool,\n}\n```\nGo to: [Type definition](JsxDOM.res#L21,1)\n\n\n---\n\n```\n \n```\n```rescript\ntype Jsx.element\n```\nGo to: [Type definition](Jsx.res#L8,1)\n\n\n---\n\n```\n \n```\n```rescript\ntype domRef\n```\nGo to: [Type definition](JsxDOM.res#L8,1)\n\n\n---\n\n```\n \n```\n```rescript\ntype popover =\n | @as(\"auto\") Auto\n | @as(\"manual\") Manual\n | @as(\"hint\") Hint\n```\nGo to: [Type definition](JsxDOM.res#L12,1)\n\n\n---\n\n```\n \n```\n```rescript\ntype popoverTargetAction =\n | @as(\"toggle\") Toggle\n | @as(\"show\") Show\n | @as(\"hide\") Hide\n```\nGo to: [Type definition](JsxDOM.res#L16,1)\n\n\n---\n\n```\n \n```\n```rescript\ntype style = JsxDOMStyle.t\n```\nGo to: [Type definition](JsxDOM.res#L7,1)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Clipboard.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L78,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Composition.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L88,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Keyboard.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L97,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Focus.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L119,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Form.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L129,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Mouse.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L136,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Selection.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L213,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Touch.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L220,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Pointer.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L165,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.UI.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L243,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Wheel.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L254,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Media.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L266,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Image.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L273,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Animation.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L280,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Transition.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L291,3)\n" + "value": "```rescript\nJsxDOM.domProps\n```\n\n---\n\n```\n \n```\n```rescript\ntype JsxDOM.domProps = {\n key?: string,\n children?: Jsx.element,\n ref?: domRef,\n allow?: string,\n ariaCurrent?: [\n | #date\n | #\"false\"\n | #location\n | #page\n | #step\n | #time\n | #\"true\"\n ],\n ariaDetails?: string,\n ariaDisabled?: bool,\n ariaHidden?: bool,\n ariaInvalid?: [#\"false\" | #grammar | #spelling | #\"true\"],\n ariaKeyshortcuts?: string,\n ariaLabel?: string,\n ariaRoledescription?: string,\n ariaAutocomplete?: [#both | #inline | #list | #none],\n ariaChecked?: [#\"false\" | #mixed | #\"true\"],\n ariaExpanded?: bool,\n ariaHaspopup?: [\n | #dialog\n | #\"false\"\n | #grid\n | #listbox\n | #menu\n | #tree\n | #\"true\"\n ],\n ariaLevel?: int,\n ariaModal?: bool,\n ariaMultiline?: bool,\n ariaMultiselectable?: bool,\n ariaOrientation?: [#horizontal | #undefined | #vertical],\n ariaPlaceholder?: string,\n ariaPressed?: [#\"false\" | #mixed | #\"true\"],\n ariaReadonly?: bool,\n ariaRequired?: bool,\n ariaSelected?: bool,\n ariaSort?: string,\n ariaValuemax?: float,\n ariaValuemin?: float,\n ariaValuenow?: float,\n ariaValuetext?: string,\n ariaAtomic?: bool,\n ariaBusy?: bool,\n ariaLive?: [#assertive | #off | #polite | #rude],\n ariaRelevant?: string,\n ariaDropeffect?: [\n | #copy\n | #execute\n | #link\n | #move\n | #none\n | #popup\n ],\n ariaGrabbed?: bool,\n ariaActivedescendant?: string,\n ariaColcount?: int,\n ariaColindex?: int,\n ariaColspan?: int,\n ariaControls?: string,\n ariaDescribedby?: string,\n ariaErrormessage?: string,\n ariaFlowto?: string,\n ariaLabelledby?: string,\n ariaOwns?: string,\n ariaPosinset?: int,\n ariaRowcount?: int,\n ariaRowindex?: int,\n ariaRowspan?: int,\n ariaSetsize?: int,\n defaultChecked?: bool,\n defaultValue?: string,\n accessKey?: string,\n capture?: [#environment | #user],\n className?: string,\n contentEditable?: bool,\n contextMenu?: string,\n dataTestId?: string,\n dir?: string,\n draggable?: bool,\n hidden?: bool,\n id?: string,\n inert?: bool,\n lang?: string,\n popover?: popover,\n popoverTarget?: string,\n popoverTargetAction?: popoverTargetAction,\n role?: string,\n style?: style,\n spellCheck?: bool,\n tabIndex?: int,\n title?: string,\n itemID?: string,\n itemProp?: string,\n itemRef?: string,\n itemScope?: bool,\n itemType?: string,\n accept?: string,\n acceptCharset?: string,\n action?: string,\n allowFullScreen?: bool,\n alt?: string,\n as_?: string,\n async?: bool,\n autoComplete?: string,\n autoCapitalize?: string,\n autoFocus?: bool,\n autoPlay?: bool,\n challenge?: string,\n charSet?: string,\n checked?: bool,\n cite?: string,\n crossOrigin?: string,\n cols?: int,\n colSpan?: int,\n content?: string,\n controls?: bool,\n coords?: string,\n data?: string,\n dateTime?: string,\n default?: bool,\n defer?: bool,\n disabled?: bool,\n download?: string,\n encType?: string,\n form?: string,\n formAction?: string,\n formTarget?: string,\n formMethod?: string,\n frameBorder?: int,\n headers?: string,\n height?: string,\n high?: int,\n href?: string,\n hrefLang?: string,\n htmlFor?: string,\n httpEquiv?: string,\n icon?: string,\n inputMode?: string,\n integrity?: string,\n keyType?: string,\n kind?: string,\n label?: string,\n list?: string,\n loading?: [#eager | #lazy],\n loop?: bool,\n low?: int,\n manifest?: string,\n max?: string,\n maxLength?: int,\n media?: string,\n mediaGroup?: string,\n method?: string,\n min?: string,\n minLength?: int,\n multiple?: bool,\n muted?: bool,\n name?: string,\n nonce?: string,\n noValidate?: bool,\n open_?: bool,\n optimum?: int,\n pattern?: string,\n placeholder?: string,\n playsInline?: bool,\n poster?: string,\n preload?: string,\n radioGroup?: string,\n readOnly?: bool,\n rel?: string,\n required?: bool,\n reversed?: bool,\n rows?: int,\n rowSpan?: int,\n sandbox?: string,\n scope?: string,\n scoped?: bool,\n scrolling?: string,\n selected?: bool,\n shape?: string,\n size?: int,\n sizes?: string,\n span?: int,\n src?: string,\n srcDoc?: string,\n srcLang?: string,\n srcSet?: string,\n start?: int,\n step?: float,\n summary?: string,\n target?: string,\n type_?: string,\n useMap?: string,\n value?: string,\n width?: string,\n wrap?: string,\n onCopy?: JsxEvent.Clipboard.t => unit,\n onCut?: JsxEvent.Clipboard.t => unit,\n onPaste?: JsxEvent.Clipboard.t => unit,\n onCompositionEnd?: JsxEvent.Composition.t => unit,\n onCompositionStart?: JsxEvent.Composition.t => unit,\n onCompositionUpdate?: JsxEvent.Composition.t => unit,\n onKeyDown?: JsxEvent.Keyboard.t => unit,\n onKeyPress?: JsxEvent.Keyboard.t => unit,\n onKeyUp?: JsxEvent.Keyboard.t => unit,\n onFocus?: JsxEvent.Focus.t => unit,\n onBlur?: JsxEvent.Focus.t => unit,\n onBeforeInput?: JsxEvent.Form.t => unit,\n onChange?: JsxEvent.Form.t => unit,\n onInput?: JsxEvent.Form.t => unit,\n onReset?: JsxEvent.Form.t => unit,\n onSubmit?: JsxEvent.Form.t => unit,\n onInvalid?: JsxEvent.Form.t => unit,\n onClick?: JsxEvent.Mouse.t => unit,\n onContextMenu?: JsxEvent.Mouse.t => unit,\n onDoubleClick?: JsxEvent.Mouse.t => unit,\n onDrag?: JsxEvent.Mouse.t => unit,\n onDragEnd?: JsxEvent.Mouse.t => unit,\n onDragEnter?: JsxEvent.Mouse.t => unit,\n onDragExit?: JsxEvent.Mouse.t => unit,\n onDragLeave?: JsxEvent.Mouse.t => unit,\n onDragOver?: JsxEvent.Mouse.t => unit,\n onDragStart?: JsxEvent.Mouse.t => unit,\n onDrop?: JsxEvent.Mouse.t => unit,\n onMouseDown?: JsxEvent.Mouse.t => unit,\n onMouseEnter?: JsxEvent.Mouse.t => unit,\n onMouseLeave?: JsxEvent.Mouse.t => unit,\n onMouseMove?: JsxEvent.Mouse.t => unit,\n onMouseOut?: JsxEvent.Mouse.t => unit,\n onMouseOver?: JsxEvent.Mouse.t => unit,\n onMouseUp?: JsxEvent.Mouse.t => unit,\n onSelect?: JsxEvent.Selection.t => unit,\n onTouchCancel?: JsxEvent.Touch.t => unit,\n onTouchEnd?: JsxEvent.Touch.t => unit,\n onTouchMove?: JsxEvent.Touch.t => unit,\n onTouchStart?: JsxEvent.Touch.t => unit,\n onPointerOver?: JsxEvent.Pointer.t => unit,\n onPointerEnter?: JsxEvent.Pointer.t => unit,\n onPointerDown?: JsxEvent.Pointer.t => unit,\n onPointerMove?: JsxEvent.Pointer.t => unit,\n onPointerUp?: JsxEvent.Pointer.t => unit,\n onPointerCancel?: JsxEvent.Pointer.t => unit,\n onPointerOut?: JsxEvent.Pointer.t => unit,\n onPointerLeave?: JsxEvent.Pointer.t => unit,\n onGotPointerCapture?: JsxEvent.Pointer.t => unit,\n onLostPointerCapture?: JsxEvent.Pointer.t => unit,\n onScroll?: JsxEvent.UI.t => unit,\n onWheel?: JsxEvent.Wheel.t => unit,\n onAbort?: JsxEvent.Media.t => unit,\n onCanPlay?: JsxEvent.Media.t => unit,\n onCanPlayThrough?: JsxEvent.Media.t => unit,\n onDurationChange?: JsxEvent.Media.t => unit,\n onEmptied?: JsxEvent.Media.t => unit,\n onEncrypted?: JsxEvent.Media.t => unit,\n onEnded?: JsxEvent.Media.t => unit,\n onError?: JsxEvent.Media.t => unit,\n onLoadedData?: JsxEvent.Media.t => unit,\n onLoadedMetadata?: JsxEvent.Media.t => unit,\n onLoadStart?: JsxEvent.Media.t => unit,\n onPause?: JsxEvent.Media.t => unit,\n onPlay?: JsxEvent.Media.t => unit,\n onPlaying?: JsxEvent.Media.t => unit,\n onProgress?: JsxEvent.Media.t => unit,\n onRateChange?: JsxEvent.Media.t => unit,\n onSeeked?: JsxEvent.Media.t => unit,\n onSeeking?: JsxEvent.Media.t => unit,\n onStalled?: JsxEvent.Media.t => unit,\n onSuspend?: JsxEvent.Media.t => unit,\n onTimeUpdate?: JsxEvent.Media.t => unit,\n onVolumeChange?: JsxEvent.Media.t => unit,\n onWaiting?: JsxEvent.Media.t => unit,\n onLoad?: JsxEvent.Image.t => unit,\n onAnimationStart?: JsxEvent.Animation.t => unit,\n onAnimationEnd?: JsxEvent.Animation.t => unit,\n onAnimationIteration?: JsxEvent.Animation.t => unit,\n onTransitionEnd?: JsxEvent.Transition.t => unit,\n accentHeight?: string,\n accumulate?: string,\n additive?: string,\n alignmentBaseline?: string,\n allowReorder?: string,\n alphabetic?: string,\n amplitude?: string,\n arabicForm?: string,\n ascent?: string,\n attributeName?: string,\n attributeType?: string,\n autoReverse?: string,\n azimuth?: string,\n baseFrequency?: string,\n baseProfile?: string,\n baselineShift?: string,\n bbox?: string,\n begin?: string,\n bias?: string,\n by?: string,\n calcMode?: string,\n capHeight?: string,\n clip?: string,\n clipPath?: string,\n clipPathUnits?: string,\n clipRule?: string,\n colorInterpolation?: string,\n colorInterpolationFilters?: string,\n colorProfile?: string,\n colorRendering?: string,\n contentScriptType?: string,\n contentStyleType?: string,\n cursor?: string,\n cx?: string,\n cy?: string,\n d?: string,\n decelerate?: string,\n descent?: string,\n diffuseConstant?: string,\n direction?: string,\n display?: string,\n divisor?: string,\n dominantBaseline?: string,\n dur?: string,\n dx?: string,\n dy?: string,\n edgeMode?: string,\n elevation?: string,\n enableBackground?: string,\n end?: string,\n exponent?: string,\n externalResourcesRequired?: string,\n fill?: string,\n fillOpacity?: string,\n fillRule?: string,\n filter?: string,\n filterRes?: string,\n filterUnits?: string,\n floodColor?: string,\n floodOpacity?: string,\n focusable?: string,\n fontFamily?: string,\n fontSize?: string,\n fontSizeAdjust?: string,\n fontStretch?: string,\n fontStyle?: string,\n fontVariant?: string,\n fontWeight?: string,\n fomat?: string,\n from?: string,\n fx?: string,\n fy?: string,\n g1?: string,\n g2?: string,\n glyphName?: string,\n glyphOrientationHorizontal?: string,\n glyphOrientationVertical?: string,\n glyphRef?: string,\n gradientTransform?: string,\n gradientUnits?: string,\n hanging?: string,\n horizAdvX?: string,\n horizOriginX?: string,\n ideographic?: string,\n imageRendering?: string,\n in_?: string,\n in2?: string,\n intercept?: string,\n k?: string,\n k1?: string,\n k2?: string,\n k3?: string,\n k4?: string,\n kernelMatrix?: string,\n kernelUnitLength?: string,\n kerning?: string,\n keyPoints?: string,\n keySplines?: string,\n keyTimes?: string,\n lengthAdjust?: string,\n letterSpacing?: string,\n lightingColor?: string,\n limitingConeAngle?: string,\n local?: string,\n markerEnd?: string,\n markerHeight?: string,\n markerMid?: string,\n markerStart?: string,\n markerUnits?: string,\n markerWidth?: string,\n mask?: string,\n maskContentUnits?: string,\n maskUnits?: string,\n mathematical?: string,\n mode?: string,\n numOctaves?: string,\n offset?: string,\n opacity?: string,\n operator?: string,\n order?: string,\n orient?: string,\n orientation?: string,\n origin?: string,\n overflow?: string,\n overflowX?: string,\n overflowY?: string,\n overlinePosition?: string,\n overlineThickness?: string,\n paintOrder?: string,\n panose1?: string,\n pathLength?: string,\n patternContentUnits?: string,\n patternTransform?: string,\n patternUnits?: string,\n pointerEvents?: string,\n points?: string,\n pointsAtX?: string,\n pointsAtY?: string,\n pointsAtZ?: string,\n preserveAlpha?: string,\n preserveAspectRatio?: string,\n primitiveUnits?: string,\n r?: string,\n radius?: string,\n referrerPolicy?: string,\n refX?: string,\n refY?: string,\n renderingIntent?: string,\n repeatCount?: string,\n repeatDur?: string,\n requiredExtensions?: string,\n requiredFeatures?: string,\n restart?: string,\n result?: string,\n rotate?: string,\n rx?: string,\n ry?: string,\n scale?: string,\n seed?: string,\n shapeRendering?: string,\n slope?: string,\n slot?: string,\n spacing?: string,\n specularConstant?: string,\n specularExponent?: string,\n speed?: string,\n spreadMethod?: string,\n startOffset?: string,\n stdDeviation?: string,\n stemh?: string,\n stemv?: string,\n stitchTiles?: string,\n stopColor?: string,\n stopOpacity?: string,\n strikethroughPosition?: string,\n strikethroughThickness?: string,\n string?: string,\n stroke?: string,\n strokeDasharray?: string,\n strokeDashoffset?: string,\n strokeLinecap?: string,\n strokeLinejoin?: string,\n strokeMiterlimit?: string,\n strokeOpacity?: string,\n strokeWidth?: string,\n surfaceScale?: string,\n systemLanguage?: string,\n tableValues?: string,\n targetX?: string,\n targetY?: string,\n textAnchor?: string,\n textDecoration?: string,\n textLength?: string,\n textRendering?: string,\n to?: string,\n transform?: string,\n u1?: string,\n u2?: string,\n underlinePosition?: string,\n underlineThickness?: string,\n unicode?: string,\n unicodeBidi?: string,\n unicodeRange?: string,\n unitsPerEm?: string,\n vAlphabetic?: string,\n vHanging?: string,\n vIdeographic?: string,\n vMathematical?: string,\n values?: string,\n vectorEffect?: string,\n version?: string,\n vertAdvX?: string,\n vertAdvY?: string,\n vertOriginX?: string,\n vertOriginY?: string,\n viewBox?: string,\n viewTarget?: string,\n visibility?: string,\n widths?: string,\n wordSpacing?: string,\n writingMode?: string,\n x?: string,\n x1?: string,\n x2?: string,\n xChannelSelector?: string,\n xHeight?: string,\n xlinkActuate?: string,\n xlinkArcrole?: string,\n xlinkHref?: string,\n xlinkRole?: string,\n xlinkShow?: string,\n xlinkTitle?: string,\n xlinkType?: string,\n xmlns?: string,\n xmlnsXlink?: string,\n xmlBase?: string,\n xmlLang?: string,\n xmlSpace?: string,\n y?: string,\n y1?: string,\n y2?: string,\n yChannelSelector?: string,\n z?: string,\n zoomAndPan?: string,\n about?: string,\n datatype?: string,\n inlist?: string,\n prefix?: string,\n property?: string,\n resource?: string,\n typeof?: string,\n vocab?: string,\n dangerouslySetInnerHTML?: {\"__html\": string},\n suppressContentEditableWarning?: bool,\n}\n```\nGo to: [Type definition](JsxDOM.res#L21,1)\n\n\n---\n\n```\n \n```\n```rescript\ntype Jsx.element\n```\nGo to: [Type definition](Jsx.res#L8,1)\n\n\n---\n\n```\n \n```\n```rescript\ntype domRef\n```\nGo to: [Type definition](JsxDOM.res#L8,1)\n\n\n---\n\n```\n \n```\n```rescript\ntype popover =\n | @as(\"auto\") Auto\n | @as(\"manual\") Manual\n | @as(\"hint\") Hint\n```\nGo to: [Type definition](JsxDOM.res#L12,1)\n\n\n---\n\n```\n \n```\n```rescript\ntype popoverTargetAction =\n | @as(\"toggle\") Toggle\n | @as(\"show\") Show\n | @as(\"hide\") Hide\n```\nGo to: [Type definition](JsxDOM.res#L16,1)\n\n\n---\n\n```\n \n```\n```rescript\ntype style = JsxDOMStyle.t\n```\nGo to: [Type definition](JsxDOM.res#L7,1)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Clipboard.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L78,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Composition.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L88,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Keyboard.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L97,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Focus.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L119,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Form.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L129,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Mouse.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L136,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Selection.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L213,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Touch.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L220,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Pointer.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L165,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.UI.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L243,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Wheel.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L254,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Media.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L266,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Image.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L273,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Animation.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L280,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Transition.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L291,3)\n" } } @@ -2865,50 +2766,6 @@ ContextPath int Path Stdlib.Int.t Path t [ - { - "deprecated": true, - "detail": "(int, ~radix: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toString` instead\n\n\n`toStringWithRadix(n, ~radix)` return a `string` representing the given value.\n`~radix` specifies the radix base to use for the formatted number.\nSee [`Number.toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString)\non MDN.\n\n## Examples\n\n```rescript\nInt.toStringWithRadix(6, ~radix=2) // \"110\"\nInt.toStringWithRadix(373592855, ~radix=16) // \"16449317\"\nInt.toStringWithRadix(123456, ~radix=36) // \"2n9c\"\n```\n\n## Exceptions\n\n`RangeError`: if `radix` is less than 2 or greater than 36.\n" - }, - "kind": 12, - "label": "Int.toStringWithRadix", - "tags": [ 1 ] - }, - { - "deprecated": true, - "detail": "(int, ~digits: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toExponential` instead\n\n\n`toExponential(n, ~digits)` return a `string` representing the given value in\nexponential notation. `digits` specifies how many digits should appear after\nthe decimal point. See [`Number.toExponential`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential)\non MDN.\n\n## Examples\n\n```rescript\nInt.toExponentialWithPrecision(77, ~digits=2) // \"7.70e+1\"\nInt.toExponentialWithPrecision(5678, ~digits=2) // \"5.68e+3\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` less than 0 or greater than 10.\n" - }, - "kind": 12, - "label": "Int.toExponentialWithPrecision", - "tags": [ 1 ] - }, - { - "deprecated": true, - "detail": "(int, ~digits: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toFixed` instead\n\n\n`toFixedWithPrecision(n, ~digits)` return a `string` representing the given\nvalue using fixed-point notation. `digits` specifies how many digits should\nappear after the decimal point. See [`Number.toFixed`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed)\non MDN.\n\n## Examples\n\n```rescript\nInt.toFixedWithPrecision(300, ~digits=4) // \"300.0000\"\nInt.toFixedWithPrecision(300, ~digits=1) // \"300.0\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` is less than 0 or larger than 100.\n" - }, - "kind": 12, - "label": "Int.toFixedWithPrecision", - "tags": [ 1 ] - }, - { - "deprecated": true, - "detail": "(int, ~digits: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toPrecision` instead\n\n\n`toPrecisionWithPrecision(n, ~digits)` return a `string` representing the giver value with\nprecision. `digits` specifies the number of significant digits. See [`Number.toPrecision`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision) on MDN.\n\n## Examples\n\n```rescript\nInt.toPrecisionWithPrecision(100, ~digits=2) // \"1.0e+2\"\nInt.toPrecisionWithPrecision(1, ~digits=2) // \"1.0\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` is not between 1 and 100 (inclusive).\n Implementations are allowed to support larger and smaller values as well.\n ECMA-262 only requires a precision of up to 21 significant digits.\n" - }, - "kind": 12, - "label": "Int.toPrecisionWithPrecision", - "tags": [ 1 ] - }, { "detail": "(int, ~digits: int=?) => string", "documentation": { @@ -2982,28 +2839,6 @@ ContextPath float Path Stdlib.Float.t Path t [ - { - "deprecated": true, - "detail": "(float, ~radix: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toString` with `~radix` instead\n\n\n`toStringWithRadix(v, ~radix)` return a `string` representing the given value.\n`~radix` specifies the radix base to use for the formatted number.\nSee [`Number.toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString) on MDN.\n\n## Examples\n\n```rescript\nFloat.toStringWithRadix(6.0, ~radix=2) == \"110\"\nFloat.toStringWithRadix(3735928559.0, ~radix=16) == \"deadbeef\"\nFloat.toStringWithRadix(123456.0, ~radix=36) == \"2n9c\"\n```\n\n## Exceptions\n\n`RangeError`: if `radix` is less than 2 or greater than 36.\n" - }, - "kind": 12, - "label": "Float.toStringWithRadix", - "tags": [ 1 ] - }, - { - "deprecated": true, - "detail": "(float, ~digits: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toExponential` instead\n\n\n`toExponential(v, ~digits)` return a `string` representing the given value in\nexponential notation. `digits` specifies how many digits should appear after\nthe decimal point.\nSee [`Number.toExponential`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential) on MDN.\n\n## Examples\n\n```rescript\nFloat.toExponentialWithPrecision(77.0, ~digits=2) == \"7.70e+1\"\nFloat.toExponentialWithPrecision(5678.0, ~digits=2) == \"5.68e+3\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` less than 0 or greater than 10.\n" - }, - "kind": 12, - "label": "Float.toExponentialWithPrecision", - "tags": [ 1 ] - }, { "detail": "float => int", "documentation": { @@ -3014,28 +2849,6 @@ Path t "label": "Float.toInt", "tags": [] }, - { - "deprecated": true, - "detail": "(float, ~digits: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toFixed` instead\n\n\n`toFixedWithPrecision(v, ~digits)` return a `string` representing the given\nvalue using fixed-point notation. `digits` specifies how many digits should\nappear after the decimal point.\nSee [`Number.toFixed`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed) on MDN.\n\n## Examples\n\n```rescript\nFloat.toFixedWithPrecision(300.0, ~digits=4) == \"300.0000\"\nFloat.toFixedWithPrecision(300.0, ~digits=1) == \"300.0\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` is less than 0 or larger than 100.\n" - }, - "kind": 12, - "label": "Float.toFixedWithPrecision", - "tags": [ 1 ] - }, - { - "deprecated": true, - "detail": "(float, ~digits: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toPrecision` instead\n\n\n`toPrecisionWithPrecision(v, ~digits)` return a `string` representing the giver value with\nprecision. `digits` specifies the number of significant digits.\nSee [`Number.toPrecision`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision) on MDN.\n\n## Examples\n\n```rescript\nFloat.toPrecisionWithPrecision(100.0, ~digits=2) == \"1.0e+2\"\nFloat.toPrecisionWithPrecision(1.0, ~digits=1) == \"1\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` is not between 1 and 100 (inclusive).\n Implementations are allowed to support larger and smaller values as well.\n ECMA-262 only requires a precision of up to 21 significant digits.\n \n" - }, - "kind": 12, - "label": "Float.toPrecisionWithPrecision", - "tags": [ 1 ] - }, { "detail": "(float, ~digits: int=?) => string", "documentation": { @@ -3100,17 +2913,6 @@ Path ok Path Stdlib.Result.g Path g [ - { - "deprecated": true, - "detail": "(result<'a, 'b>, ~message: string=?) => 'a", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use 'getOrThrow' instead\n\n\n `getExn(res, ~message=?)` returns `n` if `res` is `Ok(n)`, otherwise throws an exception with the message provided, or a generic message if no message was provided.\n\n ```res example\n Result.getExn(Result.Ok(42)) == 42\n \n switch Result.getExn(Error(\"Invalid data\")) {\n | exception _ => true\n | _ => false\n } == true\n\n switch Result.getExn(Error(\"Invalid data\"), ~message=\"was Error!\") {\n | exception _ => true // Throws a JsError with the message \"was Error!\"\n | _ => false\n } == true\n ```\n" - }, - "kind": 12, - "label": "Result.getExn", - "tags": [ 1 ] - }, { "detail": "(result<'a, 'b>, ~message: string=?) => 'a", "documentation": { @@ -3130,17 +2932,6 @@ Path g "kind": 12, "label": "Result.getOr", "tags": [] - }, - { - "deprecated": true, - "detail": "(result<'a, 'b>, 'a) => 'a", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use getOr instead\n\n" - }, - "kind": 12, - "label": "Result.getWithDefault", - "tags": [ 1 ] } ] @@ -3247,17 +3038,6 @@ Path uncurried Path Stdlib.Int.toS Path toS [ - { - "deprecated": true, - "detail": "(int, ~radix: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toString` instead\n\n\n`toStringWithRadix(n, ~radix)` return a `string` representing the given value.\n`~radix` specifies the radix base to use for the formatted number.\nSee [`Number.toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString)\non MDN.\n\n## Examples\n\n```rescript\nInt.toStringWithRadix(6, ~radix=2) // \"110\"\nInt.toStringWithRadix(373592855, ~radix=16) // \"16449317\"\nInt.toStringWithRadix(123456, ~radix=36) // \"2n9c\"\n```\n\n## Exceptions\n\n`RangeError`: if `radix` is less than 2 or greater than 36.\n" - }, - "kind": 12, - "label": "Int.toStringWithRadix", - "tags": [ 1 ] - }, { "detail": "(int, ~radix: int=?) => string", "documentation": { diff --git a/tests/analysis_tests/tests/src/expected/CompletionChar.res.txt b/tests/analysis_tests/tests/src/expected/CompletionChar.res.txt index 94b273aa561..f04f52e9ad3 100644 --- a/tests/analysis_tests/tests/src/expected/CompletionChar.res.txt +++ b/tests/analysis_tests/tests/src/expected/CompletionChar.res.txt @@ -9,17 +9,6 @@ Path c Path Stdlib.Int.toS Path toS [ - { - "deprecated": true, - "detail": "(int, ~radix: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toString` instead\n\n\n`toStringWithRadix(n, ~radix)` return a `string` representing the given value.\n`~radix` specifies the radix base to use for the formatted number.\nSee [`Number.toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString)\non MDN.\n\n## Examples\n\n```rescript\nInt.toStringWithRadix(6, ~radix=2) // \"110\"\nInt.toStringWithRadix(373592855, ~radix=16) // \"16449317\"\nInt.toStringWithRadix(123456, ~radix=36) // \"2n9c\"\n```\n\n## Exceptions\n\n`RangeError`: if `radix` is less than 2 or greater than 36.\n" - }, - "kind": 12, - "label": "Int.toStringWithRadix", - "tags": [ 1 ] - }, { "detail": "(int, ~radix: int=?) => string", "documentation": { diff --git a/tests/analysis_tests/tests/src/expected/CompletionDictPattern.res.txt b/tests/analysis_tests/tests/src/expected/CompletionDictPattern.res.txt index 475705d69fc..19b28691d92 100644 --- a/tests/analysis_tests/tests/src/expected/CompletionDictPattern.res.txt +++ b/tests/analysis_tests/tests/src/expected/CompletionDictPattern.res.txt @@ -351,17 +351,6 @@ Path "label": "Option.map", "tags": [] }, - { - "deprecated": true, - "detail": "(option<'a>, ~message: string=?) => 'a", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `getOrThrow` instead\n\n\n`getExn(opt, ~message=?)` returns `value` if `opt` is `Some(value)`, otherwise throws an exception with the message provided, or a generic message if no message was provided.\n\n```rescript\nOption.getExn(Some(3)) == 3\n\nswitch Option.getExn(None) {\n| exception _ => assert(true)\n| _ => assert(false)\n}\n\nswitch Option.getExn(None, ~message=\"was None!\") {\n| exception _ => assert(true) // Throws a JsError with the message \"was None!\"\n| _ => assert(false)\n}\n```\n\n## Exceptions\n\n- Throws an error if `opt` is `None`\n" - }, - "kind": 12, - "label": "Option.getExn", - "tags": [ 1 ] - }, { "detail": "(\n option<'a>,\n option<'b>,\n ('a, 'b) => Ordering.t,\n) => Ordering.t", "documentation": { @@ -412,17 +401,6 @@ Path "label": "Option.mapOr", "tags": [] }, - { - "deprecated": true, - "detail": "(option<'a>, 'b, 'a => 'b) => 'b", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use mapOr instead\n\n" - }, - "kind": 12, - "label": "Option.mapWithDefault", - "tags": [ 1 ] - }, { "detail": "option<'a> => bool", "documentation": { @@ -433,17 +411,6 @@ Path "label": "Option.isSome", "tags": [] }, - { - "deprecated": true, - "detail": "(option<'a>, 'a) => 'a", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use getOr instead\n\n" - }, - "kind": 12, - "label": "Option.getWithDefault", - "tags": [ 1 ] - }, { "detail": "(option<'a>, 'a => unit) => unit", "documentation": { diff --git a/tests/analysis_tests/tests/src/expected/CompletionExpressions.res.txt b/tests/analysis_tests/tests/src/expected/CompletionExpressions.res.txt index 830ad20f315..9b5fe8d428b 100644 --- a/tests/analysis_tests/tests/src/expected/CompletionExpressions.res.txt +++ b/tests/analysis_tests/tests/src/expected/CompletionExpressions.res.txt @@ -948,7 +948,7 @@ Path fnTakingCallback "detail": "('a, 'a) => unit", "documentation": { "kind": "markdown", - "value": "\n`assertEqual(a, b)` check if `a` is equal `b`. If not throw a panic exception\n\n## Examples\n\n```rescript\nlist{1, 2}->List.tailExn == list{2}\n```\n" + "value": "\n`assertEqual(a, b)` check if `a` is equal `b`. If not throw a panic exception\n\n## Examples\n\n```rescript\nlist{1, 2}->List.tailOrThrow == list{2}\n```\n" }, "kind": 12, "label": "assertEqual", @@ -1617,14 +1617,6 @@ Path mkStuff "kind": 12, "label": "RegExp.fromString()", "tags": [] - }, - { - "detail": "(string, ~flags: string) => t", - "insertText": "RegExp.fromStringWithFlags($0)", - "insertTextFormat": 2, - "kind": 12, - "label": "RegExp.fromStringWithFlags()", - "tags": [] } ] diff --git a/tests/analysis_tests/tests/src/expected/CompletionInferValues.res.txt b/tests/analysis_tests/tests/src/expected/CompletionInferValues.res.txt index d069d546eff..2ac81fb6b5d 100644 --- a/tests/analysis_tests/tests/src/expected/CompletionInferValues.res.txt +++ b/tests/analysis_tests/tests/src/expected/CompletionInferValues.res.txt @@ -12,50 +12,6 @@ ContextPath int Path Stdlib.Int.t Path t [ - { - "deprecated": true, - "detail": "(int, ~radix: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toString` instead\n\n\n`toStringWithRadix(n, ~radix)` return a `string` representing the given value.\n`~radix` specifies the radix base to use for the formatted number.\nSee [`Number.toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString)\non MDN.\n\n## Examples\n\n```rescript\nInt.toStringWithRadix(6, ~radix=2) // \"110\"\nInt.toStringWithRadix(373592855, ~radix=16) // \"16449317\"\nInt.toStringWithRadix(123456, ~radix=36) // \"2n9c\"\n```\n\n## Exceptions\n\n`RangeError`: if `radix` is less than 2 or greater than 36.\n" - }, - "kind": 12, - "label": "Int.toStringWithRadix", - "tags": [ 1 ] - }, - { - "deprecated": true, - "detail": "(int, ~digits: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toExponential` instead\n\n\n`toExponential(n, ~digits)` return a `string` representing the given value in\nexponential notation. `digits` specifies how many digits should appear after\nthe decimal point. See [`Number.toExponential`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential)\non MDN.\n\n## Examples\n\n```rescript\nInt.toExponentialWithPrecision(77, ~digits=2) // \"7.70e+1\"\nInt.toExponentialWithPrecision(5678, ~digits=2) // \"5.68e+3\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` less than 0 or greater than 10.\n" - }, - "kind": 12, - "label": "Int.toExponentialWithPrecision", - "tags": [ 1 ] - }, - { - "deprecated": true, - "detail": "(int, ~digits: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toFixed` instead\n\n\n`toFixedWithPrecision(n, ~digits)` return a `string` representing the given\nvalue using fixed-point notation. `digits` specifies how many digits should\nappear after the decimal point. See [`Number.toFixed`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed)\non MDN.\n\n## Examples\n\n```rescript\nInt.toFixedWithPrecision(300, ~digits=4) // \"300.0000\"\nInt.toFixedWithPrecision(300, ~digits=1) // \"300.0\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` is less than 0 or larger than 100.\n" - }, - "kind": 12, - "label": "Int.toFixedWithPrecision", - "tags": [ 1 ] - }, - { - "deprecated": true, - "detail": "(int, ~digits: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toPrecision` instead\n\n\n`toPrecisionWithPrecision(n, ~digits)` return a `string` representing the giver value with\nprecision. `digits` specifies the number of significant digits. See [`Number.toPrecision`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision) on MDN.\n\n## Examples\n\n```rescript\nInt.toPrecisionWithPrecision(100, ~digits=2) // \"1.0e+2\"\nInt.toPrecisionWithPrecision(1, ~digits=2) // \"1.0\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` is not between 1 and 100 (inclusive).\n Implementations are allowed to support larger and smaller values as well.\n ECMA-262 only requires a precision of up to 21 significant digits.\n" - }, - "kind": 12, - "label": "Int.toPrecisionWithPrecision", - "tags": [ 1 ] - }, { "detail": "(int, ~digits: int=?) => string", "documentation": { @@ -410,50 +366,6 @@ Path JsxEvent.Mouse.button Path Stdlib.Int.t Path t [ - { - "deprecated": true, - "detail": "(int, ~radix: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toString` instead\n\n\n`toStringWithRadix(n, ~radix)` return a `string` representing the given value.\n`~radix` specifies the radix base to use for the formatted number.\nSee [`Number.toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString)\non MDN.\n\n## Examples\n\n```rescript\nInt.toStringWithRadix(6, ~radix=2) // \"110\"\nInt.toStringWithRadix(373592855, ~radix=16) // \"16449317\"\nInt.toStringWithRadix(123456, ~radix=36) // \"2n9c\"\n```\n\n## Exceptions\n\n`RangeError`: if `radix` is less than 2 or greater than 36.\n" - }, - "kind": 12, - "label": "Int.toStringWithRadix", - "tags": [ 1 ] - }, - { - "deprecated": true, - "detail": "(int, ~digits: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toExponential` instead\n\n\n`toExponential(n, ~digits)` return a `string` representing the given value in\nexponential notation. `digits` specifies how many digits should appear after\nthe decimal point. See [`Number.toExponential`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential)\non MDN.\n\n## Examples\n\n```rescript\nInt.toExponentialWithPrecision(77, ~digits=2) // \"7.70e+1\"\nInt.toExponentialWithPrecision(5678, ~digits=2) // \"5.68e+3\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` less than 0 or greater than 10.\n" - }, - "kind": 12, - "label": "Int.toExponentialWithPrecision", - "tags": [ 1 ] - }, - { - "deprecated": true, - "detail": "(int, ~digits: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toFixed` instead\n\n\n`toFixedWithPrecision(n, ~digits)` return a `string` representing the given\nvalue using fixed-point notation. `digits` specifies how many digits should\nappear after the decimal point. See [`Number.toFixed`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed)\non MDN.\n\n## Examples\n\n```rescript\nInt.toFixedWithPrecision(300, ~digits=4) // \"300.0000\"\nInt.toFixedWithPrecision(300, ~digits=1) // \"300.0\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` is less than 0 or larger than 100.\n" - }, - "kind": 12, - "label": "Int.toFixedWithPrecision", - "tags": [ 1 ] - }, - { - "deprecated": true, - "detail": "(int, ~digits: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toPrecision` instead\n\n\n`toPrecisionWithPrecision(n, ~digits)` return a `string` representing the giver value with\nprecision. `digits` specifies the number of significant digits. See [`Number.toPrecision`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision) on MDN.\n\n## Examples\n\n```rescript\nInt.toPrecisionWithPrecision(100, ~digits=2) // \"1.0e+2\"\nInt.toPrecisionWithPrecision(1, ~digits=2) // \"1.0\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` is not between 1 and 100 (inclusive).\n Implementations are allowed to support larger and smaller values as well.\n ECMA-262 only requires a precision of up to 21 significant digits.\n" - }, - "kind": 12, - "label": "Int.toPrecisionWithPrecision", - "tags": [ 1 ] - }, { "detail": "(int, ~digits: int=?) => string", "documentation": { @@ -733,17 +645,6 @@ Path slic "kind": 12, "label": "String.slice", "tags": [] - }, - { - "deprecated": true, - "detail": "(string, ~start: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `slice` instead\n\n\n`sliceToEnd(str, ~start)` returns the substring of `str` starting at character\n`start` to the end of the string.\n- If `start` is negative, then it is evaluated as `length(str - start)`.\n- If `start` is greater than the length of `str`, then sliceToEnd returns the empty string.\n See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nString.sliceToEnd(\"abcdefg\", ~start=4) == \"efg\"\nString.sliceToEnd(\"abcdefg\", ~start=-2) == \"fg\"\nString.sliceToEnd(\"abcdefg\", ~start=7) == \"\"\n```\n" - }, - "kind": 12, - "label": "String.sliceToEnd", - "tags": [ 1 ] } ] @@ -763,17 +664,6 @@ Path someRecordWithNestedStuff Path Stdlib.Int.toS Path toS [ - { - "deprecated": true, - "detail": "(int, ~radix: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toString` instead\n\n\n`toStringWithRadix(n, ~radix)` return a `string` representing the given value.\n`~radix` specifies the radix base to use for the formatted number.\nSee [`Number.toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString)\non MDN.\n\n## Examples\n\n```rescript\nInt.toStringWithRadix(6, ~radix=2) // \"110\"\nInt.toStringWithRadix(373592855, ~radix=16) // \"16449317\"\nInt.toStringWithRadix(123456, ~radix=36) // \"2n9c\"\n```\n\n## Exceptions\n\n`RangeError`: if `radix` is less than 2 or greater than 36.\n" - }, - "kind": 12, - "label": "Int.toStringWithRadix", - "tags": [ 1 ] - }, { "detail": "(int, ~radix: int=?) => string", "documentation": { @@ -805,17 +695,6 @@ Path otherNestedRecord Path Stdlib.Int.toS Path toS [ - { - "deprecated": true, - "detail": "(int, ~radix: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toString` instead\n\n\n`toStringWithRadix(n, ~radix)` return a `string` representing the given value.\n`~radix` specifies the radix base to use for the formatted number.\nSee [`Number.toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString)\non MDN.\n\n## Examples\n\n```rescript\nInt.toStringWithRadix(6, ~radix=2) // \"110\"\nInt.toStringWithRadix(373592855, ~radix=16) // \"16449317\"\nInt.toStringWithRadix(123456, ~radix=36) // \"2n9c\"\n```\n\n## Exceptions\n\n`RangeError`: if `radix` is less than 2 or greater than 36.\n" - }, - "kind": 12, - "label": "Int.toStringWithRadix", - "tags": [ 1 ] - }, { "detail": "(int, ~radix: int=?) => string", "documentation": { @@ -848,17 +727,6 @@ Path otherNestedRecord Path Stdlib.Int.toS Path toS [ - { - "deprecated": true, - "detail": "(int, ~radix: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toString` instead\n\n\n`toStringWithRadix(n, ~radix)` return a `string` representing the given value.\n`~radix` specifies the radix base to use for the formatted number.\nSee [`Number.toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString)\non MDN.\n\n## Examples\n\n```rescript\nInt.toStringWithRadix(6, ~radix=2) // \"110\"\nInt.toStringWithRadix(373592855, ~radix=16) // \"16449317\"\nInt.toStringWithRadix(123456, ~radix=36) // \"2n9c\"\n```\n\n## Exceptions\n\n`RangeError`: if `radix` is less than 2 or greater than 36.\n" - }, - "kind": 12, - "label": "Int.toStringWithRadix", - "tags": [ 1 ] - }, { "detail": "(int, ~radix: int=?) => string", "documentation": { @@ -896,17 +764,6 @@ Path slic "kind": 12, "label": "String.slice", "tags": [] - }, - { - "deprecated": true, - "detail": "(string, ~start: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `slice` instead\n\n\n`sliceToEnd(str, ~start)` returns the substring of `str` starting at character\n`start` to the end of the string.\n- If `start` is negative, then it is evaluated as `length(str - start)`.\n- If `start` is greater than the length of `str`, then sliceToEnd returns the empty string.\n See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nString.sliceToEnd(\"abcdefg\", ~start=4) == \"efg\"\nString.sliceToEnd(\"abcdefg\", ~start=-2) == \"fg\"\nString.sliceToEnd(\"abcdefg\", ~start=7) == \"\"\n```\n" - }, - "kind": 12, - "label": "String.sliceToEnd", - "tags": [ 1 ] } ] @@ -935,17 +792,6 @@ Path slic "kind": 12, "label": "String.slice", "tags": [] - }, - { - "deprecated": true, - "detail": "(string, ~start: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `slice` instead\n\n\n`sliceToEnd(str, ~start)` returns the substring of `str` starting at character\n`start` to the end of the string.\n- If `start` is negative, then it is evaluated as `length(str - start)`.\n- If `start` is greater than the length of `str`, then sliceToEnd returns the empty string.\n See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nString.sliceToEnd(\"abcdefg\", ~start=4) == \"efg\"\nString.sliceToEnd(\"abcdefg\", ~start=-2) == \"fg\"\nString.sliceToEnd(\"abcdefg\", ~start=7) == \"\"\n```\n" - }, - "kind": 12, - "label": "String.sliceToEnd", - "tags": [ 1 ] } ] @@ -974,17 +820,6 @@ Path slic "kind": 12, "label": "String.slice", "tags": [] - }, - { - "deprecated": true, - "detail": "(string, ~start: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `slice` instead\n\n\n`sliceToEnd(str, ~start)` returns the substring of `str` starting at character\n`start` to the end of the string.\n- If `start` is negative, then it is evaluated as `length(str - start)`.\n- If `start` is greater than the length of `str`, then sliceToEnd returns the empty string.\n See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nString.sliceToEnd(\"abcdefg\", ~start=4) == \"efg\"\nString.sliceToEnd(\"abcdefg\", ~start=-2) == \"fg\"\nString.sliceToEnd(\"abcdefg\", ~start=7) == \"\"\n```\n" - }, - "kind": 12, - "label": "String.sliceToEnd", - "tags": [ 1 ] } ] @@ -1002,17 +837,6 @@ ContextPath int Path Stdlib.Int.toSt Path toSt [ - { - "deprecated": true, - "detail": "(int, ~radix: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toString` instead\n\n\n`toStringWithRadix(n, ~radix)` return a `string` representing the given value.\n`~radix` specifies the radix base to use for the formatted number.\nSee [`Number.toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString)\non MDN.\n\n## Examples\n\n```rescript\nInt.toStringWithRadix(6, ~radix=2) // \"110\"\nInt.toStringWithRadix(373592855, ~radix=16) // \"16449317\"\nInt.toStringWithRadix(123456, ~radix=36) // \"2n9c\"\n```\n\n## Exceptions\n\n`RangeError`: if `radix` is less than 2 or greater than 36.\n" - }, - "kind": 12, - "label": "Int.toStringWithRadix", - "tags": [ 1 ] - }, { "detail": "(int, ~radix: int=?) => string", "documentation": { diff --git a/tests/analysis_tests/tests/src/expected/CompletionJsx.res.txt b/tests/analysis_tests/tests/src/expected/CompletionJsx.res.txt index cebc9ea5539..aa2a9f29ad4 100644 --- a/tests/analysis_tests/tests/src/expected/CompletionJsx.res.txt +++ b/tests/analysis_tests/tests/src/expected/CompletionJsx.res.txt @@ -274,28 +274,6 @@ Path "label": "Int.equal", "tags": [] }, - { - "deprecated": true, - "detail": "(int, ~radix: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toString` instead\n\n\n`toStringWithRadix(n, ~radix)` return a `string` representing the given value.\n`~radix` specifies the radix base to use for the formatted number.\nSee [`Number.toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString)\non MDN.\n\n## Examples\n\n```rescript\nInt.toStringWithRadix(6, ~radix=2) // \"110\"\nInt.toStringWithRadix(373592855, ~radix=16) // \"16449317\"\nInt.toStringWithRadix(123456, ~radix=36) // \"2n9c\"\n```\n\n## Exceptions\n\n`RangeError`: if `radix` is less than 2 or greater than 36.\n" - }, - "kind": 12, - "label": "Int.toStringWithRadix", - "tags": [ 1 ] - }, - { - "deprecated": true, - "detail": "(int, ~digits: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toExponential` instead\n\n\n`toExponential(n, ~digits)` return a `string` representing the given value in\nexponential notation. `digits` specifies how many digits should appear after\nthe decimal point. See [`Number.toExponential`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential)\non MDN.\n\n## Examples\n\n```rescript\nInt.toExponentialWithPrecision(77, ~digits=2) // \"7.70e+1\"\nInt.toExponentialWithPrecision(5678, ~digits=2) // \"5.68e+3\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` less than 0 or greater than 10.\n" - }, - "kind": 12, - "label": "Int.toExponentialWithPrecision", - "tags": [ 1 ] - }, { "detail": "(int, int) => int", "documentation": { @@ -316,28 +294,6 @@ Path "label": "Int.clamp", "tags": [] }, - { - "deprecated": true, - "detail": "(int, ~digits: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toFixed` instead\n\n\n`toFixedWithPrecision(n, ~digits)` return a `string` representing the given\nvalue using fixed-point notation. `digits` specifies how many digits should\nappear after the decimal point. See [`Number.toFixed`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed)\non MDN.\n\n## Examples\n\n```rescript\nInt.toFixedWithPrecision(300, ~digits=4) // \"300.0000\"\nInt.toFixedWithPrecision(300, ~digits=1) // \"300.0\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` is less than 0 or larger than 100.\n" - }, - "kind": 12, - "label": "Int.toFixedWithPrecision", - "tags": [ 1 ] - }, - { - "deprecated": true, - "detail": "(int, ~digits: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toPrecision` instead\n\n\n`toPrecisionWithPrecision(n, ~digits)` return a `string` representing the giver value with\nprecision. `digits` specifies the number of significant digits. See [`Number.toPrecision`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision) on MDN.\n\n## Examples\n\n```rescript\nInt.toPrecisionWithPrecision(100, ~digits=2) // \"1.0e+2\"\nInt.toPrecisionWithPrecision(1, ~digits=2) // \"1.0\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` is not between 1 and 100 (inclusive).\n Implementations are allowed to support larger and smaller values as well.\n ECMA-262 only requires a precision of up to 21 significant digits.\n" - }, - "kind": 12, - "label": "Int.toPrecisionWithPrecision", - "tags": [ 1 ] - }, { "detail": "(int, int) => int", "documentation": { @@ -444,17 +400,6 @@ Path "label": "Int.mod", "tags": [] }, - { - "deprecated": true, - "detail": "(int, int, rangeOptions) => array", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `range` instead\n\n\n`rangeWithOptions(start, end, options)` is like `range`, but with `step` and\n`inclusive` options configurable.\n\nIf `step` is set, the sequence will increase or decrease by that amount for each\nstep. If `start < end` and `step` is negative, or vice versa, an empty array is\nreturned since the sequence would otherwise never reach or exceed the end value\nand hence be infinite. If `step` is `0` and `start !=` end, a `RangeError` is\nraised as the sequence would never reach or exceed the end value and hence be\ninfinite.\n\nIf `inclusive` is set to `true`, the sequence will include `end` if `step` is\nset such that the sequence includes it.\n\n## Examples\n\n```rescript\nInt.rangeWithOptions(3, 7, {step: 2}) == [3, 5]\nInt.rangeWithOptions(3, 7, {step: 2, inclusive: true}) == [3, 5, 7]\nInt.rangeWithOptions(3, 6, {step: -2}) // RangeError\n```\n\n## Exceptions\n\n- Raises `RangeError` if `step == 0 && start != end`.\n" - }, - "kind": 12, - "label": "Int.rangeWithOptions", - "tags": [ 1 ] - }, { "detail": "(int, int) => int", "documentation": { @@ -542,28 +487,6 @@ Path "label": "Int.equal", "tags": [] }, - { - "deprecated": true, - "detail": "(int, ~radix: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toString` instead\n\n\n`toStringWithRadix(n, ~radix)` return a `string` representing the given value.\n`~radix` specifies the radix base to use for the formatted number.\nSee [`Number.toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString)\non MDN.\n\n## Examples\n\n```rescript\nInt.toStringWithRadix(6, ~radix=2) // \"110\"\nInt.toStringWithRadix(373592855, ~radix=16) // \"16449317\"\nInt.toStringWithRadix(123456, ~radix=36) // \"2n9c\"\n```\n\n## Exceptions\n\n`RangeError`: if `radix` is less than 2 or greater than 36.\n" - }, - "kind": 12, - "label": "Int.toStringWithRadix", - "tags": [ 1 ] - }, - { - "deprecated": true, - "detail": "(int, ~digits: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toExponential` instead\n\n\n`toExponential(n, ~digits)` return a `string` representing the given value in\nexponential notation. `digits` specifies how many digits should appear after\nthe decimal point. See [`Number.toExponential`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential)\non MDN.\n\n## Examples\n\n```rescript\nInt.toExponentialWithPrecision(77, ~digits=2) // \"7.70e+1\"\nInt.toExponentialWithPrecision(5678, ~digits=2) // \"5.68e+3\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` less than 0 or greater than 10.\n" - }, - "kind": 12, - "label": "Int.toExponentialWithPrecision", - "tags": [ 1 ] - }, { "detail": "(int, int) => int", "documentation": { @@ -584,28 +507,6 @@ Path "label": "Int.clamp", "tags": [] }, - { - "deprecated": true, - "detail": "(int, ~digits: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toFixed` instead\n\n\n`toFixedWithPrecision(n, ~digits)` return a `string` representing the given\nvalue using fixed-point notation. `digits` specifies how many digits should\nappear after the decimal point. See [`Number.toFixed`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed)\non MDN.\n\n## Examples\n\n```rescript\nInt.toFixedWithPrecision(300, ~digits=4) // \"300.0000\"\nInt.toFixedWithPrecision(300, ~digits=1) // \"300.0\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` is less than 0 or larger than 100.\n" - }, - "kind": 12, - "label": "Int.toFixedWithPrecision", - "tags": [ 1 ] - }, - { - "deprecated": true, - "detail": "(int, ~digits: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toPrecision` instead\n\n\n`toPrecisionWithPrecision(n, ~digits)` return a `string` representing the giver value with\nprecision. `digits` specifies the number of significant digits. See [`Number.toPrecision`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision) on MDN.\n\n## Examples\n\n```rescript\nInt.toPrecisionWithPrecision(100, ~digits=2) // \"1.0e+2\"\nInt.toPrecisionWithPrecision(1, ~digits=2) // \"1.0\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` is not between 1 and 100 (inclusive).\n Implementations are allowed to support larger and smaller values as well.\n ECMA-262 only requires a precision of up to 21 significant digits.\n" - }, - "kind": 12, - "label": "Int.toPrecisionWithPrecision", - "tags": [ 1 ] - }, { "detail": "(int, int) => int", "documentation": { @@ -712,17 +613,6 @@ Path "label": "Int.mod", "tags": [] }, - { - "deprecated": true, - "detail": "(int, int, rangeOptions) => array", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `range` instead\n\n\n`rangeWithOptions(start, end, options)` is like `range`, but with `step` and\n`inclusive` options configurable.\n\nIf `step` is set, the sequence will increase or decrease by that amount for each\nstep. If `start < end` and `step` is negative, or vice versa, an empty array is\nreturned since the sequence would otherwise never reach or exceed the end value\nand hence be infinite. If `step` is `0` and `start !=` end, a `RangeError` is\nraised as the sequence would never reach or exceed the end value and hence be\ninfinite.\n\nIf `inclusive` is set to `true`, the sequence will include `end` if `step` is\nset such that the sequence includes it.\n\n## Examples\n\n```rescript\nInt.rangeWithOptions(3, 7, {step: 2}) == [3, 5]\nInt.rangeWithOptions(3, 7, {step: 2, inclusive: true}) == [3, 5, 7]\nInt.rangeWithOptions(3, 6, {step: -2}) // RangeError\n```\n\n## Exceptions\n\n- Raises `RangeError` if `step == 0 && start != end`.\n" - }, - "kind": 12, - "label": "Int.rangeWithOptions", - "tags": [ 1 ] - }, { "detail": "(int, int) => int", "documentation": { @@ -1091,15 +981,15 @@ Path s } } ], - "detail": "(string, RegExp.t) => option", + "detail": "(string, string) => bool", "documentation": { "kind": "markdown", - "value": "\n`searchOpt(str, regexp)`. Like `search`, but return an `option`.\n\n## Examples\n\n```rescript\nString.searchOpt(\"testing 1 2 3\", /\\d+/) == Some(8)\nString.searchOpt(\"no numbers\", /\\d+/) == None\n```\n" + "value": "\n`startsWith(str, substr)` returns `true` if the `str` starts with `substr`,\n`false` otherwise.\nSee [`String.startsWith`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith) on MDN.\n\n## Examples\n\n```rescript\nString.startsWith(\"BuckleScript\", \"Buckle\") == true\nString.startsWith(\"BuckleScript\", \"\") == true\nString.startsWith(\"JavaScript\", \"Buckle\") == false\n```\n" }, - "insertText": "->String.searchOpt", + "insertText": "->String.startsWith", "kind": 12, - "label": "->String.searchOpt", - "sortText": "searchOpt", + "label": "->String.startsWith", + "sortText": "startsWith", "tags": [] }, { @@ -1112,15 +1002,15 @@ Path s } } ], - "detail": "(string, RegExp.t, ~limit: int) => array>", + "detail": "(string, string, ~limit: int) => array", "documentation": { "kind": "markdown", - "value": "\n`splitByRegExpAtMost(str, regexp, ~limit)` splits the given `str` at every\noccurrence of `regexp` and returns an array of the first `limit` resulting\nsubstrings. If `limit` is negative or greater than the number of substrings, the\narray will contain all the substrings.\nSee [`String.split`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split) on MDN.\n\n## Examples\n\n```rescript\nString.splitByRegExpAtMost(\"Hello World. How are you doing?\", / /, ~limit=3) == [\n Some(\"Hello\"),\n Some(\"World.\"),\n Some(\"How\"),\n ]\n```\n" + "value": "\n`splitAtMost(str, delimiter, ~limit)` splits the given `str` at every\noccurrence of `delimiter` and returns an array of the first `limit` resulting\nsubstrings. If `limit` is negative or greater than the number of substrings,\nthe array will contain all the substrings.\n\n## Examples\n\n```rescript\nString.splitAtMost(\"ant/bee/cat/dog/elk\", \"/\", ~limit=3) == [\"ant\", \"bee\", \"cat\"]\nString.splitAtMost(\"ant/bee/cat/dog/elk\", \"/\", ~limit=0) == []\nString.splitAtMost(\"ant/bee/cat/dog/elk\", \"/\", ~limit=9) == [\"ant\", \"bee\", \"cat\", \"dog\", \"elk\"]\n```\n" }, - "insertText": "->String.splitByRegExpAtMost", + "insertText": "->String.splitAtMost", "kind": 12, - "label": "->String.splitByRegExpAtMost", - "sortText": "splitByRegExpAtMost", + "label": "->String.splitAtMost", + "sortText": "splitAtMost", "tags": [] }, { @@ -1133,15 +1023,15 @@ Path s } } ], - "detail": "(string, ~start: int, ~end: int=?) => string", + "detail": "(string, RegExp.t) => option", "documentation": { "kind": "markdown", - "value": "\n`slice(str, ~start, ~end)` returns the substring of `str` starting at\ncharacter `start` up to but not including `end`.\n- If either `start` or `end` is negative, then it is evaluated as\n `length(str - start)` or `length(str - end)`.\n- If `end` is greater than the length of `str`, then it is treated as\n `length(str)`.\n- If `start` is greater than `end`, slice returns the empty string.\n See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nString.slice(\"abcdefg\", ~start=2, ~end=5) == \"cde\"\nString.slice(\"abcdefg\", ~start=2, ~end=9) == \"cdefg\"\nString.slice(\"abcdefg\", ~start=-4, ~end=-2) == \"de\"\nString.slice(\"abcdefg\", ~start=5, ~end=1) == \"\"\nString.slice(\"abcdefg\", ~start=2) == \"cdefg\"\nString.slice(\"Hello World\", ~start=6) == \"World\"\n```\n" + "value": "\n`searchOpt(str, regexp)`. Like `search`, but return an `option`.\n\n## Examples\n\n```rescript\nString.searchOpt(\"testing 1 2 3\", /\\d+/) == Some(8)\nString.searchOpt(\"no numbers\", /\\d+/) == None\n```\n" }, - "insertText": "->String.slice", + "insertText": "->String.searchOpt", "kind": 12, - "label": "->String.slice", - "sortText": "slice", + "label": "->String.searchOpt", + "sortText": "searchOpt", "tags": [] }, { @@ -1154,37 +1044,15 @@ Path s } } ], - "deprecated": true, - "detail": "(string, ~start: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `substring` instead\n\n\n`substringToEnd(str, ~start)` returns the substring of `str` from position\n`start` to the end.\n- If `start` is less than or equal to zero, the entire string is returned.\n- If `start` is greater than or equal to the length of `str`, the empty string\n is returned.\n See [`String.substring`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring) on MDN.\n\n## Examples\n\n```rescript\nString.substringToEnd(\"playground\", ~start=4) == \"ground\"\nString.substringToEnd(\"playground\", ~start=-3) == \"playground\"\nString.substringToEnd(\"playground\", ~start=12) == \"\"\n```\n" - }, - "insertText": "->String.substringToEnd", - "kind": 12, - "label": "->String.substringToEnd", - "sortText": "substringToEnd", - "tags": [ 1 ] - }, - { - "additionalTextEdits": [ - { - "newText": "", - "range": { - "end": { "character": 18, "line": 93 }, - "start": { "character": 17, "line": 93 } - } - } - ], - "detail": "(string, string) => bool", + "detail": "(string, RegExp.t, ~limit: int) => array>", "documentation": { "kind": "markdown", - "value": "\n`startsWith(str, substr)` returns `true` if the `str` starts with `substr`,\n`false` otherwise.\nSee [`String.startsWith`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith) on MDN.\n\n## Examples\n\n```rescript\nString.startsWith(\"BuckleScript\", \"Buckle\") == true\nString.startsWith(\"BuckleScript\", \"\") == true\nString.startsWith(\"JavaScript\", \"Buckle\") == false\n```\n" + "value": "\n`splitByRegExpAtMost(str, regexp, ~limit)` splits the given `str` at every\noccurrence of `regexp` and returns an array of the first `limit` resulting\nsubstrings. If `limit` is negative or greater than the number of substrings, the\narray will contain all the substrings.\nSee [`String.split`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split) on MDN.\n\n## Examples\n\n```rescript\nString.splitByRegExpAtMost(\"Hello World. How are you doing?\", / /, ~limit=3) == [\n Some(\"Hello\"),\n Some(\"World.\"),\n Some(\"How\"),\n ]\n```\n" }, - "insertText": "->String.startsWith", + "insertText": "->String.splitByRegExpAtMost", "kind": 12, - "label": "->String.startsWith", - "sortText": "startsWith", + "label": "->String.splitByRegExpAtMost", + "sortText": "splitByRegExpAtMost", "tags": [] }, { @@ -1197,39 +1065,17 @@ Path s } } ], - "detail": "(string, string, ~limit: int) => array", + "detail": "(string, ~start: int, ~end: int=?) => string", "documentation": { "kind": "markdown", - "value": "\n`splitAtMost(str, delimiter, ~limit)` splits the given `str` at every\noccurrence of `delimiter` and returns an array of the first `limit` resulting\nsubstrings. If `limit` is negative or greater than the number of substrings,\nthe array will contain all the substrings.\n\n## Examples\n\n```rescript\nString.splitAtMost(\"ant/bee/cat/dog/elk\", \"/\", ~limit=3) == [\"ant\", \"bee\", \"cat\"]\nString.splitAtMost(\"ant/bee/cat/dog/elk\", \"/\", ~limit=0) == []\nString.splitAtMost(\"ant/bee/cat/dog/elk\", \"/\", ~limit=9) == [\"ant\", \"bee\", \"cat\", \"dog\", \"elk\"]\n```\n" + "value": "\n`slice(str, ~start, ~end)` returns the substring of `str` starting at\ncharacter `start` up to but not including `end`.\n- If either `start` or `end` is negative, then it is evaluated as\n `length(str - start)` or `length(str - end)`.\n- If `end` is greater than the length of `str`, then it is treated as\n `length(str)`.\n- If `start` is greater than `end`, slice returns the empty string.\n See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nString.slice(\"abcdefg\", ~start=2, ~end=5) == \"cde\"\nString.slice(\"abcdefg\", ~start=2, ~end=9) == \"cdefg\"\nString.slice(\"abcdefg\", ~start=-4, ~end=-2) == \"de\"\nString.slice(\"abcdefg\", ~start=5, ~end=1) == \"\"\nString.slice(\"abcdefg\", ~start=2) == \"cdefg\"\nString.slice(\"Hello World\", ~start=6) == \"World\"\n```\n" }, - "insertText": "->String.splitAtMost", + "insertText": "->String.slice", "kind": 12, - "label": "->String.splitAtMost", - "sortText": "splitAtMost", + "label": "->String.slice", + "sortText": "slice", "tags": [] }, - { - "additionalTextEdits": [ - { - "newText": "", - "range": { - "end": { "character": 18, "line": 93 }, - "start": { "character": 17, "line": 93 } - } - } - ], - "deprecated": true, - "detail": "(string, ~start: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `slice` instead\n\n\n`sliceToEnd(str, ~start)` returns the substring of `str` starting at character\n`start` to the end of the string.\n- If `start` is negative, then it is evaluated as `length(str - start)`.\n- If `start` is greater than the length of `str`, then sliceToEnd returns the empty string.\n See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nString.sliceToEnd(\"abcdefg\", ~start=4) == \"efg\"\nString.sliceToEnd(\"abcdefg\", ~start=-2) == \"fg\"\nString.sliceToEnd(\"abcdefg\", ~start=7) == \"\"\n```\n" - }, - "insertText": "->String.sliceToEnd", - "kind": 12, - "label": "->String.sliceToEnd", - "sortText": "sliceToEnd", - "tags": [ 1 ] - }, { "additionalTextEdits": [ { diff --git a/tests/analysis_tests/tests/src/expected/CompletionNullNullable.res.txt b/tests/analysis_tests/tests/src/expected/CompletionNullNullable.res.txt index 83d58867dfd..c0403dbcc7f 100644 --- a/tests/analysis_tests/tests/src/expected/CompletionNullNullable.res.txt +++ b/tests/analysis_tests/tests/src/expected/CompletionNullNullable.res.txt @@ -76,28 +76,6 @@ Path "sortText": "map", "tags": [] }, - { - "additionalTextEdits": [ - { - "newText": "", - "range": { - "end": { "character": 5, "line": 2 }, - "start": { "character": 4, "line": 2 } - } - } - ], - "deprecated": true, - "detail": "t<'a> => 'a", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `getOrThrow` instead\n\n\n`getExn(value)` throws an exception if `null`, otherwise returns the value.\n\n```rescript\nNull.getExn(Null.make(3)) == 3\n\nswitch Null.getExn(%raw(\"'ReScript'\")) {\n| exception Invalid_argument(_) => assert(false)\n| value => value == \"ReScript\"\n}\n\nswitch Null.getExn(%raw(\"null\")) {\n| exception Invalid_argument(_) => assert(true)\n| _ => assert(false)\n}\n```\n\n## Exceptions\n\n- Throws `Invalid_argument` if `value` is `null`\n" - }, - "insertText": "->Null.getExn", - "kind": 12, - "label": "->Null.getExn", - "sortText": "getExn", - "tags": [ 1 ] - }, { "additionalTextEdits": [ { @@ -224,50 +202,6 @@ Path "sortText": "mapOr", "tags": [] }, - { - "additionalTextEdits": [ - { - "newText": "", - "range": { - "end": { "character": 5, "line": 2 }, - "start": { "character": 4, "line": 2 } - } - } - ], - "deprecated": true, - "detail": "(t<'a>, 'b, 'a => 'b) => 'b", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use mapOr instead\n\n" - }, - "insertText": "->Null.mapWithDefault", - "kind": 12, - "label": "->Null.mapWithDefault", - "sortText": "mapWithDefault", - "tags": [ 1 ] - }, - { - "additionalTextEdits": [ - { - "newText": "", - "range": { - "end": { "character": 5, "line": 2 }, - "start": { "character": 4, "line": 2 } - } - } - ], - "deprecated": true, - "detail": "(t<'a>, 'a) => 'a", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use getOr instead\n\n" - }, - "insertText": "->Null.getWithDefault", - "kind": 12, - "label": "->Null.getWithDefault", - "sortText": "getWithDefault", - "tags": [ 1 ] - }, { "additionalTextEdits": [ { @@ -407,28 +341,6 @@ Path "sortText": "map", "tags": [] }, - { - "additionalTextEdits": [ - { - "newText": "", - "range": { - "end": { "character": 5, "line": 7 }, - "start": { "character": 4, "line": 7 } - } - } - ], - "deprecated": true, - "detail": "t<'a> => 'a", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `getOrThrow` instead\n\n\n`getExn(value)` throws an exception if `null` or `undefined`, otherwise returns the value.\n\n```rescript\nswitch Nullable.getExn(%raw(\"'Hello'\")) {\n| exception Invalid_argument(_) => assert(false)\n| value => value == \"Hello\"\n}\n\nswitch Nullable.getExn(%raw(\"null\")) {\n| exception Invalid_argument(_) => assert(true)\n| _ => assert(false)\n}\n\nswitch Nullable.getExn(%raw(\"undefined\")) {\n| exception Invalid_argument(_) => assert(true)\n| _ => assert(false)\n}\n```\n\n## Exceptions\n\n- Throws `Invalid_argument` if `value` is `null` or `undefined`\n" - }, - "insertText": "->Nullable.getExn", - "kind": 12, - "label": "->Nullable.getExn", - "sortText": "getExn", - "tags": [ 1 ] - }, { "additionalTextEdits": [ { @@ -551,50 +463,6 @@ Path "sortText": "mapOr", "tags": [] }, - { - "additionalTextEdits": [ - { - "newText": "", - "range": { - "end": { "character": 5, "line": 7 }, - "start": { "character": 4, "line": 7 } - } - } - ], - "deprecated": true, - "detail": "(t<'a>, 'b, 'a => 'b) => 'b", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use mapOr instead\n\n" - }, - "insertText": "->Nullable.mapWithDefault", - "kind": 12, - "label": "->Nullable.mapWithDefault", - "sortText": "mapWithDefault", - "tags": [ 1 ] - }, - { - "additionalTextEdits": [ - { - "newText": "", - "range": { - "end": { "character": 5, "line": 7 }, - "start": { "character": 4, "line": 7 } - } - } - ], - "deprecated": true, - "detail": "(t<'a>, 'a) => 'a", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use getOr instead\n\n" - }, - "insertText": "->Nullable.getWithDefault", - "kind": 12, - "label": "->Nullable.getWithDefault", - "sortText": "getWithDefault", - "tags": [ 1 ] - }, { "additionalTextEdits": [ { diff --git a/tests/analysis_tests/tests/src/expected/CompletionPattern.res.txt b/tests/analysis_tests/tests/src/expected/CompletionPattern.res.txt index a10c8aca41e..b57844dfada 100644 --- a/tests/analysis_tests/tests/src/expected/CompletionPattern.res.txt +++ b/tests/analysis_tests/tests/src/expected/CompletionPattern.res.txt @@ -938,7 +938,7 @@ Path xn "value": "Matches on a JavaScript error. Read more in the [documentation on catching JS exceptions](https://rescript-lang.org/docs/manual/latest/exception#catching-js-exceptions)." }, "kind": 4, - "label": "Exn.Error(error)", + "label": "JsExn(error)", "tags": [] } ] diff --git a/tests/analysis_tests/tests/src/expected/CompletionPipeChain.res.txt b/tests/analysis_tests/tests/src/expected/CompletionPipeChain.res.txt index 81481d773b6..04fdfe5f9c7 100644 --- a/tests/analysis_tests/tests/src/expected/CompletionPipeChain.res.txt +++ b/tests/analysis_tests/tests/src/expected/CompletionPipeChain.res.txt @@ -310,50 +310,6 @@ Path Belt.Array.reduce Path Stdlib.Int.t Path t [ - { - "deprecated": true, - "detail": "(int, ~radix: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toString` instead\n\n\n`toStringWithRadix(n, ~radix)` return a `string` representing the given value.\n`~radix` specifies the radix base to use for the formatted number.\nSee [`Number.toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString)\non MDN.\n\n## Examples\n\n```rescript\nInt.toStringWithRadix(6, ~radix=2) // \"110\"\nInt.toStringWithRadix(373592855, ~radix=16) // \"16449317\"\nInt.toStringWithRadix(123456, ~radix=36) // \"2n9c\"\n```\n\n## Exceptions\n\n`RangeError`: if `radix` is less than 2 or greater than 36.\n" - }, - "kind": 12, - "label": "Int.toStringWithRadix", - "tags": [ 1 ] - }, - { - "deprecated": true, - "detail": "(int, ~digits: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toExponential` instead\n\n\n`toExponential(n, ~digits)` return a `string` representing the given value in\nexponential notation. `digits` specifies how many digits should appear after\nthe decimal point. See [`Number.toExponential`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential)\non MDN.\n\n## Examples\n\n```rescript\nInt.toExponentialWithPrecision(77, ~digits=2) // \"7.70e+1\"\nInt.toExponentialWithPrecision(5678, ~digits=2) // \"5.68e+3\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` less than 0 or greater than 10.\n" - }, - "kind": 12, - "label": "Int.toExponentialWithPrecision", - "tags": [ 1 ] - }, - { - "deprecated": true, - "detail": "(int, ~digits: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toFixed` instead\n\n\n`toFixedWithPrecision(n, ~digits)` return a `string` representing the given\nvalue using fixed-point notation. `digits` specifies how many digits should\nappear after the decimal point. See [`Number.toFixed`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed)\non MDN.\n\n## Examples\n\n```rescript\nInt.toFixedWithPrecision(300, ~digits=4) // \"300.0000\"\nInt.toFixedWithPrecision(300, ~digits=1) // \"300.0\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` is less than 0 or larger than 100.\n" - }, - "kind": 12, - "label": "Int.toFixedWithPrecision", - "tags": [ 1 ] - }, - { - "deprecated": true, - "detail": "(int, ~digits: int) => string", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `toPrecision` instead\n\n\n`toPrecisionWithPrecision(n, ~digits)` return a `string` representing the giver value with\nprecision. `digits` specifies the number of significant digits. See [`Number.toPrecision`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision) on MDN.\n\n## Examples\n\n```rescript\nInt.toPrecisionWithPrecision(100, ~digits=2) // \"1.0e+2\"\nInt.toPrecisionWithPrecision(1, ~digits=2) // \"1.0\"\n```\n\n## Exceptions\n\n- `RangeError`: If `digits` is not between 1 and 100 (inclusive).\n Implementations are allowed to support larger and smaller values as well.\n ECMA-262 only requires a precision of up to 21 significant digits.\n" - }, - "kind": 12, - "label": "Int.toPrecisionWithPrecision", - "tags": [ 1 ] - }, { "detail": "(int, ~digits: int=?) => string", "documentation": { diff --git a/tests/analysis_tests/tests/src/expected/CompletionRegexp.res.txt b/tests/analysis_tests/tests/src/expected/CompletionRegexp.res.txt index 32e7eddd8dc..cc6c0662ff7 100644 --- a/tests/analysis_tests/tests/src/expected/CompletionRegexp.res.txt +++ b/tests/analysis_tests/tests/src/expected/CompletionRegexp.res.txt @@ -33,7 +33,7 @@ Path "detail": "t => bool", "documentation": { "kind": "markdown", - "value": "\n`sticky(regexp)` returns whether the sticky (`y`) flag is set on this `RegExp`.\n\nSee [`RegExp.sticky`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/sticky) on MDN.\n\n## Examples\n```rescript\nlet regexp1 = RegExp.fromStringWithFlags(\"\\\\w+\", ~flags=\"g\")\nConsole.log(regexp1->RegExp.unicode) // Logs `false`, since `y` is not set\n\nlet regexp2 = RegExp.fromStringWithFlags(\"\\\\w+\", ~flags=\"my\")\nConsole.log(regexp2->RegExp.unicode) // Logs `true`, since `y` is set\n```\n" + "value": "\n`sticky(regexp)` returns whether the sticky (`y`) flag is set on this `RegExp`.\n\nSee [`RegExp.sticky`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/sticky) on MDN.\n\n## Examples\n```rescript\nlet regexp1 = RegExp.fromString(\"\\\\w+\", ~flags=\"g\")\nConsole.log(regexp1->RegExp.unicode) // Logs `false`, since `y` is not set\n\nlet regexp2 = RegExp.fromString(\"\\\\w+\", ~flags=\"my\")\nConsole.log(regexp2->RegExp.unicode) // Logs `true`, since `y` is set\n```\n" }, "kind": 12, "label": "RegExp.sticky", @@ -63,7 +63,7 @@ Path "detail": "t => bool", "documentation": { "kind": "markdown", - "value": "\n`ignoreCase(regexp)` returns whether the ignore case (`i`) flag is set on this `RegExp`.\n\nSee [`RegExp.ignoreCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/ignoreCase) on MDN.\n\n## Examples\n```rescript\nlet regexp1 = RegExp.fromStringWithFlags(\"\\\\w+\", ~flags=\"g\")\nConsole.log(regexp1->RegExp.ignoreCase) // Logs `false`, since `i` is not set\n\nlet regexp2 = RegExp.fromStringWithFlags(\"\\\\w+\", ~flags=\"i\")\nConsole.log(regexp2->RegExp.ignoreCase) // Logs `true`, since `i` is set\n```\n" + "value": "\n`ignoreCase(regexp)` returns whether the ignore case (`i`) flag is set on this `RegExp`.\n\nSee [`RegExp.ignoreCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/ignoreCase) on MDN.\n\n## Examples\n```rescript\nlet regexp1 = RegExp.fromString(\"\\\\w+\", ~flags=\"g\")\nConsole.log(regexp1->RegExp.ignoreCase) // Logs `false`, since `i` is not set\n\nlet regexp2 = RegExp.fromString(\"\\\\w+\", ~flags=\"i\")\nConsole.log(regexp2->RegExp.ignoreCase) // Logs `true`, since `i` is set\n```\n" }, "kind": 12, "label": "RegExp.ignoreCase", @@ -73,7 +73,7 @@ Path "detail": "t => bool", "documentation": { "kind": "markdown", - "value": "\n`global(regexp)` returns whether the global (`g`) flag is set on this `RegExp`.\n\nSee [`RegExp.global`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/global) on MDN.\n\n## Examples\n```rescript\nlet regexp1 = RegExp.fromStringWithFlags(\"\\\\w+\", ~flags=\"g\")\nConsole.log(regexp1->RegExp.global) // Logs `true`, since `g` is set\n\nlet regexp2 = RegExp.fromStringWithFlags(\"\\\\w+\", ~flags=\"i\")\nConsole.log(regexp2->RegExp.global) // Logs `false`, since `g` is not set\n```\n" + "value": "\n`global(regexp)` returns whether the global (`g`) flag is set on this `RegExp`.\n\nSee [`RegExp.global`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/global) on MDN.\n\n## Examples\n```rescript\nlet regexp1 = RegExp.fromString(\"\\\\w+\", ~flags=\"g\")\nConsole.log(regexp1->RegExp.global) // Logs `true`, since `g` is set\n\nlet regexp2 = RegExp.fromString(\"\\\\w+\", ~flags=\"i\")\nConsole.log(regexp2->RegExp.global) // Logs `false`, since `g` is not set\n```\n" }, "kind": 12, "label": "RegExp.global", @@ -83,7 +83,7 @@ Path "detail": "t => bool", "documentation": { "kind": "markdown", - "value": "\n`multiline(regexp)` returns whether the multiline (`m`) flag is set on this `RegExp`.\n\nSee [`RegExp.multiline`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/multiline) on MDN.\n\n## Examples\n```rescript\nlet regexp1 = RegExp.fromStringWithFlags(\"\\\\w+\", ~flags=\"g\")\nConsole.log(regexp1->RegExp.multiline) // Logs `false`, since `m` is not set\n\nlet regexp2 = RegExp.fromStringWithFlags(\"\\\\w+\", ~flags=\"mi\")\nConsole.log(regexp2->RegExp.multiline) // Logs `true`, since `m` is set\n```\n" + "value": "\n`multiline(regexp)` returns whether the multiline (`m`) flag is set on this `RegExp`.\n\nSee [`RegExp.multiline`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/multiline) on MDN.\n\n## Examples\n```rescript\nlet regexp1 = RegExp.fromString(\"\\\\w+\", ~flags=\"g\")\nConsole.log(regexp1->RegExp.multiline) // Logs `false`, since `m` is not set\n\nlet regexp2 = RegExp.fromString(\"\\\\w+\", ~flags=\"mi\")\nConsole.log(regexp2->RegExp.multiline) // Logs `true`, since `m` is set\n```\n" }, "kind": 12, "label": "RegExp.multiline", @@ -103,7 +103,7 @@ Path "detail": "t => bool", "documentation": { "kind": "markdown", - "value": "\n`unicode(regexp)` returns whether the unicode (`y`) flag is set on this `RegExp`.\n\nSee [`RegExp.unicode`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode) on MDN.\n\n## Examples\n```rescript\nlet regexp1 = RegExp.fromStringWithFlags(\"\\\\w+\", ~flags=\"g\")\nConsole.log(regexp1->RegExp.unicode) // Logs `false`, since `u` is not set\n\nlet regexp2 = RegExp.fromStringWithFlags(\"\\\\w+\", ~flags=\"mu\")\nConsole.log(regexp2->RegExp.unicode) // Logs `true`, since `u` is set\n```\n" + "value": "\n`unicode(regexp)` returns whether the unicode (`y`) flag is set on this `RegExp`.\n\nSee [`RegExp.unicode`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode) on MDN.\n\n## Examples\n```rescript\nlet regexp1 = RegExp.fromString(\"\\\\w+\", ~flags=\"g\")\nConsole.log(regexp1->RegExp.unicode) // Logs `false`, since `u` is not set\n\nlet regexp2 = RegExp.fromString(\"\\\\w+\", ~flags=\"mu\")\nConsole.log(regexp2->RegExp.unicode) // Logs `true`, since `u` is set\n```\n" }, "kind": 12, "label": "RegExp.unicode", @@ -113,7 +113,7 @@ Path "detail": "t => string", "documentation": { "kind": "markdown", - "value": "\n`source(regexp)` returns the source text for this `RegExp`, without the two forward slashes (if present), and without any set flags.\n\nSee [`RegExp.source`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/source) on MDN.\n\n## Examples\n```rescript\nlet regexp = RegExp.fromStringWithFlags(\"\\\\w+\", ~flags=\"g\")\nConsole.log(regexp->RegExp.source) // Logs `\\w+`, the source text of the `RegExp`\n```\n" + "value": "\n`source(regexp)` returns the source text for this `RegExp`, without the two forward slashes (if present), and without any set flags.\n\nSee [`RegExp.source`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/source) on MDN.\n\n## Examples\n```rescript\nlet regexp = RegExp.fromString(\"\\\\w+\", ~flags=\"g\")\nConsole.log(regexp->RegExp.source) // Logs `\\w+`, the source text of the `RegExp`\n```\n" }, "kind": 12, "label": "RegExp.source", diff --git a/tests/analysis_tests/tests/src/expected/DotPipeCompletionSpec.res.txt b/tests/analysis_tests/tests/src/expected/DotPipeCompletionSpec.res.txt index f82f68923ae..78fdd626cb7 100644 --- a/tests/analysis_tests/tests/src/expected/DotPipeCompletionSpec.res.txt +++ b/tests/analysis_tests/tests/src/expected/DotPipeCompletionSpec.res.txt @@ -573,21 +573,21 @@ Path filt } ] -Complete src/DotPipeCompletionSpec.res 89:62 -pos_cursor:[89:62] pos_no_white:[89:61] Found expr:[89:3->89:62] -pos_cursor:[89:62] pos_no_white:[89:61] Found expr:[89:36->89:62] -Pexp_field [89:36->89:55] includ:[89:56->89:62] -Completable: Cpath Value[Array, joinWith](Nolabel).includ +Complete src/DotPipeCompletionSpec.res 89:58 +pos_cursor:[89:58] pos_no_white:[89:57] Found expr:[89:3->89:58] +pos_cursor:[89:58] pos_no_white:[89:57] Found expr:[89:36->89:58] +Pexp_field [89:36->89:51] includ:[89:52->89:58] +Completable: Cpath Value[Array, join](Nolabel).includ Package opens Stdlib.place holder Pervasives.JsxModules.place holder Resolved opens 1 Stdlib -ContextPath Value[Array, joinWith](Nolabel).includ -ContextPath Value[Array, joinWith](Nolabel) -ContextPath Value[Array, joinWith] -Path Array.joinWith -ContextPath Value[Array, joinWith](Nolabel, Nolabel)->includ -ContextPath Value[Array, joinWith](Nolabel, Nolabel) -ContextPath Value[Array, joinWith] -Path Array.joinWith +ContextPath Value[Array, join](Nolabel).includ +ContextPath Value[Array, join](Nolabel) +ContextPath Value[Array, join] +Path Array.join +ContextPath Value[Array, join](Nolabel, Nolabel)->includ +ContextPath Value[Array, join](Nolabel, Nolabel) +ContextPath Value[Array, join] +Path Array.join Path Stdlib.String.includ Path includ [ @@ -596,20 +596,20 @@ Path includ { "newText": "", "range": { - "end": { "character": 56, "line": 89 }, - "start": { "character": 55, "line": 89 } + "end": { "character": 52, "line": 89 }, + "start": { "character": 51, "line": 89 } } } ], - "detail": "(string, string) => bool", + "detail": "(string, string, int) => bool", "documentation": { "kind": "markdown", - "value": "\n`includes(str, searchValue)` returns `true` if `searchValue` is found anywhere\nwithin `str`, `false` otherwise.\nSee [`String.includes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes) on MDN.\n\n## Examples\n\n```rescript\nString.includes(\"programmer\", \"gram\") == true\nString.includes(\"programmer\", \"er\") == true\nString.includes(\"programmer\", \"pro\") == true\nString.includes(\"programmer.dat\", \"xyz\") == false\n```\n" + "value": "\n`includesFrom(str, searchValue, start)` returns `true` if `searchValue` is found\nanywhere within `str` starting at character number `start` (where 0 is the\nfirst character), `false` otherwise.\nSee [`String.includes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes) on MDN.\n\n## Examples\n\n```rescript\nString.includesFrom(\"programmer\", \"gram\", 1) == true\nString.includesFrom(\"programmer\", \"gram\", 4) == false\nString.includesFrom(`대한민국`, `한`, 1) == true\n```\n" }, - "insertText": "->String.includes", + "insertText": "->String.includesFrom", "kind": 12, - "label": "->String.includes", - "sortText": "includes", + "label": "->String.includesFrom", + "sortText": "includesFrom", "tags": [] }, { @@ -617,20 +617,20 @@ Path includ { "newText": "", "range": { - "end": { "character": 56, "line": 89 }, - "start": { "character": 55, "line": 89 } + "end": { "character": 52, "line": 89 }, + "start": { "character": 51, "line": 89 } } } ], - "detail": "(string, string, int) => bool", + "detail": "(string, string) => bool", "documentation": { "kind": "markdown", - "value": "\n`includesFrom(str, searchValue, start)` returns `true` if `searchValue` is found\nanywhere within `str` starting at character number `start` (where 0 is the\nfirst character), `false` otherwise.\nSee [`String.includes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes) on MDN.\n\n## Examples\n\n```rescript\nString.includesFrom(\"programmer\", \"gram\", 1) == true\nString.includesFrom(\"programmer\", \"gram\", 4) == false\nString.includesFrom(`대한민국`, `한`, 1) == true\n```\n" + "value": "\n`includes(str, searchValue)` returns `true` if `searchValue` is found anywhere\nwithin `str`, `false` otherwise.\nSee [`String.includes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes) on MDN.\n\n## Examples\n\n```rescript\nString.includes(\"programmer\", \"gram\") == true\nString.includes(\"programmer\", \"er\") == true\nString.includes(\"programmer\", \"pro\") == true\nString.includes(\"programmer.dat\", \"xyz\") == false\n```\n" }, - "insertText": "->String.includesFrom", + "insertText": "->String.includes", "kind": 12, - "label": "->String.includesFrom", - "sortText": "includesFrom", + "label": "->String.includes", + "sortText": "includes", "tags": [] } ] diff --git a/tests/belt_tests/src/ticker.mjs b/tests/belt_tests/src/ticker.mjs index 81a3282ed38..af043db5bc4 100644 --- a/tests/belt_tests/src/ticker.mjs +++ b/tests/belt_tests/src/ticker.mjs @@ -2,7 +2,6 @@ import * as Belt_List from "@rescript/belt/src/Belt_List.mjs"; import * as Belt_Float from "@rescript/belt/src/Belt_Float.mjs"; -import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; import * as Belt_Option from "@rescript/belt/src/Belt_Option.mjs"; import * as Primitive_int from "@rescript/runtime/lib/es6/Primitive_int.mjs"; import * as Belt_MapString from "@rescript/belt/src/Belt_MapString.mjs"; @@ -136,13 +135,35 @@ function compute_update_sequences(all_tickers) { let l$1 = Belt_List.sort(l, (lhs, rhs) => { let x = lhs.rank; if (typeof x !== "object") { - return Pervasives.failwith("All nodes should be ranked"); - } - let y = rhs.rank; - if (typeof y !== "object") { - return Pervasives.failwith("All nodes should be ranked"); + if (x === "Uninitialized") { + throw { + RE_EXN_ID: "Failure", + _1: "All nodes should be ranked", + Error: new Error() + }; + } + throw { + RE_EXN_ID: "Failure", + _1: "All nodes should be ranked", + Error: new Error() + }; } else { - return Primitive_int.compare(x._0, y._0); + let y = rhs.rank; + if (typeof y === "object") { + return Primitive_int.compare(x._0, y._0); + } + if (y === "Uninitialized") { + throw { + RE_EXN_ID: "Failure", + _1: "All nodes should be ranked", + Error: new Error() + }; + } + throw { + RE_EXN_ID: "Failure", + _1: "All nodes should be ranked", + Error: new Error() + }; } }); return Belt_MapString.set(map, k, l$1); @@ -157,9 +178,12 @@ function process_quote(ticker_map, new_ticker, new_value) { if (ticker.ticker_name === new_ticker) { ticker.value = new_value; return; - } else { - return Pervasives.failwith("Only single Market ticker should be udpated upon a new quote"); } + throw { + RE_EXN_ID: "Failure", + _1: "Only single Market ticker should be udpated upon a new quote", + Error: new Error() + }; } let match$1 = match._0; let match$2 = match$1.lhs.value; @@ -190,87 +214,153 @@ function process_input_line(ticker_map, all_tickers, line) { }; }; let tokens = split("|", line); - if (tokens === 0) { - return Pervasives.failwith("Invalid input line"); - } - switch (tokens.hd) { - case "Q" : - let match = tokens.tl; - if (match === 0) { - return Pervasives.failwith("Invalid input line"); - } - let match$1 = match.tl; - if (match$1 === 0) { - return Pervasives.failwith("Invalid input line"); - } - if (match$1.tl !== 0) { - return Pervasives.failwith("Invalid input line"); - } - let ticker_map$1 = ticker_map !== undefined ? Primitive_option.valFromOption(ticker_map) : compute_update_sequences(all_tickers); - let value = Belt_Option.getExn(Belt_Float.fromString(match$1.hd)); - process_quote(ticker_map$1, match.hd, value); - return [ - all_tickers, - Primitive_option.some(ticker_map$1) - ]; - case "R" : - let match$2 = tokens.tl; - if (match$2 === 0) { - return Pervasives.failwith("Invalid input line"); - } - let match$3 = match$2.tl; - if (match$3 === 0) { - return Pervasives.failwith("Invalid input line"); - } - let ticker_name = match$2.hd; - switch (match$3.hd) { - case "+" : - let match$4 = match$3.tl; - if (match$4 === 0) { - return Pervasives.failwith("Invalid input line"); - } - let match$5 = match$4.tl; - if (match$5 !== 0 && match$5.tl === 0) { + if (tokens !== 0) { + switch (tokens.hd) { + case "Q" : + let match = tokens.tl; + if (match !== 0) { + let match$1 = match.tl; + if (match$1 !== 0) { + if (match$1.tl !== 0) { + throw { + RE_EXN_ID: "Failure", + _1: "Invalid input line", + Error: new Error() + }; + } + let ticker_map$1 = ticker_map !== undefined ? Primitive_option.valFromOption(ticker_map) : compute_update_sequences(all_tickers); + let value = Belt_Option.getExn(Belt_Float.fromString(match$1.hd)); + process_quote(ticker_map$1, match.hd, value); return [ - {hd: make_binary_op(ticker_name, match$4.hd, match$5.hd, "PLUS"), tl: all_tickers}, - ticker_map + all_tickers, + Primitive_option.some(ticker_map$1) ]; - } else { - return Pervasives.failwith("Invalid input line"); } - case "-" : - let match$6 = match$3.tl; - if (match$6 === 0) { - return Pervasives.failwith("Invalid input line"); - } - let match$7 = match$6.tl; - if (match$7 !== 0 && match$7.tl === 0) { - return [ - {hd: make_binary_op(ticker_name, match$6.hd, match$7.hd, "MINUS"), tl: all_tickers}, - ticker_map - ]; + throw { + RE_EXN_ID: "Failure", + _1: "Invalid input line", + Error: new Error() + }; + } + throw { + RE_EXN_ID: "Failure", + _1: "Invalid input line", + Error: new Error() + }; + case "R" : + let match$2 = tokens.tl; + if (match$2 !== 0) { + let match$3 = match$2.tl; + if (match$3 !== 0) { + let ticker_name = match$2.hd; + switch (match$3.hd) { + case "+" : + let match$4 = match$3.tl; + if (match$4 !== 0) { + let match$5 = match$4.tl; + if (match$5 !== 0) { + if (match$5.tl !== 0) { + throw { + RE_EXN_ID: "Failure", + _1: "Invalid input line", + Error: new Error() + }; + } + return [ + {hd: make_binary_op(ticker_name, match$4.hd, match$5.hd, "PLUS"), tl: all_tickers}, + ticker_map + ]; + } + throw { + RE_EXN_ID: "Failure", + _1: "Invalid input line", + Error: new Error() + }; + } + throw { + RE_EXN_ID: "Failure", + _1: "Invalid input line", + Error: new Error() + }; + case "-" : + let match$6 = match$3.tl; + if (match$6 !== 0) { + let match$7 = match$6.tl; + if (match$7 !== 0) { + if (match$7.tl !== 0) { + throw { + RE_EXN_ID: "Failure", + _1: "Invalid input line", + Error: new Error() + }; + } + return [ + {hd: make_binary_op(ticker_name, match$6.hd, match$7.hd, "MINUS"), tl: all_tickers}, + ticker_map + ]; + } + throw { + RE_EXN_ID: "Failure", + _1: "Invalid input line", + Error: new Error() + }; + } + throw { + RE_EXN_ID: "Failure", + _1: "Invalid input line", + Error: new Error() + }; + case "S" : + if (match$3.tl !== 0) { + throw { + RE_EXN_ID: "Failure", + _1: "Invalid input line", + Error: new Error() + }; + } + return [ + {hd: { + value: undefined, + rank: "Uninitialized", + ticker_name: ticker_name, + type_: "Market" + }, tl: all_tickers}, + ticker_map + ]; + default: + throw { + RE_EXN_ID: "Failure", + _1: "Invalid input line", + Error: new Error() + }; + } } else { - return Pervasives.failwith("Invalid input line"); + throw { + RE_EXN_ID: "Failure", + _1: "Invalid input line", + Error: new Error() + }; } - case "S" : - if (match$3.tl !== 0) { - return Pervasives.failwith("Invalid input line"); - } else { - return [ - {hd: { - value: undefined, - rank: "Uninitialized", - ticker_name: ticker_name, - type_: "Market" - }, tl: all_tickers}, - ticker_map - ]; - } - default: - return Pervasives.failwith("Invalid input line"); - } - default: - return Pervasives.failwith("Invalid input line"); + } else { + throw { + RE_EXN_ID: "Failure", + _1: "Invalid input line", + Error: new Error() + }; + } + default: + throw { + RE_EXN_ID: "Failure", + _1: "Invalid input line", + Error: new Error() + }; + } + } else { + throw { + RE_EXN_ID: "Failure", + _1: "Invalid input line", + Error: new Error() + }; } } diff --git a/tests/belt_tests/src/ticker.res b/tests/belt_tests/src/ticker.res index b462b74ddbd..b442264453a 100644 --- a/tests/belt_tests/src/ticker.res +++ b/tests/belt_tests/src/ticker.res @@ -160,7 +160,7 @@ let compute_update_sequences = all_tickers => { let l = l->List.sort((lhs, rhs) => switch (lhs, rhs) { | ({rank: Ranked(x)}, {rank: Ranked(y)}) => Pervasives.compare(x, y) - | (_, _) => failwith("All nodes should be ranked") + | (_, _) => throw(Failure("All nodes should be ranked")) } ) map->Ticker_map.set(k, l) @@ -176,7 +176,8 @@ let process_quote = (ticker_map, new_ticker, new_value) => { switch ticker { | {type_: Market, ticker_name, _} if ticker_name == new_ticker => ticker.value = Some(new_value) - | {type_: Market, _} => failwith("Only single Market ticker should be udpated upon a new quote") + | {type_: Market, _} => + throw(Failure("Only single Market ticker should be udpated upon a new quote")) | {type_: Binary_op({lhs, rhs, op}), ticker_name, _} => let value = switch (lhs.value, rhs.value) { @@ -230,7 +231,7 @@ let process_input_line = (ticker_map, all_tickers, line) => { let value = value->Float.fromString->Option.getExn process_quote(ticker_map, ticker_name, value) (all_tickers, Some(ticker_map)) - | _ => failwith("Invalid input line") + | _ => throw(Failure("Invalid input line")) } all_tickers diff --git a/tests/build_tests/source_map/input.js b/tests/build_tests/source_map/input.js index 1789e539854..545d70d9ae8 100644 --- a/tests/build_tests/source_map/input.js +++ b/tests/build_tests/source_map/input.js @@ -161,7 +161,7 @@ const originalDebuggerPositions = findTokenPositions(demoSource, "%debugger"); assert.equal(originalDebuggerPositions.length, 2); const originalRaiseErrorPositions = findTokenPositions( demoSource, - "Exn.raiseError", + "JsError.throwWithMessage", ); assert.equal(originalRaiseErrorPositions.length, 2); const originalPipeCallPositions = findTokenPositions(demoSource, "input->fn"); @@ -172,7 +172,7 @@ const originalPatternBranchPositions = [ ]; const originalHelperRaiseErrorPositions = findTokenPositions( helperSource, - "Exn.raiseError", + "JsError.throwWithMessage", ); assert.equal(originalHelperRaiseErrorPositions.length, 1); const originalHelperPipeCallPositions = findTokenPositions( @@ -301,7 +301,7 @@ function assertSourceMap(filename, js, map, options = {}) { const decodedMappings = decodeMappings(map.mappings); const generatedRaiseErrorPositions = findTokenPositions( js, - "Stdlib_Exn.raiseError", + "Stdlib_JsError.throwWithMessage", ); assert.equal( generatedRaiseErrorPositions.length, diff --git a/tests/build_tests/source_map/src/Demo.res b/tests/build_tests/source_map/src/Demo.res index b8ba45ea21d..749d35a8f96 100644 --- a/tests/build_tests/source_map/src/Demo.res +++ b/tests/build_tests/source_map/src/Demo.res @@ -7,7 +7,7 @@ type item = | Single(int) | Pair(int, int) -let crash = () => Exn.raiseError("source map test") +let crash = () => JsError.throwWithMessage("source map test") let debugStatement = () => { %debugger @@ -33,6 +33,6 @@ let describeItem = item => let unicodeMessage = "한글 🌏" -let unicodeCrash = () => Exn.raiseError(unicodeMessage) +let unicodeCrash = () => JsError.throwWithMessage(unicodeMessage) let value = add(pipedValue, 22) diff --git a/tests/build_tests/source_map/src/Helper.res b/tests/build_tests/source_map/src/Helper.res index 217bca9ea9a..8ef1ab805eb 100644 --- a/tests/build_tests/source_map/src/Helper.res +++ b/tests/build_tests/source_map/src/Helper.res @@ -15,6 +15,6 @@ let describe = payload => let unicodeLabel = "helper 한글 🌏" -let fail = () => Exn.raiseError("helper source map") +let fail = () => JsError.throwWithMessage("helper source map") let value = pipeThrough(21, multiply) diff --git a/tests/build_tests/super_errors/expected/deprecated_with_automigration.res.expected b/tests/build_tests/super_errors_multi/expected/Cross_deprecated_with_automigration.expected similarity index 66% rename from tests/build_tests/super_errors/expected/deprecated_with_automigration.res.expected rename to tests/build_tests/super_errors_multi/expected/Cross_deprecated_with_automigration.expected index a905b528b7b..2a8acd2dc43 100644 --- a/tests/build_tests/super_errors/expected/deprecated_with_automigration.res.expected +++ b/tests/build_tests/super_errors_multi/expected/Cross_deprecated_with_automigration.expected @@ -1,13 +1,14 @@ +===== User.res ===== Warning number 3 - /.../fixtures/deprecated_with_automigration.res:2:13-23 + /.../fixtures/Cross_deprecated_with_automigration/User.res:2:13-25 1 │ let values = list{1, 2} - 2 │ let first = List.getExn(values, 0) + 2 │ let first = Legacy.getExn(values, 0) 3 │ let incremented = first + 1 4 │ let _ = incremented - deprecated: Stdlib.List.getExn + deprecated: Legacy.getExn Use `getOrThrow` instead This can be automatically migrated by the ReScript migration tool. Run `rescript-tools migrate-all ` to run all automatic migrations available in your project, or `rescript-tools migrate ` to migrate a single file. \ No newline at end of file diff --git a/tests/build_tests/super_errors_multi/fixtures/Cross_deprecated_with_automigration/Legacy.res b/tests/build_tests/super_errors_multi/fixtures/Cross_deprecated_with_automigration/Legacy.res new file mode 100644 index 00000000000..13aa2bd2e8d --- /dev/null +++ b/tests/build_tests/super_errors_multi/fixtures/Cross_deprecated_with_automigration/Legacy.res @@ -0,0 +1,2 @@ +let getOrThrow = List.getOrThrow +let getExn = getOrThrow diff --git a/tests/build_tests/super_errors_multi/fixtures/Cross_deprecated_with_automigration/Legacy.resi b/tests/build_tests/super_errors_multi/fixtures/Cross_deprecated_with_automigration/Legacy.resi new file mode 100644 index 00000000000..c15e224c2c4 --- /dev/null +++ b/tests/build_tests/super_errors_multi/fixtures/Cross_deprecated_with_automigration/Legacy.resi @@ -0,0 +1,7 @@ +let getOrThrow: (list<'a>, int) => 'a + +@deprecated({ + reason: "Use `getOrThrow` instead", + migrate: Legacy.getOrThrow(), +}) +let getExn: (list<'a>, int) => 'a diff --git a/tests/build_tests/super_errors/fixtures/deprecated_with_automigration.res b/tests/build_tests/super_errors_multi/fixtures/Cross_deprecated_with_automigration/User.res similarity index 66% rename from tests/build_tests/super_errors/fixtures/deprecated_with_automigration.res rename to tests/build_tests/super_errors_multi/fixtures/Cross_deprecated_with_automigration/User.res index 959937879dd..a8c4709a06f 100644 --- a/tests/build_tests/super_errors/fixtures/deprecated_with_automigration.res +++ b/tests/build_tests/super_errors_multi/fixtures/Cross_deprecated_with_automigration/User.res @@ -1,4 +1,4 @@ let values = list{1, 2} -let first = List.getExn(values, 0) +let first = Legacy.getExn(values, 0) let incremented = first + 1 let _ = incremented diff --git a/tests/tests/src/UntaggedVariants.res b/tests/tests/src/UntaggedVariants.res index 9b2ea555878..c39db062be9 100644 --- a/tests/tests/src/UntaggedVariants.res +++ b/tests/tests/src/UntaggedVariants.res @@ -374,7 +374,7 @@ module Arr = { let classify = async (a: arr) => switch a { - | Array(arr) => Console.log(arr->Array.joinWith("-")) + | Array(arr) => Console.log(arr->Array.join("-")) | String(s) => Console.log(s) | Promise(p) => Console.log(await p) | Object({userName}) => Console.log(userName) @@ -424,7 +424,7 @@ module AllInstanceofTypes = { | Object({userName}) => Console.log(userName) | Date(date) => Console.log(date->Date.toString) | RegExp(re) => Console.log(re->RegExp.test("test")) - | Array(arr) => Console.log(arr->Array.joinWith("-")) + | Array(arr) => Console.log(arr->Array.join("-")) | File(file) => Console.log(file->fileName) | Blob(blob) => Console.log(blob->blobSize) | ArrayBuffer(_) => Console.log("ArrayBuffer") diff --git a/tests/tests/src/bench.mjs b/tests/tests/src/bench.mjs index f48d7376714..b11884cc6f3 100644 --- a/tests/tests/src/bench.mjs +++ b/tests/tests/src/bench.mjs @@ -1,6 +1,5 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.mjs"; function map(f, a) { @@ -22,7 +21,11 @@ function init(l, f) { return []; } if (l < 0) { - return Pervasives.invalid_arg("Array.init"); + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Array.init", + Error: new Error() + }; } let res = Stdlib_Array.make(l, f$1(0)); for (let i = 1; i < l; ++i) { diff --git a/tests/tests/src/bench.res b/tests/tests/src/bench.res index c626be5c8aa..42f25630367 100644 --- a/tests/tests/src/bench.res +++ b/tests/tests/src/bench.res @@ -17,7 +17,7 @@ let init = (l, f) => if l == 0 { [] } else if l < 0 { - invalid_arg("Array.init") + throw(Invalid_argument("Array.init")) } else { /* See #6575. We could also check for maximum array size, but this depends on whether we create a float array or a regular one... */ diff --git a/tests/tests/src/bigint_test.res b/tests/tests/src/bigint_test.res index b2a5c842989..66a400b7fd4 100644 --- a/tests/tests/src/bigint_test.res +++ b/tests/tests/src/bigint_test.res @@ -16,10 +16,10 @@ let generic_lessequal = \"<=" let bigint_greaterequal = (x: bigint, y) => x >= y let generic_greaterequal = \">=" let bigint_land = BigInt.bitwiseAnd -let bigint_lor = BigInt.lor -let bigint_lxor = BigInt.lxor -let bigint_lsl = BigInt.lsl -let bigint_asr = BigInt.asr +let bigint_lor = BigInt.bitwiseOr +let bigint_lxor = BigInt.bitwiseXor +let bigint_lsl = BigInt.shiftLeft +let bigint_asr = BigInt.shiftRight describe(__MODULE__, () => { test("bigint_test", () => { diff --git a/tests/tests/src/conditional/cond_a_load_test.mjs b/tests/tests/src/conditional/cond_a_load_test.mjs index 47502b2cc2f..959f580c14b 100644 --- a/tests/tests/src/conditional/cond_a_load_test.mjs +++ b/tests/tests/src/conditional/cond_a_load_test.mjs @@ -1,7 +1,6 @@ // Generated by ReScript, PLEASE EDIT WITH CARE import * as Mocha from "mocha"; -import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.mjs"; async function loadCondANone() { @@ -25,15 +24,25 @@ async function raisesAssertFailure(load) { Mocha.describe("Cond_a_load_test", () => { Mocha.test("cond_a loads as a module whose body throws Assert_failure", async () => { let ok = await raisesAssertFailure(() => import("./cond_a.mjs").then(m => m.u)); - if (!ok) { - return Pervasives.failwith("cond_a did not throw Assert_failure on load"); + if (ok) { + return; } + throw { + RE_EXN_ID: "Failure", + _1: "cond_a did not throw Assert_failure on load", + Error: new Error() + }; }); Mocha.test("cond_a_none loads as a module whose body throws Assert_failure", async () => { let ok = await raisesAssertFailure(loadCondANone); - if (!ok) { - return Pervasives.failwith("cond_a_none did not throw Assert_failure on load"); + if (ok) { + return; } + throw { + RE_EXN_ID: "Failure", + _1: "cond_a_none did not throw Assert_failure on load", + Error: new Error() + }; }); }); diff --git a/tests/tests/src/conditional/cond_a_load_test.res b/tests/tests/src/conditional/cond_a_load_test.res index 407d13ca0b3..b6e3fbde145 100644 --- a/tests/tests/src/conditional/cond_a_load_test.res +++ b/tests/tests/src/conditional/cond_a_load_test.res @@ -18,13 +18,13 @@ describe(__MODULE__, () => { testAsync("cond_a loads as a module whose body throws Assert_failure", async () => { let ok = await raisesAssertFailure(() => import(Cond_a.u)) if !ok { - failwith("cond_a did not throw Assert_failure on load") + throw(Failure("cond_a did not throw Assert_failure on load")) } }) testAsync("cond_a_none loads as a module whose body throws Assert_failure", async () => { let ok = await raisesAssertFailure(loadCondANone) if !ok { - failwith("cond_a_none did not throw Assert_failure on load") + throw(Failure("cond_a_none did not throw Assert_failure on load")) } }) }) diff --git a/tests/tests/src/const_defs_test.mjs b/tests/tests/src/const_defs_test.mjs index d0be58d1df7..24ec08e4e14 100644 --- a/tests/tests/src/const_defs_test.mjs +++ b/tests/tests/src/const_defs_test.mjs @@ -1,11 +1,14 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; let u = 3; function f() { - return Pervasives.invalid_arg("hi"); + throw { + RE_EXN_ID: "Invalid_argument", + _1: "hi", + Error: new Error() + }; } export { diff --git a/tests/tests/src/const_defs_test.res b/tests/tests/src/const_defs_test.res index 3328dac5316..20f9f13ca16 100644 --- a/tests/tests/src/const_defs_test.res +++ b/tests/tests/src/const_defs_test.res @@ -4,4 +4,4 @@ let u = if Const_defs.v { 4 } -let f = () => invalid_arg("hi") +let f = () => throw(Invalid_argument("hi")) diff --git a/tests/tests/src/defunctor_make_test.mjs b/tests/tests/src/defunctor_make_test.mjs index 54709bc9e76..37ae0d8ea7b 100644 --- a/tests/tests/src/defunctor_make_test.mjs +++ b/tests/tests/src/defunctor_make_test.mjs @@ -1,6 +1,5 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; import * as Primitive_int from "@rescript/runtime/lib/es6/Primitive_int.mjs"; function getcompare(x) { @@ -44,7 +43,11 @@ function bal(l, x, d, r) { hr = typeof r !== "object" ? 0 : r._4; if (hl > (hr + 2 | 0)) { if (typeof l !== "object") { - return Pervasives.invalid_arg("Map.bal"); + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; } let lr = l._3; let ld = l._2; @@ -52,11 +55,15 @@ function bal(l, x, d, r) { let ll = l._0; if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); - } else if (typeof lr !== "object") { - return Pervasives.invalid_arg("Map.bal"); - } else { + } + if (typeof lr === "object") { return create(create(ll, lv, ld, lr._0), lr._1, lr._2, create(lr._3, x, d, r)); } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; } if (hr <= (hl + 2 | 0)) { return { @@ -69,7 +76,11 @@ function bal(l, x, d, r) { }; } if (typeof r !== "object") { - return Pervasives.invalid_arg("Map.bal"); + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; } let rr = r._3; let rd = r._2; @@ -77,11 +88,15 @@ function bal(l, x, d, r) { let rl = r._0; if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); - } else if (typeof rl !== "object") { - return Pervasives.invalid_arg("Map.bal"); - } else { + } + if (typeof rl === "object") { return create(create(l, x, d, rl._0), rl._1, rl._2, create(rl._3, rv, rd, rr)); } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; } function add(x, data, compare, x_) { diff --git a/tests/tests/src/defunctor_make_test.res b/tests/tests/src/defunctor_make_test.res index 72fcbde0437..c68abb9c80c 100644 --- a/tests/tests/src/defunctor_make_test.res +++ b/tests/tests/src/defunctor_make_test.res @@ -71,13 +71,13 @@ let bal = (l, x, d, r) => { } if hl > hr + 2 { switch l { - | Empty => invalid_arg("Map.bal") + | Empty => throw(Invalid_argument("Map.bal")) | Node(ll, lv, ld, lr, _) => if height(ll) >= height(lr) { create(ll, lv, ld, create(lr, x, d, r)) } else { switch lr { - | Empty => invalid_arg("Map.bal") + | Empty => throw(Invalid_argument("Map.bal")) | Node(lrl, lrv, lrd, lrr, _) => create(create(ll, lv, ld, lrl), lrv, lrd, create(lrr, x, d, r)) } @@ -85,13 +85,13 @@ let bal = (l, x, d, r) => { } } else if hr > hl + 2 { switch r { - | Empty => invalid_arg("Map.bal") + | Empty => throw(Invalid_argument("Map.bal")) | Node(rl, rv, rd, rr, _) => if height(rr) >= height(rl) { create(create(l, x, d, rl), rv, rd, rr) } else { switch rl { - | Empty => invalid_arg("Map.bal") + | Empty => throw(Invalid_argument("Map.bal")) | Node(rll, rlv, rld, rlr, _) => create(create(l, x, d, rll), rlv, rld, create(rlr, rv, rd, rr)) } diff --git a/tests/tests/src/earger_curry_test.mjs b/tests/tests/src/earger_curry_test.mjs index e88320d84c2..4c43a780b4f 100644 --- a/tests/tests/src/earger_curry_test.mjs +++ b/tests/tests/src/earger_curry_test.mjs @@ -1,7 +1,6 @@ // Generated by ReScript, PLEASE EDIT WITH CARE import * as Mocha from "mocha"; -import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; import * as Test_utils from "./test_utils.mjs"; import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.mjs"; @@ -24,7 +23,11 @@ function init(l, f) { return []; } if (l < 0) { - return Pervasives.invalid_arg("Array.init"); + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Array.init", + Error: new Error() + }; } let res = Stdlib_Array.make(l, f$1(0)); for (let i = 1; i < l; ++i) { diff --git a/tests/tests/src/earger_curry_test.res b/tests/tests/src/earger_curry_test.res index 284e8ad4bbe..b789099c07a 100644 --- a/tests/tests/src/earger_curry_test.res +++ b/tests/tests/src/earger_curry_test.res @@ -19,7 +19,7 @@ let init = (l, f) => if l == 0 { [] } else if l < 0 { - invalid_arg("Array.init") + throw(Invalid_argument("Array.init")) } else { /* See #6575. We could also check for maximum array size, but this depends on whether we create a float array or a regular one... */ diff --git a/tests/tests/src/exception_alias.mjs b/tests/tests/src/exception_alias.mjs index 05d5c63f2d8..91cbf502e61 100644 --- a/tests/tests/src/exception_alias.mjs +++ b/tests/tests/src/exception_alias.mjs @@ -11,19 +11,15 @@ let b = Stdlib_List.length({hd: 1, tl: {hd: 2, tl: /* [] */0}}); let List = { size: Stdlib_List.size, head: Stdlib_List.head, - headExn: Stdlib_List.headExn, headOrThrow: Stdlib_List.headOrThrow, tail: Stdlib_List.tail, - tailExn: Stdlib_List.tailExn, tailOrThrow: Stdlib_List.tailOrThrow, add: Stdlib_List.add, get: Stdlib_List.get, - getExn: Stdlib_List.getExn, getOrThrow: Stdlib_List.getOrThrow, make: Stdlib_List.make, fromInitializer: Stdlib_List.fromInitializer, shuffle: Stdlib_List.shuffle, - toShuffled: Stdlib_List.toShuffled, drop: Stdlib_List.drop, take: Stdlib_List.take, splitAt: Stdlib_List.splitAt, @@ -55,7 +51,6 @@ let List = { compareLength: Stdlib_List.compareLength, compare: Stdlib_List.compare, equal: Stdlib_List.equal, - has: Stdlib_List.has, includes: Stdlib_List.includes, find: Stdlib_List.find, filter: Stdlib_List.filter, @@ -63,10 +58,6 @@ let List = { filterMap: Stdlib_List.filterMap, partition: Stdlib_List.partition, unzip: Stdlib_List.unzip, - getAssoc: Stdlib_List.getAssoc, - hasAssoc: Stdlib_List.hasAssoc, - removeAssoc: Stdlib_List.removeAssoc, - setAssoc: Stdlib_List.setAssoc, sort: Stdlib_List.sort, b: b, length: 3 diff --git a/tests/tests/src/exception_raise_test.mjs b/tests/tests/src/exception_raise_test.mjs index 3ba6fc37643..0a321a3b5e1 100644 --- a/tests/tests/src/exception_raise_test.mjs +++ b/tests/tests/src/exception_raise_test.mjs @@ -1,9 +1,9 @@ // Generated by ReScript, PLEASE EDIT WITH CARE import * as Mocha from "mocha"; -import * as Stdlib_Exn from "@rescript/runtime/lib/es6/Stdlib_Exn.mjs"; import * as Test_utils from "./test_utils.mjs"; import * as Stdlib_List from "@rescript/runtime/lib/es6/Stdlib_List.mjs"; +import * as Stdlib_JsExn from "@rescript/runtime/lib/es6/Stdlib_JsExn.mjs"; import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.mjs"; let Local = /* @__PURE__ */Primitive_exceptions.create("Exception_raise_test.Local"); @@ -177,7 +177,7 @@ Mocha.describe("Exception_raise_test", () => { testValue = (()=>{throw 2})(); } catch (raw_e) { let e = Primitive_exceptions.internalToException(raw_e); - testValue = Stdlib_Exn.asJsExn(e) !== undefined; + testValue = Stdlib_JsExn.fromException(e) !== undefined; } Test_utils.eq("File \"exception_raise_test.res\", line 86, characters 7-14", testValue, true); }); diff --git a/tests/tests/src/exception_raise_test.res b/tests/tests/src/exception_raise_test.res index ca6ea90f722..7e9a5be544c 100644 --- a/tests/tests/src/exception_raise_test.res +++ b/tests/tests/src/exception_raise_test.res @@ -81,7 +81,7 @@ describe(__MODULE__, () => { test("Exn.asJsExn with raw throw", () => { let testValue = try %raw(`()=>{throw 2}`)() catch { - | e => Exn.asJsExn(e) != None + | e => JsExn.fromException(e) != None } eq(__LOC__, testValue, true) }) diff --git a/tests/tests/src/ext_array_test.mjs b/tests/tests/src/ext_array_test.mjs index df9bcd80247..ba63cc31256 100644 --- a/tests/tests/src/ext_array_test.mjs +++ b/tests/tests/src/ext_array_test.mjs @@ -1,6 +1,5 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; import * as Stdlib_List from "@rescript/runtime/lib/es6/Stdlib_List.mjs"; import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.mjs"; import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.mjs"; @@ -98,19 +97,25 @@ function filter_map(f, a) { function range(from, to_) { if (from > to_) { - return Pervasives.invalid_arg("Ext_array_test.range"); - } else { - return Stdlib_Array.fromInitializer((to_ - from | 0) + 1 | 0, i => i + from | 0); + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Ext_array_test.range", + Error: new Error() + }; } + return Stdlib_Array.fromInitializer((to_ - from | 0) + 1 | 0, i => i + from | 0); } function map2i(f, a, b) { let len = a.length; if (len !== b.length) { - return Pervasives.invalid_arg("Ext_array_test.map2i"); - } else { - return a.map((i, a) => f(i, a, b[i])); + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Ext_array_test.map2i", + Error: new Error() + }; } + return a.map((i, a) => f(i, a, b[i])); } function tolist_aux(a, f, _i, _res) { diff --git a/tests/tests/src/ext_array_test.res b/tests/tests/src/ext_array_test.res index 1af2cfe2588..6173d828486 100644 --- a/tests/tests/src/ext_array_test.res +++ b/tests/tests/src/ext_array_test.res @@ -97,7 +97,7 @@ let filter_map = (f: _ => option<_>, a) => { let range = (from, to_) => if from > to_ { - invalid_arg("Ext_array_test.range") + throw(Invalid_argument("Ext_array_test.range")) } else { Array.fromInitializer(~length=to_ - from + 1, i => i + from) } @@ -105,7 +105,7 @@ let range = (from, to_) => let map2i = (f, a, b) => { let len = Array.length(a) if len != Array.length(b) { - invalid_arg("Ext_array_test.map2i") + throw(Invalid_argument("Ext_array_test.map2i")) } else { a->Array.mapWithIndex((i, a) => f(i, a, Array.getUnsafe(b, i))) } diff --git a/tests/tests/src/flexible_array_test.mjs b/tests/tests/src/flexible_array_test.mjs index 5ee6828a637..7cff1f6fdb7 100644 --- a/tests/tests/src/flexible_array_test.mjs +++ b/tests/tests/src/flexible_array_test.mjs @@ -1,6 +1,5 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.mjs"; import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.mjs"; @@ -162,9 +161,12 @@ function length(param) { function get(param, i) { if (i >= 0 && i < param[1]) { return sub(param[0], i + 1 | 0); - } else { - return Pervasives.invalid_arg("Array.get"); } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Array.get", + Error: new Error() + }; } function set(param, i, v) { @@ -174,9 +176,12 @@ function set(param, i, v) { update(param[0], i + 1 | 0, v), k ]; - } else { - return Pervasives.invalid_arg("Array.set"); } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Array.set", + Error: new Error() + }; } function push_front(param, v) { @@ -193,9 +198,12 @@ function pop_front(param) { lorem(param[0]), k - 1 | 0 ]; - } else { - return Pervasives.invalid_arg("Array.pop_front"); } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Array.pop_front", + Error: new Error() + }; } function push_back(param, v) { @@ -213,9 +221,12 @@ function pop_back(param) { $$delete(param[0], k), k - 1 | 0 ]; - } else { - return Pervasives.invalid_arg("Array.pop_back"); } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Array.pop_back", + Error: new Error() + }; } function filter_from(i, p, s) { diff --git a/tests/tests/src/flexible_array_test.res b/tests/tests/src/flexible_array_test.res index a54df1f9724..e9ff8fb7856 100644 --- a/tests/tests/src/flexible_array_test.res +++ b/tests/tests/src/flexible_array_test.res @@ -104,14 +104,14 @@ module Int_array: { if i >= 0 && i < k { sub(tree, i + 1) } else { - invalid_arg("Array.get") + throw(Invalid_argument("Array.get")) } let set = ((tree, k), i, v) => if i >= 0 && i < k { (update(tree, i + 1, v), k) } else { - invalid_arg("Array.set") + throw(Invalid_argument("Array.set")) } let push_front = ((tree, k), v) => (loext(tree, v), k + 1) @@ -120,7 +120,7 @@ module Int_array: { if k > 0 { (lorem(tree), k - 1) } else { - invalid_arg("Array.pop_front") + throw(Invalid_argument("Array.pop_front")) } let push_back = ((tree, k), v) => (update(tree, k + 1, v), k + 1) @@ -129,7 +129,7 @@ module Int_array: { if k > 0 { (delete(tree, k), k - 1) } else { - invalid_arg("Array.pop_back") + throw(Invalid_argument("Array.pop_back")) } let filter_from = (i, p, s) => { diff --git a/tests/tests/src/gpr_2316_test.mjs b/tests/tests/src/gpr_2316_test.mjs index b9fcb0ab587..33626b04e66 100644 --- a/tests/tests/src/gpr_2316_test.mjs +++ b/tests/tests/src/gpr_2316_test.mjs @@ -1,15 +1,17 @@ // Generated by ReScript, PLEASE EDIT WITH CARE import * as Mocha from "mocha"; -import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; import * as Test_utils from "./test_utils.mjs"; import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.mjs"; let y; try { - Pervasives.failwith("boo"); - y = undefined; + throw { + RE_EXN_ID: "Failure", + _1: "boo", + Error: new Error() + }; } catch (raw_msg) { let msg = Primitive_exceptions.internalToException(raw_msg); if (msg.RE_EXN_ID === "Failure") { @@ -23,11 +25,12 @@ let x; let exit = 0; -let e; - try { - e = Pervasives.failwith("boo"); - exit = 1; + throw { + RE_EXN_ID: "Failure", + _1: "boo", + Error: new Error() + }; } catch (raw_msg$1) { let msg$1 = Primitive_exceptions.internalToException(raw_msg$1); if (msg$1.RE_EXN_ID === "Failure") { diff --git a/tests/tests/src/gpr_2316_test.res b/tests/tests/src/gpr_2316_test.res index 5f8da1041b5..ac873c1865c 100644 --- a/tests/tests/src/gpr_2316_test.res +++ b/tests/tests/src/gpr_2316_test.res @@ -1,12 +1,12 @@ open Mocha open Test_utils -let y = switch failwith("boo") { +let y = switch throw(Failure("boo")) { | exception Failure(msg) => Some(msg) | e => None } -let x = switch failwith("boo") { +let x = switch throw(Failure("boo")) { | exception Failure(msg) => Some(msg) | e => Console.log("ok") diff --git a/tests/tests/src/gpr_2608_test.mjs b/tests/tests/src/gpr_2608_test.mjs index 58ce4fd9c9f..d19fb173665 100644 --- a/tests/tests/src/gpr_2608_test.mjs +++ b/tests/tests/src/gpr_2608_test.mjs @@ -9,14 +9,14 @@ let oppHeroes = {hd: 0, tl: /* [] */0}; let huntGrootCondition = false; if (Stdlib_List.length(/* [] */0) > 0) { - let x = Stdlib_List.filter(oppHeroes, h => Stdlib_List.headExn(/* [] */0) <= 1000); + let x = Stdlib_List.filter(oppHeroes, h => Stdlib_List.headOrThrow(/* [] */0) <= 1000); huntGrootCondition = Stdlib_List.length(x) === 0; } let huntGrootCondition2 = true; if (Stdlib_List.length(/* [] */0) < 0) { - let x$1 = Stdlib_List.filter(oppHeroes, h => Stdlib_List.headExn(/* [] */0) <= 1000); + let x$1 = Stdlib_List.filter(oppHeroes, h => Stdlib_List.headOrThrow(/* [] */0) <= 1000); huntGrootCondition2 = Stdlib_List.length(x$1) === 0; } diff --git a/tests/tests/src/gpr_2608_test.res b/tests/tests/src/gpr_2608_test.res index 01719eade00..4502047c1df 100644 --- a/tests/tests/src/gpr_2608_test.res +++ b/tests/tests/src/gpr_2608_test.res @@ -6,13 +6,13 @@ let nearestGroots = list{} let oppHeroes = list{0} let huntGrootCondition = List.length(nearestGroots) > 0 && { - let x = oppHeroes->List.filter(h => List.headExn(nearestGroots) <= 1000) + let x = oppHeroes->List.filter(h => List.headOrThrow(nearestGroots) <= 1000) List.length(x) == 0 } let huntGrootCondition2 = List.length(nearestGroots) >= 0 || { - let x = oppHeroes->List.filter(h => List.headExn(nearestGroots) <= 1000) + let x = oppHeroes->List.filter(h => List.headOrThrow(nearestGroots) <= 1000) List.length(x) == 0 } diff --git a/tests/tests/src/gpr_3697_test.mjs b/tests/tests/src/gpr_3697_test.mjs index 0c952a177a5..485ec21eb74 100644 --- a/tests/tests/src/gpr_3697_test.mjs +++ b/tests/tests/src/gpr_3697_test.mjs @@ -5,14 +5,14 @@ import * as Stdlib_Lazy from "@rescript/runtime/lib/es6/Stdlib_Lazy.mjs"; function fix() { return { TAG: "Fix", - _0: Stdlib_Lazy.from_fun(fix) + _0: Stdlib_Lazy.make(fix) }; } function unfixLeak(_f) { while (true) { let f = _f; - _f = Stdlib_Lazy.force(f._0); + _f = Stdlib_Lazy.get(f._0); continue; }; } @@ -20,7 +20,7 @@ function unfixLeak(_f) { function unfix(p) { while (true) { let h = p.contents; - p.contents = Stdlib_Lazy.force(h._0); + p.contents = Stdlib_Lazy.get(h._0); }; } diff --git a/tests/tests/src/gpr_3697_test.res b/tests/tests/src/gpr_3697_test.res index f6e55b04bb0..f50923ed21c 100644 --- a/tests/tests/src/gpr_3697_test.res +++ b/tests/tests/src/gpr_3697_test.res @@ -1,14 +1,14 @@ type rec t<'a> = Fix(Lazy.t>) -let rec fix = () => Fix(Lazy.from_fun(fix)) +let rec fix = () => Fix(Lazy.make(fix)) -let rec unfixLeak = (Fix(f)) => unfixLeak(Lazy.force(f)) +let rec unfixLeak = (Fix(f)) => unfixLeak(Lazy.get(f)) let unfix = p => while true { p := switch p.contents { - | Fix(h) => Lazy.force(h) + | Fix(h) => Lazy.get(h) } } /* ;; unfixLeak (fix ()) */ diff --git a/tests/tests/src/inline_map2_test.mjs b/tests/tests/src/inline_map2_test.mjs index c3783db6796..8a034c64011 100644 --- a/tests/tests/src/inline_map2_test.mjs +++ b/tests/tests/src/inline_map2_test.mjs @@ -1,7 +1,6 @@ // Generated by ReScript, PLEASE EDIT WITH CARE import * as Mocha from "mocha"; -import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; import * as Test_utils from "./test_utils.mjs"; import * as Stdlib_List from "@rescript/runtime/lib/es6/Stdlib_List.mjs"; import * as Primitive_int from "@rescript/runtime/lib/es6/Primitive_int.mjs"; @@ -43,7 +42,11 @@ function Make(Ord) { hr = typeof r !== "object" ? 0 : r._4; if (hl > (hr + 2 | 0)) { if (typeof l !== "object") { - return Pervasives.invalid_arg("Map.bal"); + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; } let lr = l._3; let ld = l._2; @@ -51,11 +54,15 @@ function Make(Ord) { let ll = l._0; if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); - } else if (typeof lr !== "object") { - return Pervasives.invalid_arg("Map.bal"); - } else { + } + if (typeof lr === "object") { return create(create(ll, lv, ld, lr._0), lr._1, lr._2, create(lr._3, x, d, r)); } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; } if (hr <= (hl + 2 | 0)) { return { @@ -68,7 +75,11 @@ function Make(Ord) { }; } if (typeof r !== "object") { - return Pervasives.invalid_arg("Map.bal"); + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; } let rr = r._3; let rd = r._2; @@ -76,11 +87,15 @@ function Make(Ord) { let rl = r._0; if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); - } else if (typeof rl !== "object") { - return Pervasives.invalid_arg("Map.bal"); - } else { + } + if (typeof rl === "object") { return create(create(l, x, d, rl._0), rl._1, rl._2, create(rl._3, rv, rd, rr)); } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; }; let is_empty = x => typeof x !== "object"; let add = (x, data, x_) => { @@ -187,7 +202,11 @@ function Make(Ord) { }; let remove_min_binding = x => { if (typeof x !== "object") { - return Pervasives.invalid_arg("Map.remove_min_elt"); + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.remove_min_elt", + Error: new Error() + }; } let l = x._0; if (typeof l !== "object") { @@ -633,7 +652,11 @@ function bal(l, x, d, r) { hr = typeof r !== "object" ? 0 : r._4; if (hl > (hr + 2 | 0)) { if (typeof l !== "object") { - return Pervasives.invalid_arg("Map.bal"); + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; } let lr = l._3; let ld = l._2; @@ -641,11 +664,15 @@ function bal(l, x, d, r) { let ll = l._0; if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); - } else if (typeof lr !== "object") { - return Pervasives.invalid_arg("Map.bal"); - } else { + } + if (typeof lr === "object") { return create(create(ll, lv, ld, lr._0), lr._1, lr._2, create(lr._3, x, d, r)); } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; } if (hr <= (hl + 2 | 0)) { return { @@ -658,7 +685,11 @@ function bal(l, x, d, r) { }; } if (typeof r !== "object") { - return Pervasives.invalid_arg("Map.bal"); + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; } let rr = r._3; let rd = r._2; @@ -666,11 +697,15 @@ function bal(l, x, d, r) { let rl = r._0; if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); - } else if (typeof rl !== "object") { - return Pervasives.invalid_arg("Map.bal"); - } else { + } + if (typeof rl === "object") { return create(create(l, x, d, rl._0), rl._1, rl._2, create(rl._3, rv, rd, rr)); } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; } function is_empty(x) { @@ -786,7 +821,11 @@ function max_binding(_x) { function remove_min_binding(x) { if (typeof x !== "object") { - return Pervasives.invalid_arg("Map.remove_min_elt"); + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.remove_min_elt", + Error: new Error() + }; } let l = x._0; if (typeof l !== "object") { @@ -1270,7 +1309,11 @@ function bal$1(l, x, d, r) { hr = typeof r !== "object" ? 0 : r._4; if (hl > (hr + 2 | 0)) { if (typeof l !== "object") { - return Pervasives.invalid_arg("Map.bal"); + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; } let lr = l._3; let ld = l._2; @@ -1278,11 +1321,15 @@ function bal$1(l, x, d, r) { let ll = l._0; if (height$1(ll) >= height$1(lr)) { return create$1(ll, lv, ld, create$1(lr, x, d, r)); - } else if (typeof lr !== "object") { - return Pervasives.invalid_arg("Map.bal"); - } else { + } + if (typeof lr === "object") { return create$1(create$1(ll, lv, ld, lr._0), lr._1, lr._2, create$1(lr._3, x, d, r)); } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; } if (hr <= (hl + 2 | 0)) { return { @@ -1295,7 +1342,11 @@ function bal$1(l, x, d, r) { }; } if (typeof r !== "object") { - return Pervasives.invalid_arg("Map.bal"); + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; } let rr = r._3; let rd = r._2; @@ -1303,11 +1354,15 @@ function bal$1(l, x, d, r) { let rl = r._0; if (height$1(rr) >= height$1(rl)) { return create$1(create$1(l, x, d, rl), rv, rd, rr); - } else if (typeof rl !== "object") { - return Pervasives.invalid_arg("Map.bal"); - } else { + } + if (typeof rl === "object") { return create$1(create$1(l, x, d, rl._0), rl._1, rl._2, create$1(rl._3, rv, rd, rr)); } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; } function is_empty$1(x) { @@ -1423,7 +1478,11 @@ function max_binding$1(_x) { function remove_min_binding$1(x) { if (typeof x !== "object") { - return Pervasives.invalid_arg("Map.remove_min_elt"); + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.remove_min_elt", + Error: new Error() + }; } let l = x._0; if (typeof l !== "object") { diff --git a/tests/tests/src/inline_map2_test.res b/tests/tests/src/inline_map2_test.res index d850e2bd581..86d9dcf1570 100644 --- a/tests/tests/src/inline_map2_test.res +++ b/tests/tests/src/inline_map2_test.res @@ -90,13 +90,13 @@ module Make = (Ord: OrderedType) => { } if hl > hr + 2 { switch l { - | Empty => invalid_arg("Map.bal") + | Empty => throw(Invalid_argument("Map.bal")) | Node(ll, lv, ld, lr, _) => if height(ll) >= height(lr) { create(ll, lv, ld, create(lr, x, d, r)) } else { switch lr { - | Empty => invalid_arg("Map.bal") + | Empty => throw(Invalid_argument("Map.bal")) | Node(lrl, lrv, lrd, lrr, _) => create(create(ll, lv, ld, lrl), lrv, lrd, create(lrr, x, d, r)) } @@ -104,13 +104,13 @@ module Make = (Ord: OrderedType) => { } } else if hr > hl + 2 { switch r { - | Empty => invalid_arg("Map.bal") + | Empty => throw(Invalid_argument("Map.bal")) | Node(rl, rv, rd, rr, _) => if height(rr) >= height(rl) { create(create(l, x, d, rl), rv, rd, rr) } else { switch rl { - | Empty => invalid_arg("Map.bal") + | Empty => throw(Invalid_argument("Map.bal")) | Node(rll, rlv, rld, rlr, _) => create(create(l, x, d, rll), rlv, rld, create(rlr, rv, rd, rr)) } @@ -204,7 +204,7 @@ module Make = (Ord: OrderedType) => { let rec remove_min_binding = x => switch x { - | Empty => invalid_arg("Map.remove_min_elt") + | Empty => throw(Invalid_argument("Map.remove_min_elt")) | Node(Empty, x, d, r, _) => r | Node(l, x, d, r, _) => bal(remove_min_binding(l), x, d, r) } diff --git a/tests/tests/src/inline_map_test.mjs b/tests/tests/src/inline_map_test.mjs index b5dd983777c..cedd5223b4d 100644 --- a/tests/tests/src/inline_map_test.mjs +++ b/tests/tests/src/inline_map_test.mjs @@ -1,7 +1,6 @@ // Generated by ReScript, PLEASE EDIT WITH CARE import * as Mocha from "mocha"; -import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; import * as Test_utils from "./test_utils.mjs"; import * as Stdlib_List from "@rescript/runtime/lib/es6/Stdlib_List.mjs"; import * as Primitive_int from "@rescript/runtime/lib/es6/Primitive_int.mjs"; @@ -34,7 +33,11 @@ function bal(l, x, d, r) { hr = typeof r !== "object" ? 0 : r._4; if (hl > (hr + 2 | 0)) { if (typeof l !== "object") { - return Pervasives.invalid_arg("Map.bal"); + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; } let lr = l._3; let ld = l._2; @@ -42,11 +45,15 @@ function bal(l, x, d, r) { let ll = l._0; if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); - } else if (typeof lr !== "object") { - return Pervasives.invalid_arg("Map.bal"); - } else { + } + if (typeof lr === "object") { return create(create(ll, lv, ld, lr._0), lr._1, lr._2, create(lr._3, x, d, r)); } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; } if (hr <= (hl + 2 | 0)) { return { @@ -59,7 +66,11 @@ function bal(l, x, d, r) { }; } if (typeof r !== "object") { - return Pervasives.invalid_arg("Map.bal"); + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; } let rr = r._3; let rd = r._2; @@ -67,11 +78,15 @@ function bal(l, x, d, r) { let rl = r._0; if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); - } else if (typeof rl !== "object") { - return Pervasives.invalid_arg("Map.bal"); - } else { + } + if (typeof rl === "object") { return create(create(l, x, d, rl._0), rl._1, rl._2, create(rl._3, rv, rd, rr)); } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; } function add(x, data, x_) { diff --git a/tests/tests/src/inline_map_test.res b/tests/tests/src/inline_map_test.res index 970eb0101f0..30e0bf30ea3 100644 --- a/tests/tests/src/inline_map_test.res +++ b/tests/tests/src/inline_map_test.res @@ -47,13 +47,13 @@ let bal = (l, x, d, r) => { } if hl > hr + 2 { switch l { - | Empty => invalid_arg("Map.bal") + | Empty => throw(Invalid_argument("Map.bal")) | Node(ll, lv, ld, lr, _) => if height(ll) >= height(lr) { create(ll, lv, ld, create(lr, x, d, r)) } else { switch lr { - | Empty => invalid_arg("Map.bal") + | Empty => throw(Invalid_argument("Map.bal")) | Node(lrl, lrv, lrd, lrr, _) => create(create(ll, lv, ld, lrl), lrv, lrd, create(lrr, x, d, r)) } @@ -61,13 +61,13 @@ let bal = (l, x, d, r) => { } } else if hr > hl + 2 { switch r { - | Empty => invalid_arg("Map.bal") + | Empty => throw(Invalid_argument("Map.bal")) | Node(rl, rv, rd, rr, _) => if height(rr) >= height(rl) { create(create(l, x, d, rl), rv, rd, rr) } else { switch rl { - | Empty => invalid_arg("Map.bal") + | Empty => throw(Invalid_argument("Map.bal")) | Node(rll, rlv, rld, rlr, _) => create(create(l, x, d, rll), rlv, rld, create(rlr, rv, rd, rr)) } @@ -161,7 +161,7 @@ let rec max_binding = x => let rec remove_min_binding = x => switch x { - | Empty => invalid_arg("Map.remove_min_elt") + | Empty => throw(Invalid_argument("Map.remove_min_elt")) | Node(Empty, x, d, r, _) => r | Node(l, x, d, r, _) => bal(remove_min_binding(l), x, d, r) } diff --git a/tests/tests/src/lazy_test.mjs b/tests/tests/src/lazy_test.mjs index 6594bd02997..1bb5b6c1063 100644 --- a/tests/tests/src/lazy_test.mjs +++ b/tests/tests/src/lazy_test.mjs @@ -59,15 +59,17 @@ let f008 = Stdlib_Lazy.make(() => { }; }); -let a2 = Stdlib_Lazy.from_val; +function a2(x) { + return Stdlib_Lazy.make(() => x); +} -let a3 = Stdlib_Lazy.from_val(3); +let a3 = Stdlib_Lazy.make(() => 3); -let a4 = Stdlib_Lazy.from_val(3); +let a4 = Stdlib_Lazy.make(() => 3); -let a5 = Stdlib_Lazy.from_val(undefined); +let a5 = Stdlib_Lazy.make(() => {}); -let a6 = Stdlib_Lazy.from_val(); +let a6 = Stdlib_Lazy.make(() => {}); let a7 = Stdlib_Lazy.get(a5); @@ -80,17 +82,21 @@ Mocha.describe("Lazy_test", () => { ])); Mocha.test("lazy_force", () => Test_utils.eq("File \"lazy_test.res\", line 74, characters 30-37", u_v.contents, 2)); Mocha.test("lazy_from_fun", () => Test_utils.eq("File \"lazy_test.res\", line 75, characters 33-40", Stdlib_Lazy.get(l_from_fun), 3)); - Mocha.test("lazy_from_val", () => Test_utils.eq("File \"lazy_test.res\", line 76, characters 33-40", Stdlib_Lazy.get(Stdlib_Lazy.from_val(3)), 3)); - Mocha.test("lazy_from_val2", () => Test_utils.eq("File \"lazy_test.res\", line 78, characters 7-14", Stdlib_Lazy.get(Stdlib_Lazy.get(Stdlib_Lazy.from_val(Stdlib_Lazy.make(() => 3)))), 3)); + Mocha.test("lazy_from_val", () => Test_utils.eq("File \"lazy_test.res\", line 76, characters 33-40", Stdlib_Lazy.get(Stdlib_Lazy.make(() => 3)), 3)); + Mocha.test("lazy_from_val2", () => Test_utils.eq("File \"lazy_test.res\", line 78, characters 7-14", Stdlib_Lazy.get(Stdlib_Lazy.get(Stdlib_Lazy.make(() => Stdlib_Lazy.make(() => 3)))), 3)); Mocha.test("lazy_from_val3", () => { debugger; Test_utils.eq("File \"lazy_test.res\", line 82, characters 6-13", Stdlib_Lazy.get(Stdlib_Lazy.get(Stdlib_Lazy.make(() => forward_test))), 4); }); - Mocha.test("lazy_test.res", () => Test_utils.eq("File \"lazy_test.res\", line 90, characters 26-33", a3, a4)); + Mocha.test("lazy_test.res", () => Test_utils.eq("File \"lazy_test.res\", line 90, characters 26-33", Stdlib_Lazy.get(a3), Stdlib_Lazy.get(a4))); Mocha.test("lazy_test.res", () => Test_utils.eq("File \"lazy_test.res\", line 91, characters 26-33", a7, undefined)); Mocha.test("lazy_test.res", () => Test_utils.eq("File \"lazy_test.res\", line 92, characters 26-33", a8, undefined)); - Mocha.test("File \"lazy_test.res\", line 93, characters 7-14", () => Test_utils.ok("File \"lazy_test.res\", line 93, characters 25-32", Stdlib_Lazy.isEvaluated(Stdlib_Lazy.from_val(3)))); - Mocha.test("File \"lazy_test.res\", line 94, characters 7-14", () => Test_utils.ok("File \"lazy_test.res\", line 94, characters 25-32", !Stdlib_Lazy.isEvaluated(Stdlib_Lazy.make(() => { + Mocha.test("File \"lazy_test.res\", line 93, characters 7-14", () => { + let evaluated = Stdlib_Lazy.make(() => 3); + Stdlib_Lazy.get(evaluated); + Test_utils.ok("File \"lazy_test.res\", line 96, characters 7-14", Stdlib_Lazy.isEvaluated(evaluated)); + }); + Mocha.test("File \"lazy_test.res\", line 98, characters 7-14", () => Test_utils.ok("File \"lazy_test.res\", line 98, characters 25-32", !Stdlib_Lazy.isEvaluated(Stdlib_Lazy.make(() => { throw { RE_EXN_ID: "Not_found", Error: new Error() diff --git a/tests/tests/src/lazy_test.res b/tests/tests/src/lazy_test.res index 5a77e036079..e6d7d447751 100644 --- a/tests/tests/src/lazy_test.res +++ b/tests/tests/src/lazy_test.res @@ -58,12 +58,12 @@ let f008 = Lazy.make(() => { throw(Not_found) }) -let a2 = x => Lazy.from_val(x) +let a2 = x => Lazy.make(() => x) -let a3 = Lazy.from_val(3) +let a3 = Lazy.make(() => 3) let a4 = a2(3) -let a5 = Lazy.from_val(None) -let a6 = Lazy.from_val() +let a5 = Lazy.make(() => None) +let a6 = Lazy.make(() => ()) let a7 = Lazy.get(a5) let a8 = Lazy.get(a6) @@ -73,9 +73,9 @@ describe(__MODULE__, () => { // test("lazy_match", () => eq(__LOC__, h, 2)) test("lazy_force", () => eq(__LOC__, u_v.contents, 2)) test("lazy_from_fun", () => eq(__LOC__, Lazy.get(l_from_fun), 3)) - test("lazy_from_val", () => eq(__LOC__, Lazy.get(Lazy.from_val(3)), 3)) + test("lazy_from_val", () => eq(__LOC__, Lazy.get(Lazy.make(() => 3)), 3)) test("lazy_from_val2", () => - eq(__LOC__, Lazy.get(Lazy.get(Lazy.from_val(Lazy.make(() => 3)))), 3) + eq(__LOC__, Lazy.get(Lazy.get(Lazy.make(() => Lazy.make(() => 3)))), 3) ) test("lazy_from_val3", () => eq( @@ -87,9 +87,13 @@ describe(__MODULE__, () => { 4, ) ) - test(__FILE__, () => eq(__LOC__, a3, a4)) + test(__FILE__, () => eq(__LOC__, Lazy.get(a3), Lazy.get(a4))) test(__FILE__, () => eq(__LOC__, a7, None)) test(__FILE__, () => eq(__LOC__, a8, ())) - test(__LOC__, () => ok(__LOC__, Lazy.isEvaluated(Lazy.from_val(3)))) + test(__LOC__, () => { + let evaluated = Lazy.make(() => 3) + ignore(Lazy.get(evaluated)) + ok(__LOC__, Lazy.isEvaluated(evaluated)) + }) test(__LOC__, () => ok(__LOC__, !Lazy.isEvaluated(Lazy.make(() => throw(Not_found))))) }) diff --git a/tests/tests/src/mario_game.mjs b/tests/tests/src/mario_game.mjs index d8da28954c6..aa90533a693 100644 --- a/tests/tests/src/mario_game.mjs +++ b/tests/tests/src/mario_game.mjs @@ -1,6 +1,5 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; import * as Stdlib_Int from "@rescript/runtime/lib/es6/Stdlib_Int.mjs"; import * as Stdlib_List from "@rescript/runtime/lib/es6/Stdlib_List.mjs"; import * as Primitive_int from "@rescript/runtime/lib/es6/Primitive_int.mjs"; @@ -1462,7 +1461,11 @@ function game_win(ctx) { ctx.fillStyle = "white"; ctx.font = "20px 'Press Start 2P'"; ctx.fillText("You win!", 180, 128); - return Pervasives.failwith("Game over."); + throw { + RE_EXN_ID: "Failure", + _1: "Game over.", + Error: new Error() + }; } function game_loss(ctx) { @@ -1472,7 +1475,11 @@ function game_loss(ctx) { ctx.fillStyle = "white"; ctx.font = "20px 'Press Start 2P'"; ctx.fillText("GAME OVER. You lose!", 60, 128); - return Pervasives.failwith("Game over."); + throw { + RE_EXN_ID: "Failure", + _1: "Game over.", + Error: new Error() + }; } let Draw = { @@ -2367,7 +2374,11 @@ function choose_enemy_typ(typ) { case 2 : return "Goomba"; default: - return Pervasives.failwith("Shouldn't reach here"); + throw { + RE_EXN_ID: "Failure", + _1: "Shouldn't reach here", + Error: new Error() + }; } } @@ -2387,7 +2398,11 @@ function choose_sblock_typ(typ) { case 4 : return "Ground"; default: - return Pervasives.failwith("Shouldn't reach here"); + throw { + RE_EXN_ID: "Failure", + _1: "Shouldn't reach here", + Error: new Error() + }; } } @@ -2772,7 +2787,11 @@ function choose_block_pattern(blockw, blockh, cbx, cby, prob) { ] ], tl: /* [] */0}; default: - return Pervasives.failwith("Shouldn't reach here"); + throw { + RE_EXN_ID: "Failure", + _1: "Shouldn't reach here", + Error: new Error() + }; } } @@ -3011,7 +3030,17 @@ let loadCount = { function load(param) { let canvas_id = "canvas"; let el = document.getElementById(canvas_id); - let canvas = el !== null ? el : (console.log("cant find canvas canvas"), Pervasives.failwith("fail")); + let canvas; + if (el !== null) { + canvas = el; + } else { + console.log("cant find canvas canvas"); + throw { + RE_EXN_ID: "Failure", + _1: "fail", + Error: new Error() + }; + } let context = canvas.getContext("2d"); document.addEventListener("keydown", keydown, true); document.addEventListener("keyup", keyup, true); diff --git a/tests/tests/src/mario_game.res b/tests/tests/src/mario_game.res index 20345edbbe7..382a2ac60d5 100644 --- a/tests/tests/src/mario_game.res +++ b/tests/tests/src/mario_game.res @@ -1486,7 +1486,7 @@ module Draw: { ctx["fillStyle"] = "white" ctx["font"] = "20px 'Press Start 2P'" ctx["fillText"]("You win!", 180., 128.) - failwith("Game over.") + throw(Failure("Game over.")) } /* gave_loss displays a black screen stating a loss to finish that level play. */ @@ -1498,10 +1498,10 @@ module Draw: { ctx["fillStyle"] = "white" ctx["font"] = "20px 'Press Start 2P'" ctx["fillText"]("GAME OVER. You lose!", 60., 128.) - failwith("Game over.") + throw(Failure("Game over.")) } - let draw_background_color = canvas => failwith("todo") + let draw_background_color = canvas => throw(Failure("todo")) } module Viewport: { open Actors @@ -2190,7 +2190,7 @@ module Procedural_generator: { | 0 => RKoopa | 1 => GKoopa | 2 => Goomba - | _ => failwith("Shouldn't reach here") + | _ => throw(Failure("Shouldn't reach here")) } /* Chooses what type of block should be instantiated given typ number */ @@ -2201,7 +2201,7 @@ module Procedural_generator: { | 2 => Cloud | 3 => QBlock(Mushroom) | 4 => Ground - | _ => failwith("Shouldn't reach here") + | _ => throw(Failure("Shouldn't reach here")) } /* Optimizes lst such that there are no two items in the list that have the same @@ -2371,7 +2371,7 @@ module Procedural_generator: { } } | 5 => list{(3, (cbx, cby))} - | _ => failwith("Shouldn't reach here") + | _ => throw(Failure("Shouldn't reach here")) } obj_coord } @@ -2595,7 +2595,7 @@ module Main = { let canvas = switch Dom_html.getElementById(Dom_html.document, canvas_id) { | None => Console.log("cant find canvas " ++ canvas_id ++ "") - failwith("fail") + throw(Failure("fail")) | Some(el) => Dom_html.elementToCanvasElement(el) } diff --git a/tests/tests/src/mpr_6033_test.mjs b/tests/tests/src/mpr_6033_test.mjs index a4af31e53df..e38c52dea59 100644 --- a/tests/tests/src/mpr_6033_test.mjs +++ b/tests/tests/src/mpr_6033_test.mjs @@ -10,7 +10,7 @@ function f(x) { Mocha.describe("Mpr_6033_test", () => { Mocha.test("lazy evaluation", () => { - let x = Stdlib_Lazy.from_fun(() => "def"); + let x = Stdlib_Lazy.make(() => "def"); Stdlib_Lazy.get(x); let u = Stdlib_Lazy.get(x) + "abc"; Test_utils.eq("File \"mpr_6033_test.res\", line 14, characters 7-14", u, "defabc"); diff --git a/tests/tests/src/mpr_6033_test.res b/tests/tests/src/mpr_6033_test.res index de377adc404..98fc6185035 100644 --- a/tests/tests/src/mpr_6033_test.res +++ b/tests/tests/src/mpr_6033_test.res @@ -8,7 +8,7 @@ let f = x => describe(__MODULE__, () => { test("lazy evaluation", () => { - let x = Lazy.from_fun(() => "def") + let x = Lazy.make(() => "def") ignore(Lazy.get(x)) let u = f(x) eq(__LOC__, u, "defabc") diff --git a/tests/tests/src/recursive_records_test.mjs b/tests/tests/src/recursive_records_test.mjs index bd06c81c1ae..d947b60b1ea 100644 --- a/tests/tests/src/recursive_records_test.mjs +++ b/tests/tests/src/recursive_records_test.mjs @@ -86,9 +86,9 @@ Mocha.describe("Recursive_records_test", () => { Test_utils.eq("File \"recursive_records_test.res\", line 63, characters 7-14", (hd(rec_cell2$1) + hd(tl_exn(rec_cell2$1)) | 0) + hd(tl_exn(tl_exn(rec_cell2$1))) | 0, 9); }); Mocha.test("recursive variant list operations", () => { - Test_utils.eq("File \"recursive_records_test.res\", line 69, characters 7-14", (Stdlib_List.headExn(rec_cell3) + Stdlib_List.headExn(Stdlib_List.tailExn(rec_cell3)) | 0) + Stdlib_List.headExn(Stdlib_List.tailExn(Stdlib_List.tailExn(rec_cell3))) | 0, 9); + Test_utils.eq("File \"recursive_records_test.res\", line 69, characters 7-14", (Stdlib_List.headOrThrow(rec_cell3) + Stdlib_List.headOrThrow(Stdlib_List.tailOrThrow(rec_cell3)) | 0) + Stdlib_List.headOrThrow(Stdlib_List.tailOrThrow(Stdlib_List.tailOrThrow(rec_cell3))) | 0, 9); let rec_cell3$1 = f3(3); - Test_utils.eq("File \"recursive_records_test.res\", line 71, characters 7-14", (Stdlib_List.headExn(rec_cell3$1) + Stdlib_List.headExn(Stdlib_List.tailExn(rec_cell3$1)) | 0) + Stdlib_List.headExn(Stdlib_List.tailExn(Stdlib_List.tailExn(rec_cell3$1))) | 0, 9); + Test_utils.eq("File \"recursive_records_test.res\", line 71, characters 7-14", (Stdlib_List.headOrThrow(rec_cell3$1) + Stdlib_List.headOrThrow(Stdlib_List.tailOrThrow(rec_cell3$1)) | 0) + Stdlib_List.headOrThrow(Stdlib_List.tailOrThrow(Stdlib_List.tailOrThrow(rec_cell3$1))) | 0, 9); }); }); diff --git a/tests/tests/src/recursive_records_test.res b/tests/tests/src/recursive_records_test.res index fe70c1784b6..02f6557c587 100644 --- a/tests/tests/src/recursive_records_test.res +++ b/tests/tests/src/recursive_records_test.res @@ -64,8 +64,8 @@ describe(__MODULE__, () => { }) test("recursive variant list operations", () => { - let hd = List.headExn - let tl = List.tailExn + let hd = List.headOrThrow + let tl = List.tailOrThrow eq(__LOC__, hd(rec_cell3) + hd(tl(rec_cell3)) + hd(tl(tl(rec_cell3))), 9) let rec_cell3 = f3(3) eq(__LOC__, hd(rec_cell3) + hd(tl(rec_cell3)) + hd(tl(tl(rec_cell3))), 9) diff --git a/tests/tests/src/set_gen.mjs b/tests/tests/src/set_gen.mjs index b0524031a67..7d85fbd180a 100644 --- a/tests/tests/src/set_gen.mjs +++ b/tests/tests/src/set_gen.mjs @@ -1,6 +1,5 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; import * as Stdlib_List from "@rescript/runtime/lib/es6/Stdlib_List.mjs"; import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.mjs"; @@ -309,7 +308,11 @@ function internal_bal(l, v, r) { function remove_min_elt(x) { if (typeof x !== "object") { - return Pervasives.invalid_arg("Set.remove_min_elt"); + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Set.remove_min_elt", + Error: new Error() + }; } let l = x._0; if (typeof l !== "object") { diff --git a/tests/tests/src/set_gen.res b/tests/tests/src/set_gen.res index 19a78b92d12..da5db1d356e 100644 --- a/tests/tests/src/set_gen.res +++ b/tests/tests/src/set_gen.res @@ -324,7 +324,7 @@ let internal_bal = (l, v, r) => { let rec remove_min_elt = x => switch x { - | Empty => invalid_arg("Set.remove_min_elt") + | Empty => throw(Invalid_argument("Set.remove_min_elt")) | Node(Empty, v, r, _) => r | Node(l, v, r, _) => internal_bal(remove_min_elt(l), v, r) } diff --git a/tests/tests/src/stdlib/Stdlib_IntTests.mjs b/tests/tests/src/stdlib/Stdlib_IntTests.mjs index 6a75939bab5..b7c549e6814 100644 --- a/tests/tests/src/stdlib/Stdlib_IntTests.mjs +++ b/tests/tests/src/stdlib/Stdlib_IntTests.mjs @@ -1,7 +1,6 @@ // Generated by ReScript, PLEASE EDIT WITH CARE import * as Test from "./Test.mjs"; -import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; import * as Stdlib_Int from "@rescript/runtime/lib/es6/Stdlib_Int.mjs"; import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.mjs"; import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.mjs"; @@ -11,7 +10,11 @@ let eq = Primitive_object.equal; function $$catch(f) { try { f(); - return Pervasives.failwith("no exception raised"); + throw { + RE_EXN_ID: "Failure", + _1: "no exception raised", + Error: new Error() + }; } catch (raw_err) { let err = Primitive_exceptions.internalToException(raw_err); if (err.RE_EXN_ID === "JsExn") { diff --git a/tests/tests/src/stdlib/Stdlib_IntTests.res b/tests/tests/src/stdlib/Stdlib_IntTests.res index f2cc09d7726..60e2fbfce93 100644 --- a/tests/tests/src/stdlib/Stdlib_IntTests.res +++ b/tests/tests/src/stdlib/Stdlib_IntTests.res @@ -3,7 +3,7 @@ let eq = (a, b) => a == b let catch = f => try { let _ = f() - failwith("no exception raised") + throw(Failure("no exception raised")) } catch { | JsExn(err) => err } diff --git a/tests/tests/src/stdlib/Stdlib_PromiseTest.mjs b/tests/tests/src/stdlib/Stdlib_PromiseTest.mjs index e8d01aceb1f..8bfeb94f8a3 100644 --- a/tests/tests/src/stdlib/Stdlib_PromiseTest.mjs +++ b/tests/tests/src/stdlib/Stdlib_PromiseTest.mjs @@ -1,15 +1,15 @@ // Generated by ReScript, PLEASE EDIT WITH CARE import * as Test from "./Test.mjs"; -import * as Stdlib_Exn from "@rescript/runtime/lib/es6/Stdlib_Exn.mjs"; import * as Stdlib_JsExn from "@rescript/runtime/lib/es6/Stdlib_JsExn.mjs"; +import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.mjs"; import * as Stdlib_Promise from "@rescript/runtime/lib/es6/Stdlib_Promise.mjs"; import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.mjs"; import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.mjs"; let TestError = /* @__PURE__ */Primitive_exceptions.create("Stdlib_PromiseTest.TestError"); -let fail = Stdlib_Exn.raiseError; +let fail = Stdlib_JsError.throwWithMessage; let equal = Primitive_object.equal; @@ -187,7 +187,7 @@ function testExnThrow() { } function testRaiseErrorThrow() { - return Stdlib_Promise.$$catch(Promise.resolve().then(() => Stdlib_Exn.raiseError("Some JS error")), e => { + return Stdlib_Promise.$$catch(Promise.resolve().then(() => Stdlib_JsError.throwWithMessage("Some JS error")), e => { let isTestErr = e.RE_EXN_ID === "JsExn" ? Primitive_object.equal(Stdlib_JsExn.message(e._1), "Some JS error") : false; Test.run([ [ diff --git a/tests/tests/src/stdlib/Stdlib_PromiseTest.res b/tests/tests/src/stdlib/Stdlib_PromiseTest.res index a5c89de490c..b2a356749e5 100644 --- a/tests/tests/src/stdlib/Stdlib_PromiseTest.res +++ b/tests/tests/src/stdlib/Stdlib_PromiseTest.res @@ -1,7 +1,7 @@ exception TestError(string) let fail = msg => { - Exn.raiseError(msg) + JsError.throwWithMessage(msg) } let equal = (a, b) => { @@ -164,7 +164,7 @@ module Catching = { open Promise let causeErr = () => { - Exn.raiseError("Some JS error") + JsError.throwWithMessage("Some JS error") } resolve() diff --git a/tests/tests/src/stdlib/Stdlib_RegExpTest.res b/tests/tests/src/stdlib/Stdlib_RegExpTest.res index cafdd8e7d81..254c4f76ace 100644 --- a/tests/tests/src/stdlib/Stdlib_RegExpTest.res +++ b/tests/tests/src/stdlib/Stdlib_RegExpTest.res @@ -3,7 +3,7 @@ let eq = (a, b) => a == b // Test for RegExp.flags Test.run( __POS_OF__("RegExp.flags basic"), - RegExp.fromStringWithFlags("\\w+", ~flags="gi")->RegExp.flags, + RegExp.fromString("\\w+", ~flags="gi")->RegExp.flags, eq, "gi", ) @@ -11,7 +11,7 @@ Test.run( // Test for alphabetical sorting of flags Test.run( __POS_OF__("RegExp.flags sorting"), - RegExp.fromStringWithFlags("\\w+", ~flags="igd")->RegExp.flags, + RegExp.fromString("\\w+", ~flags="igd")->RegExp.flags, eq, "dgi", ) diff --git a/tests/tests/src/stdlib/Stdlib_TempTests.mjs b/tests/tests/src/stdlib/Stdlib_TempTests.mjs index bb5e988ce52..b4eea337efa 100644 --- a/tests/tests/src/stdlib/Stdlib_TempTests.mjs +++ b/tests/tests/src/stdlib/Stdlib_TempTests.mjs @@ -2,7 +2,6 @@ import * as Stdlib_Int from "@rescript/runtime/lib/es6/Stdlib_Int.mjs"; import * as Stdlib_Dict from "@rescript/runtime/lib/es6/Stdlib_Dict.mjs"; -import * as Stdlib_JSON from "@rescript/runtime/lib/es6/Stdlib_JSON.mjs"; import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.mjs"; import * as Stdlib_Float from "@rescript/runtime/lib/es6/Stdlib_Float.mjs"; import * as Stdlib_BigInt from "@rescript/runtime/lib/es6/Stdlib_BigInt.mjs"; @@ -97,15 +96,13 @@ console.info("---"); let json = JSON.parse(`{"foo": "bar"}`); -let json$1 = Stdlib_JSON.Classify.classify(json); - let tmp; -if (typeof json$1 !== "object" || json$1.TAG !== "Object") { - tmp = undefined; +if (typeof json === "object" && json !== null && !Array.isArray(json)) { + let value = json["foo"]; + tmp = typeof value === "string" ? value : undefined; } else { - let value = Stdlib_JSON.Classify.classify(json$1._0["foo"]); - tmp = typeof value !== "object" || value.TAG !== "String" ? undefined : value._0; + tmp = undefined; } console.log(tmp); diff --git a/tests/tests/src/stdlib/Stdlib_TempTests.res b/tests/tests/src/stdlib/Stdlib_TempTests.res index 93270c7d9f1..23ef80ee04f 100644 --- a/tests/tests/src/stdlib/Stdlib_TempTests.res +++ b/tests/tests/src/stdlib/Stdlib_TempTests.res @@ -26,10 +26,10 @@ Console.info("") Console.info("Error") Console.info("---") let f = () => { - let error = Error.make("hello") - let typeError = Error.TypeError.make("error") - let g = () => Error.throw(error) - let h = () => Error.throw(typeError) + let error = JsError.make("hello") + let typeError = JsError.TypeError.make("error") + let g = () => JsError.throw(error) + let h = () => JsError.throw(typeError) (g, h) } @@ -46,10 +46,10 @@ Console.info("JSON") Console.info("---") let json = JSON.parseOrThrow(`{"foo": "bar"}`) Console.log( - switch JSON.Classify.classify(json) { + switch json { | Object(json) => - switch JSON.Classify.classify(json->Dict.get("foo")) { - | String(value) => Some(value) + switch json->Dict.get("foo") { + | Some(String(value)) => Some(value) | _ => None } | _ => None @@ -144,7 +144,7 @@ Console.log( " Hello world " ->String.toLowerCase ->String.trim - ->String.unsafeReplaceRegExpBy2(regexp, ( + ->String.replaceRegExpBy2Unsafe(regexp, ( ~match as _, ~group1, ~group2, diff --git a/tests/tests/src/stdlib/Stdlib_TypedArrayTests.mjs b/tests/tests/src/stdlib/Stdlib_TypedArrayTests.mjs index e6116d75b14..ea577749d5e 100644 --- a/tests/tests/src/stdlib/Stdlib_TypedArrayTests.mjs +++ b/tests/tests/src/stdlib/Stdlib_TypedArrayTests.mjs @@ -50,7 +50,7 @@ function areSame(x, y) { return x.toString() === y.toString(); } -assertTrue("fromArray", () => areSame(Stdlib_Option.getExn(new BigInt64Array([ +assertTrue("fromArray", () => areSame(Stdlib_Option.getOrThrow(new BigInt64Array([ num1, num2 ])[1], undefined), num2)); @@ -58,25 +58,25 @@ assertTrue("fromArray", () => areSame(Stdlib_Option.getExn(new BigInt64Array([ assertTrue("fromBuffer", () => { let x = new BigInt64Array(new ArrayBuffer(16)); x[1] = num2; - return areSame(Stdlib_Option.getExn(x[1], undefined), num2); + return areSame(Stdlib_Option.getOrThrow(x[1], undefined), num2); }); assertWillThrow("fromBuffer when too short can throw when used", () => { let x = new BigInt64Array(new ArrayBuffer(1)); x[0] = num1; - areSame(Stdlib_Option.getExn(x[0], undefined), num1); + areSame(Stdlib_Option.getOrThrow(x[0], undefined), num1); }); assertTrue("fromBufferWithRange", () => { let x = new BigInt64Array(new ArrayBuffer(16), 0, 1); x[0] = num1; - return areSame(Stdlib_Option.getExn(x[0], undefined), num1); + return areSame(Stdlib_Option.getOrThrow(x[0], undefined), num1); }); assertWillThrow("fromBufferWithRange is unsafe, out of range", () => { let x = new BigInt64Array(new ArrayBuffer(16), 13, 1); x[0] = num1; - areSame(Stdlib_Option.getExn(x[0], undefined), num1); + areSame(Stdlib_Option.getOrThrow(x[0], undefined), num1); }); assertTrue("fromLength is NOT in bytes", () => { @@ -89,8 +89,8 @@ assertTrue("a typed array is a TypedArray.t through a coercion", () => { return x.length === 2; }); -function o(prim0, prim1) { - return BigInt64Array.from(prim0, prim1); +function o(x, map) { + return BigInt64Array.from(x, map); } export { diff --git a/tests/tests/src/stdlib/Stdlib_TypedArrayTests.res b/tests/tests/src/stdlib/Stdlib_TypedArrayTests.res index 693e174f057..3c0eff53879 100644 --- a/tests/tests/src/stdlib/Stdlib_TypedArrayTests.res +++ b/tests/tests/src/stdlib/Stdlib_TypedArrayTests.res @@ -11,10 +11,10 @@ let num3 = BigInt.fromStringOrThrow("555555555") let assertTrue = (message, predicate) => { try { if !predicate() { - message->Error.make->Error.raise + message->JsError.make->JsError.throw } } catch { - | _ => message->Error.make->Error.raise + | _ => message->JsError.make->JsError.throw } } @@ -26,7 +26,7 @@ let assertWillThrow = (message, f) => { | _ => didThrow := true } if didThrow.contents == false { - message->Error.make->Error.raise + message->JsError.make->JsError.throw } } @@ -37,34 +37,34 @@ let areSame = (x: bigint, y: bigint) => BigInt.toString(x) == BigInt.toString(y) // assertTrue("big ints if same then equal", () => num1 == num1) assertTrue("fromArray", () => - [num1, num2]->BigInt64Array.fromArray->BigInt64Array.get(1)->Option.getExn->areSame(num2) + [num1, num2]->BigInt64Array.fromArray->BigInt64Array.get(1)->Option.getOrThrow->areSame(num2) ) assertTrue("fromBuffer", () => { let x = ArrayBuffer.make(16)->BigInt64Array.fromBuffer x->BigInt64Array.set(1, num2) - x->BigInt64Array.get(1)->Option.getExn->areSame(num2) + x->BigInt64Array.get(1)->Option.getOrThrow->areSame(num2) }) assertWillThrow("fromBuffer when too short can throw when used", () => { let x = ArrayBuffer.make(1)->BigInt64Array.fromBuffer x->BigInt64Array.set(0, num1) - x->BigInt64Array.get(0)->Option.getExn->areSame(num1)->ignore + x->BigInt64Array.get(0)->Option.getOrThrow->areSame(num1)->ignore }) assertTrue("fromBufferWithRange", () => { - let x = ArrayBuffer.make(16)->BigInt64Array.fromBufferWithRange(~byteOffset=0, ~length=1) + let x = ArrayBuffer.make(16)->BigInt64Array.fromBuffer(~byteOffset=0, ~length=1) x->BigInt64Array.set(0, num1) - x->BigInt64Array.get(0)->Option.getExn->areSame(num1) + x->BigInt64Array.get(0)->Option.getOrThrow->areSame(num1) }) // assertWillThrow("testing", () => {"a"->Error.make->Error.raise}) // assertWillThrow("testing", () => {Console.log("f")}) assertWillThrow("fromBufferWithRange is unsafe, out of range", () => { - let x = ArrayBuffer.make(16)->BigInt64Array.fromBufferWithRange(~byteOffset=13, ~length=1) + let x = ArrayBuffer.make(16)->BigInt64Array.fromBuffer(~byteOffset=13, ~length=1) x->BigInt64Array.set(0, num1) - x->BigInt64Array.get(0)->Option.getExn->areSame(num1)->ignore + x->BigInt64Array.get(0)->Option.getOrThrow->areSame(num1)->ignore }) assertTrue("fromLength is NOT in bytes", () => { @@ -76,4 +76,4 @@ assertTrue("a typed array is a TypedArray.t through a coercion", () => { let x = BigInt64Array.fromLength(2) TypedArray.length(x :> TypedArray.t) == 2 }) -let o = BigInt64Array.fromArrayLikeOrIterableWithMap +let o = (x, map) => BigInt64Array.fromArrayLikeOrIterable(x, ~map) diff --git a/tests/tests/src/stdlib/Test.mjs b/tests/tests/src/stdlib/Test.mjs index c9d7517e67e..a813fc8d7c7 100644 --- a/tests/tests/src/stdlib/Test.mjs +++ b/tests/tests/src/stdlib/Test.mjs @@ -13,7 +13,7 @@ function print(value) { if (match === "object" || match === "bigint") { return Util.inspect(value); } else if (match === "string") { - return Stdlib_Option.getExn(JSON.stringify(value), undefined); + return Stdlib_Option.getOrThrow(JSON.stringify(value), undefined); } else { return String(value); } diff --git a/tests/tests/src/stdlib/Test.res b/tests/tests/src/stdlib/Test.res index ab6122a6329..29d153132e4 100644 --- a/tests/tests/src/stdlib/Test.res +++ b/tests/tests/src/stdlib/Test.res @@ -13,7 +13,7 @@ let dirname = %raw("new URL('.', import.meta.url).pathname") @val @module("util") external inspect: _ => string = "inspect" let print = value => switch Type.typeof(value) { - | #string => JSON.stringifyAny(value)->Option.getExn // uses " instead of ' + | #string => JSON.stringifyAny(value)->Option.getOrThrow // uses " instead of ' | #object | #bigint => inspect(value) | _ => String.make(value) } diff --git a/tests/tests/src/test_ari.mjs b/tests/tests/src/test_ari.mjs index 2302a330f5a..01a89c34eb3 100644 --- a/tests/tests/src/test_ari.mjs +++ b/tests/tests/src/test_ari.mjs @@ -47,22 +47,16 @@ let size = Stdlib_List.size; let head = Stdlib_List.head; -let headExn = Stdlib_List.headExn; - let headOrThrow = Stdlib_List.headOrThrow; let tail = Stdlib_List.tail; -let tailExn = Stdlib_List.tailExn; - let tailOrThrow = Stdlib_List.tailOrThrow; let add = Stdlib_List.add; let get = Stdlib_List.get; -let getExn = Stdlib_List.getExn; - let getOrThrow = Stdlib_List.getOrThrow; let make = Stdlib_List.make; @@ -71,8 +65,6 @@ let fromInitializer = Stdlib_List.fromInitializer; let shuffle = Stdlib_List.shuffle; -let toShuffled = Stdlib_List.toShuffled; - let drop = Stdlib_List.drop; let take = Stdlib_List.take; @@ -135,8 +127,6 @@ let compare = Stdlib_List.compare; let equal = Stdlib_List.equal; -let has = Stdlib_List.has; - let includes = Stdlib_List.includes; let find = Stdlib_List.find; @@ -151,14 +141,6 @@ let partition = Stdlib_List.partition; let unzip = Stdlib_List.unzip; -let getAssoc = Stdlib_List.getAssoc; - -let hasAssoc = Stdlib_List.hasAssoc; - -let removeAssoc = Stdlib_List.removeAssoc; - -let setAssoc = Stdlib_List.setAssoc; - let sort = Stdlib_List.sort; export { @@ -173,19 +155,15 @@ export { length, size, head, - headExn, headOrThrow, tail, - tailExn, tailOrThrow, add, get, - getExn, getOrThrow, make, fromInitializer, shuffle, - toShuffled, drop, take, splitAt, @@ -217,7 +195,6 @@ export { compareLength, compare, equal, - has, includes, find, filter, @@ -225,10 +202,6 @@ export { filterMap, partition, unzip, - getAssoc, - hasAssoc, - removeAssoc, - setAssoc, sort, } /* fff Not a pure module */ diff --git a/tests/tests/src/test_include.mjs b/tests/tests/src/test_include.mjs index 54748ab8254..177fe7bb631 100644 --- a/tests/tests/src/test_include.mjs +++ b/tests/tests/src/test_include.mjs @@ -37,22 +37,16 @@ let size = Stdlib_List.size; let head = Stdlib_List.head; -let headExn = Stdlib_List.headExn; - let headOrThrow = Stdlib_List.headOrThrow; let tail = Stdlib_List.tail; -let tailExn = Stdlib_List.tailExn; - let tailOrThrow = Stdlib_List.tailOrThrow; let add = Stdlib_List.add; let get = Stdlib_List.get; -let getExn = Stdlib_List.getExn; - let getOrThrow = Stdlib_List.getOrThrow; let make = Stdlib_List.make; @@ -61,8 +55,6 @@ let fromInitializer = Stdlib_List.fromInitializer; let shuffle = Stdlib_List.shuffle; -let toShuffled = Stdlib_List.toShuffled; - let drop = Stdlib_List.drop; let take = Stdlib_List.take; @@ -125,8 +117,6 @@ let compare = Stdlib_List.compare; let equal = Stdlib_List.equal; -let has = Stdlib_List.has; - let includes = Stdlib_List.includes; let find = Stdlib_List.find; @@ -141,14 +131,6 @@ let partition = Stdlib_List.partition; let unzip = Stdlib_List.unzip; -let getAssoc = Stdlib_List.getAssoc; - -let hasAssoc = Stdlib_List.hasAssoc; - -let removeAssoc = Stdlib_List.removeAssoc; - -let setAssoc = Stdlib_List.setAssoc; - let sort = Stdlib_List.sort; export { @@ -166,19 +148,15 @@ export { length, size, head, - headExn, headOrThrow, tail, - tailExn, tailOrThrow, add, get, - getExn, getOrThrow, make, fromInitializer, shuffle, - toShuffled, drop, take, splitAt, @@ -210,7 +188,6 @@ export { compareLength, compare, equal, - has, includes, find, filter, @@ -218,10 +195,6 @@ export { filterMap, partition, unzip, - getAssoc, - hasAssoc, - removeAssoc, - setAssoc, sort, } /* No side effect */ diff --git a/tests/tests/src/test_list.mjs b/tests/tests/src/test_list.mjs index 663f433dc61..aa0e07c15e6 100644 --- a/tests/tests/src/test_list.mjs +++ b/tests/tests/src/test_list.mjs @@ -1,6 +1,5 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; import * as Stdlib_List from "@rescript/runtime/lib/es6/Stdlib_List.mjs"; function length_aux(_len, _x) { @@ -23,37 +22,51 @@ function length(l) { function hd(x) { if (x !== 0) { return x.hd; - } else { - return Pervasives.failwith("hd"); } + throw { + RE_EXN_ID: "Failure", + _1: "hd", + Error: new Error() + }; } function tl(x) { if (x !== 0) { return x.tl; - } else { - return Pervasives.failwith("tl"); } + throw { + RE_EXN_ID: "Failure", + _1: "tl", + Error: new Error() + }; } function nth(l, n) { if (n < 0) { - return Pervasives.invalid_arg("List.nth"); + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.nth", + Error: new Error() + }; } let _l = l; let _n = n; while (true) { let n$1 = _n; let l$1 = _l; - if (l$1 === 0) { - return Pervasives.failwith("nth"); - } - if (n$1 === 0) { - return l$1.hd; + if (l$1 !== 0) { + if (n$1 === 0) { + return l$1.hd; + } + _n = n$1 - 1 | 0; + _l = l$1.tl; + continue; } - _n = n$1 - 1 | 0; - _l = l$1.tl; - continue; + throw { + RE_EXN_ID: "Failure", + _1: "nth", + Error: new Error() + }; }; } @@ -167,18 +180,25 @@ function fold_right(f, l, accu) { } function map2(f, l1, l2) { - if (l1 === 0) { + if (l1 !== 0) { if (l2 !== 0) { - return Pervasives.invalid_arg("List.map2"); - } else { - return /* [] */0; + let r = f(l1.hd, l2.hd); + return {hd: r, tl: map2(f, l1.tl, l2.tl)}; } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.map2", + Error: new Error() + }; } if (l2 === 0) { - return Pervasives.invalid_arg("List.map2"); + return /* [] */0; } - let r = f(l1.hd, l2.hd); - return {hd: r, tl: map2(f, l1.tl, l2.tl)}; + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.map2", + Error: new Error() + }; } function rev_map2(f, l1, l2) { @@ -189,20 +209,27 @@ function rev_map2(f, l1, l2) { let l2$1 = _l2; let l1$1 = _l1; let accu = _accu; - if (l1$1 === 0) { + if (l1$1 !== 0) { if (l2$1 !== 0) { - return Pervasives.invalid_arg("List.rev_map2"); - } else { - return accu; + _l2 = l2$1.tl; + _l1 = l1$1.tl; + _accu = {hd: f(l1$1.hd, l2$1.hd), tl: accu}; + continue; } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.rev_map2", + Error: new Error() + }; } - if (l2$1 === 0) { - return Pervasives.invalid_arg("List.rev_map2"); + if (l2$1 !== 0) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.rev_map2", + Error: new Error() + }; } - _l2 = l2$1.tl; - _l1 = l1$1.tl; - _accu = {hd: f(l1$1.hd, l2$1.hd), tl: accu}; - continue; + return accu; }; } @@ -210,20 +237,27 @@ function iter2(f, _l1, _l2) { while (true) { let l2 = _l2; let l1 = _l1; - if (l1 === 0) { + if (l1 !== 0) { if (l2 !== 0) { - return Pervasives.invalid_arg("List.iter2"); - } else { - return; + f(l1.hd, l2.hd); + _l2 = l2.tl; + _l1 = l1.tl; + continue; } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.iter2", + Error: new Error() + }; } if (l2 === 0) { - return Pervasives.invalid_arg("List.iter2"); + return; } - f(l1.hd, l2.hd); - _l2 = l2.tl; - _l1 = l1.tl; - continue; + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.iter2", + Error: new Error() + }; }; } @@ -232,20 +266,27 @@ function fold_left2(f, _accu, _l1, _l2) { let l2 = _l2; let l1 = _l1; let accu = _accu; - if (l1 === 0) { + if (l1 !== 0) { if (l2 !== 0) { - return Pervasives.invalid_arg("List.fold_left2"); - } else { - return accu; + _l2 = l2.tl; + _l1 = l1.tl; + _accu = f(accu, l1.hd, l2.hd); + continue; } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.fold_left2", + Error: new Error() + }; } - if (l2 === 0) { - return Pervasives.invalid_arg("List.fold_left2"); + if (l2 !== 0) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.fold_left2", + Error: new Error() + }; } - _l2 = l2.tl; - _l1 = l1.tl; - _accu = f(accu, l1.hd, l2.hd); - continue; + return accu; }; } @@ -253,14 +294,21 @@ function fold_right2(f, l1, l2, accu) { if (l1 !== 0) { if (l2 !== 0) { return f(l1.hd, l2.hd, fold_right2(f, l1.tl, l2.tl, accu)); - } else { - return Pervasives.invalid_arg("List.fold_right2"); } - } else if (l2 !== 0) { - return Pervasives.invalid_arg("List.fold_right2"); - } else { - return accu; + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.fold_right2", + Error: new Error() + }; } + if (l2 !== 0) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.fold_right2", + Error: new Error() + }; + } + return accu; } function for_all(p, _x) { @@ -295,22 +343,29 @@ function for_all2(p, _l1, _l2) { while (true) { let l2 = _l2; let l1 = _l1; - if (l1 === 0) { + if (l1 !== 0) { if (l2 !== 0) { - return Pervasives.invalid_arg("List.for_all2"); - } else { - return true; + if (!p(l1.hd, l2.hd)) { + return false; + } + _l2 = l2.tl; + _l1 = l1.tl; + continue; } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.for_all2", + Error: new Error() + }; } if (l2 === 0) { - return Pervasives.invalid_arg("List.for_all2"); - } - if (!p(l1.hd, l2.hd)) { - return false; + return true; } - _l2 = l2.tl; - _l1 = l1.tl; - continue; + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.for_all2", + Error: new Error() + }; }; } @@ -318,22 +373,29 @@ function exists2(p, _l1, _l2) { while (true) { let l2 = _l2; let l1 = _l1; - if (l1 === 0) { + if (l1 !== 0) { if (l2 !== 0) { - return Pervasives.invalid_arg("List.exists2"); - } else { - return false; + if (p(l1.hd, l2.hd)) { + return true; + } + _l2 = l2.tl; + _l1 = l1.tl; + continue; } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.exists2", + Error: new Error() + }; } if (l2 === 0) { - return Pervasives.invalid_arg("List.exists2"); - } - if (p(l1.hd, l2.hd)) { - return true; + return false; } - _l2 = l2.tl; - _l1 = l1.tl; - continue; + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.exists2", + Error: new Error() + }; }; } @@ -545,14 +607,21 @@ function combine(l1, l2) { l1.hd, l2.hd ], tl: combine(l1.tl, l2.tl)}; - } else { - return Pervasives.invalid_arg("List.combine"); } - } else if (l2 !== 0) { - return Pervasives.invalid_arg("List.combine"); - } else { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.combine", + Error: new Error() + }; + } + if (l2 === 0) { return /* [] */0; } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.combine", + Error: new Error() + }; } function merge(cmp, l1, l2) { diff --git a/tests/tests/src/test_list.res b/tests/tests/src/test_list.res index 3a069901340..73dd1e3079e 100644 --- a/tests/tests/src/test_list.res +++ b/tests/tests/src/test_list.res @@ -24,23 +24,23 @@ let length = l => length_aux(0, l) let hd = x => switch x { - | list{} => failwith("hd") + | list{} => throw(Failure("hd")) | list{a, ...l} => a } let tl = x => switch x { - | list{} => failwith("tl") + | list{} => throw(Failure("tl")) | list{a, ...l} => l } let nth = (l, n) => if n < 0 { - invalid_arg("List.nth") + throw(Invalid_argument("List.nth")) } else { let rec nth_aux = (l, n) => switch l { - | list{} => failwith("nth") + | list{} => throw(Failure("nth")) | list{a, ...l} => if n == 0 { a @@ -133,7 +133,7 @@ let rec map2 = (f, l1, l2) => | (list{a1, ...l1}, list{a2, ...l2}) => let r = f(a1, a2) list{r, ...map2(f, l1, l2)} - | (_, _) => invalid_arg("List.map2") + | (_, _) => throw(Invalid_argument("List.map2")) } let rev_map2 = (f, l1, l2) => { @@ -141,7 +141,7 @@ let rev_map2 = (f, l1, l2) => { switch (l1, l2) { | (list{}, list{}) => accu | (list{a1, ...l1}, list{a2, ...l2}) => rmap2_f(list{f(a1, a2), ...accu}, l1, l2) - | (_, _) => invalid_arg("List.rev_map2") + | (_, _) => throw(Invalid_argument("List.rev_map2")) } rmap2_f(list{}, l1, l2) @@ -153,21 +153,21 @@ let rec iter2 = (f, l1, l2) => | (list{a1, ...l1}, list{a2, ...l2}) => f(a1, a2) iter2(f, l1, l2) - | (_, _) => invalid_arg("List.iter2") + | (_, _) => throw(Invalid_argument("List.iter2")) } let rec fold_left2 = (f, accu, l1, l2) => switch (l1, l2) { | (list{}, list{}) => accu | (list{a1, ...l1}, list{a2, ...l2}) => fold_left2(f, f(accu, a1, a2), l1, l2) - | (_, _) => invalid_arg("List.fold_left2") + | (_, _) => throw(Invalid_argument("List.fold_left2")) } let rec fold_right2 = (f, l1, l2, accu) => switch (l1, l2) { | (list{}, list{}) => accu | (list{a1, ...l1}, list{a2, ...l2}) => f(a1, a2, fold_right2(f, l1, l2, accu)) - | (_, _) => invalid_arg("List.fold_right2") + | (_, _) => throw(Invalid_argument("List.fold_right2")) } let rec for_all = (p, x) => @@ -186,14 +186,14 @@ let rec for_all2 = (p, l1, l2) => switch (l1, l2) { | (list{}, list{}) => true | (list{a1, ...l1}, list{a2, ...l2}) => p(a1, a2) && for_all2(p, l1, l2) - | (_, _) => invalid_arg("List.for_all2") + | (_, _) => throw(Invalid_argument("List.for_all2")) } let rec exists2 = (p, l1, l2) => switch (l1, l2) { | (list{}, list{}) => false | (list{a1, ...l1}, list{a2, ...l2}) => p(a1, a2) || exists2(p, l1, l2) - | (_, _) => invalid_arg("List.exists2") + | (_, _) => throw(Invalid_argument("List.exists2")) } let rec mem = (x, x_) => @@ -317,7 +317,7 @@ let rec combine = (l1, l2) => switch (l1, l2) { | (list{}, list{}) => list{} | (list{a1, ...l1}, list{a2, ...l2}) => list{(a1, a2), ...combine(l1, l2)} - | (_, _) => invalid_arg("List.combine") + | (_, _) => throw(Invalid_argument("List.combine")) } /* sorting */ diff --git a/tests/tests/src/test_pervasive.mjs b/tests/tests/src/test_pervasive.mjs index 7181f30f136..2f5e68a81e9 100644 --- a/tests/tests/src/test_pervasive.mjs +++ b/tests/tests/src/test_pervasive.mjs @@ -1,25 +1,20 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; import * as Stdlib_List from "@rescript/runtime/lib/es6/Stdlib_List.mjs"; -let Pervasives$1 = { +let Pervasives = { length: Stdlib_List.length, size: Stdlib_List.size, head: Stdlib_List.head, - headExn: Stdlib_List.headExn, headOrThrow: Stdlib_List.headOrThrow, tail: Stdlib_List.tail, - tailExn: Stdlib_List.tailExn, tailOrThrow: Stdlib_List.tailOrThrow, add: Stdlib_List.add, get: Stdlib_List.get, - getExn: Stdlib_List.getExn, getOrThrow: Stdlib_List.getOrThrow, make: Stdlib_List.make, fromInitializer: Stdlib_List.fromInitializer, shuffle: Stdlib_List.shuffle, - toShuffled: Stdlib_List.toShuffled, drop: Stdlib_List.drop, take: Stdlib_List.take, splitAt: Stdlib_List.splitAt, @@ -50,7 +45,6 @@ let Pervasives$1 = { some2: Stdlib_List.some2, compareLength: Stdlib_List.compareLength, equal: Stdlib_List.equal, - has: Stdlib_List.has, includes: Stdlib_List.includes, find: Stdlib_List.find, filter: Stdlib_List.filter, @@ -58,14 +52,7 @@ let Pervasives$1 = { filterMap: Stdlib_List.filterMap, partition: Stdlib_List.partition, unzip: Stdlib_List.unzip, - getAssoc: Stdlib_List.getAssoc, - hasAssoc: Stdlib_List.hasAssoc, - removeAssoc: Stdlib_List.removeAssoc, - setAssoc: Stdlib_List.setAssoc, - sort: Stdlib_List.sort, - failwith: Pervasives.failwith, - invalid_arg: Pervasives.invalid_arg, - Exit: Pervasives.Exit + sort: Stdlib_List.sort }; function a0(prim) { @@ -149,7 +136,7 @@ let f = Stdlib_List.concat; let Pervasives$make = Stdlib_List.make; export { - Pervasives$1 as Pervasives, + Pervasives, f, a0, a1, diff --git a/tests/tests/src/test_pervasives3.mjs b/tests/tests/src/test_pervasives3.mjs index 94b27cd07fa..0a97c96b884 100644 --- a/tests/tests/src/test_pervasives3.mjs +++ b/tests/tests/src/test_pervasives3.mjs @@ -1,80 +1,15 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; import * as Stdlib_List from "@rescript/runtime/lib/es6/Stdlib_List.mjs"; -let Pervasives$1 = { - failwith: Pervasives.failwith, - invalid_arg: Pervasives.invalid_arg, - Exit: Pervasives.Exit, - length: Stdlib_List.length, - size: Stdlib_List.size, - head: Stdlib_List.head, - headExn: Stdlib_List.headExn, - headOrThrow: Stdlib_List.headOrThrow, - tail: Stdlib_List.tail, - tailExn: Stdlib_List.tailExn, - tailOrThrow: Stdlib_List.tailOrThrow, - add: Stdlib_List.add, - get: Stdlib_List.get, - getExn: Stdlib_List.getExn, - getOrThrow: Stdlib_List.getOrThrow, - make: Stdlib_List.make, - fromInitializer: Stdlib_List.fromInitializer, - shuffle: Stdlib_List.shuffle, - toShuffled: Stdlib_List.toShuffled, - drop: Stdlib_List.drop, - take: Stdlib_List.take, - splitAt: Stdlib_List.splitAt, - concat: Stdlib_List.concat, - concatMany: Stdlib_List.concatMany, - reverseConcat: Stdlib_List.reverseConcat, - flat: Stdlib_List.flat, - map: Stdlib_List.map, - zip: Stdlib_List.zip, - zipBy: Stdlib_List.zipBy, - mapWithIndex: Stdlib_List.mapWithIndex, - fromArray: Stdlib_List.fromArray, - toArray: Stdlib_List.toArray, - reverse: Stdlib_List.reverse, - mapReverse: Stdlib_List.mapReverse, - forEach: Stdlib_List.forEach, - forEachWithIndex: Stdlib_List.forEachWithIndex, - reduce: Stdlib_List.reduce, - reduceWithIndex: Stdlib_List.reduceWithIndex, - reduceReverse: Stdlib_List.reduceReverse, - mapReverse2: Stdlib_List.mapReverse2, - forEach2: Stdlib_List.forEach2, - reduce2: Stdlib_List.reduce2, - reduceReverse2: Stdlib_List.reduceReverse2, - every: Stdlib_List.every, - some: Stdlib_List.some, - every2: Stdlib_List.every2, - some2: Stdlib_List.some2, - compareLength: Stdlib_List.compareLength, - compare: Stdlib_List.compare, - equal: Stdlib_List.equal, - has: Stdlib_List.has, - includes: Stdlib_List.includes, - find: Stdlib_List.find, - filter: Stdlib_List.filter, - filterWithIndex: Stdlib_List.filterWithIndex, - filterMap: Stdlib_List.filterMap, - partition: Stdlib_List.partition, - unzip: Stdlib_List.unzip, - getAssoc: Stdlib_List.getAssoc, - hasAssoc: Stdlib_List.hasAssoc, - removeAssoc: Stdlib_List.removeAssoc, - setAssoc: Stdlib_List.setAssoc, - sort: Stdlib_List.sort -}; +let Pervasives = Stdlib_List; let v = Stdlib_List.concat; let Pervasives$make = Stdlib_List.make; export { - Pervasives$1 as Pervasives, + Pervasives, v, Pervasives$make, } diff --git a/tests/tests/src/test_set.mjs b/tests/tests/src/test_set.mjs index 87b05c6c5a7..da4bc6be8f2 100644 --- a/tests/tests/src/test_set.mjs +++ b/tests/tests/src/test_set.mjs @@ -1,6 +1,5 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; import * as Stdlib_List from "@rescript/runtime/lib/es6/Stdlib_List.mjs"; function Make(Ord) { @@ -31,18 +30,26 @@ function Make(Ord) { hr = typeof r !== "object" ? 0 : r._3; if (hl > (hr + 2 | 0)) { if (typeof l !== "object") { - return Pervasives.invalid_arg("Set.bal"); + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Set.bal", + Error: new Error() + }; } let lr = l._2; let lv = l._1; let ll = l._0; if (height(ll) >= height(lr)) { return create(ll, lv, create(lr, v, r)); - } else if (typeof lr !== "object") { - return Pervasives.invalid_arg("Set.bal"); - } else { + } + if (typeof lr === "object") { return create(create(ll, lv, lr._0), lr._1, create(lr._2, v, r)); } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Set.bal", + Error: new Error() + }; } if (hr <= (hl + 2 | 0)) { return { @@ -54,18 +61,26 @@ function Make(Ord) { }; } if (typeof r !== "object") { - return Pervasives.invalid_arg("Set.bal"); + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Set.bal", + Error: new Error() + }; } let rr = r._2; let rv = r._1; let rl = r._0; if (height(rr) >= height(rl)) { return create(create(l, v, rl), rv, rr); - } else if (typeof rl !== "object") { - return Pervasives.invalid_arg("Set.bal"); - } else { + } + if (typeof rl === "object") { return create(create(l, v, rl._0), rl._1, create(rl._2, rv, rr)); } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Set.bal", + Error: new Error() + }; }; let add = (x, x_) => { if (typeof x_ !== "object") { @@ -163,7 +178,11 @@ function Make(Ord) { }; let remove_min_elt = x => { if (typeof x !== "object") { - return Pervasives.invalid_arg("Set.remove_min_elt"); + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Set.remove_min_elt", + Error: new Error() + }; } let l = x._0; if (typeof l !== "object") { diff --git a/tests/tests/src/test_set.res b/tests/tests/src/test_set.res index 39f5942a459..78ed5e19994 100644 --- a/tests/tests/src/test_set.res +++ b/tests/tests/src/test_set.res @@ -104,26 +104,26 @@ module Make = (Ord: OrderedType) => { } if hl > hr + 2 { switch l { - | Empty => invalid_arg("Set.bal") + | Empty => throw(Invalid_argument("Set.bal")) | Node(ll, lv, lr, _) => if height(ll) >= height(lr) { create(ll, lv, create(lr, v, r)) } else { switch lr { - | Empty => invalid_arg("Set.bal") + | Empty => throw(Invalid_argument("Set.bal")) | Node(lrl, lrv, lrr, _) => create(create(ll, lv, lrl), lrv, create(lrr, v, r)) } } } } else if hr > hl + 2 { switch r { - | Empty => invalid_arg("Set.bal") + | Empty => throw(Invalid_argument("Set.bal")) | Node(rl, rv, rr, _) => if height(rr) >= height(rl) { create(create(l, v, rl), rv, rr) } else { switch rl { - | Empty => invalid_arg("Set.bal") + | Empty => throw(Invalid_argument("Set.bal")) | Node(rll, rlv, rlr, _) => create(create(l, v, rll), rlv, create(rlr, rv, rr)) } } @@ -216,7 +216,7 @@ module Make = (Ord: OrderedType) => { let rec remove_min_elt = x => switch x { - | Empty => invalid_arg("Set.remove_min_elt") + | Empty => throw(Invalid_argument("Set.remove_min_elt")) | Node(Empty, v, r, _) => r | Node(l, v, r, _) => bal(remove_min_elt(l), v, r) } diff --git a/tests/tests/src/topsort_test.mjs b/tests/tests/src/topsort_test.mjs index 2a17f2d4c35..53aa6315b52 100644 --- a/tests/tests/src/topsort_test.mjs +++ b/tests/tests/src/topsort_test.mjs @@ -49,7 +49,7 @@ function dfs1(_nodes, graph, _visited) { } let xs = nodes.tl; let x = nodes.hd; - if (Stdlib_List.has(visited, x, (prim0, prim1) => prim0 === prim1)) { + if (Stdlib_List.some(visited, y => y === x)) { _nodes = xs; continue; } @@ -99,7 +99,7 @@ function dfs2(nodes, graph, visited) { } let xs = nodes.tl; let x = nodes.hd; - if (Stdlib_List.has(visited, x, (prim0, prim1) => prim0 === prim1)) { + if (Stdlib_List.some(visited, y => y === x)) { _nodes = xs; continue; } @@ -141,7 +141,7 @@ if (!Primitive_object.equal(dfs2({hd: "b", tl: /* [] */0}, {hd: [ function dfs3(nodes, graph) { let visited = /* [] */0; let aux = (node, graph) => { - if (Stdlib_List.has(visited, node, (prim0, prim1) => prim0 === prim1)) { + if (Stdlib_List.some(visited, y => y === node)) { return; } visited = {hd: node, tl: visited}; @@ -201,7 +201,7 @@ let grwork = {hd: [ function unsafe_topsort(graph) { let visited = /* [] */0; let sort_node = node => { - if (Stdlib_List.has(visited, node, (prim0, prim1) => prim0 === prim1)) { + if (Stdlib_List.some(visited, y => y === node)) { return; } let nodes = nexts(node, graph); @@ -229,7 +229,7 @@ let Cycle = /* @__PURE__ */Primitive_exceptions.create("Topsort_test.Cycle"); function pathsort(graph) { let visited = /* [] */0; let $plus$great = (node, path) => { - if (Stdlib_List.has(path, node, (prim0, prim1) => prim0 === prim1)) { + if (Stdlib_List.some(path, y => y === node)) { throw { RE_EXN_ID: Cycle, _1: {hd: node, tl: path}, @@ -240,7 +240,7 @@ function pathsort(graph) { }; let sort_nodes = (path, nodes) => Stdlib_List.forEach(nodes, node => sort_node(path, node)); let sort_node = (path, node) => { - if (Stdlib_List.has(visited, node, (prim0, prim1) => prim0 === prim1)) { + if (Stdlib_List.some(visited, y => y === node)) { return; } sort_nodes($plus$great(node, path), nexts(node, graph)); diff --git a/tests/tests/src/topsort_test.res b/tests/tests/src/topsort_test.res index 14a822caf93..2b1e9b12924 100644 --- a/tests/tests/src/topsort_test.res +++ b/tests/tests/src/topsort_test.res @@ -24,7 +24,7 @@ let rec dfs1 = (nodes, graph, visited) => switch nodes { | list{} => List.reverse(visited) | list{x, ...xs} => - if visited->List.has(x, \"==") { + if visited->List.some(y => y == x) { dfs1(xs, graph, visited) } else { Console.log(x) @@ -44,7 +44,7 @@ let rec dfs2 = (nodes, graph, visited) => { switch nodes { | list{} => visited | list{x, ...xs} => - if visited->List.has(x, \"==") { + if visited->List.some(y => y == x) { aux(xs, graph, visited) } else { aux(xs, graph, aux(nexts(x, graph), graph, list{x, ...visited})) @@ -62,7 +62,7 @@ let () = { let dfs3 = (nodes, graph) => { let visited = ref(list{}) let rec aux = (node, graph) => - if !List.has(visited.contents, node, \"==") { + if !List.some(visited.contents, y => y == node) { visited := list{node, ...visited.contents} nexts(node, graph)->List.forEach(x => aux(x, graph)) } @@ -93,7 +93,7 @@ let unsafe_topsort = graph => { let visited = ref(list{}) let rec sort_nodes = nodes => nodes->List.forEach(node => sort_node(node)) and sort_node = node => - if !List.has(visited.contents, node, \"==") { + if !List.some(visited.contents, y => y == node) { /* This check does not prevent cycle , but it is still necessary? yes! since a node can have multiple parents @@ -117,7 +117,7 @@ let pathsort = graph => { let visited = ref(list{}) let empty_path = list{} let \"+>" = (node, path) => - if List.has(path, node, \"==") { + if List.some(path, y => y == node) { throw(Cycle(list{node, ...path})) } else { list{node, ...path} @@ -125,7 +125,7 @@ let pathsort = graph => { let rec sort_nodes = (path, nodes) => nodes->List.forEach(node => sort_node(path, node)) and sort_node = (path, node) => - if !List.has(visited.contents, node, \"==") { + if !List.some(visited.contents, y => y == node) { /* check node path ; */ sort_nodes(\"+>"(node, path), nexts(node, graph)) /* different from dfs, recorded after its diff --git a/tests/tests/src/unsafe_ppx_test.mjs b/tests/tests/src/unsafe_ppx_test.mjs index 4e94c29395c..8884aa100f9 100644 --- a/tests/tests/src/unsafe_ppx_test.mjs +++ b/tests/tests/src/unsafe_ppx_test.mjs @@ -1,7 +1,6 @@ // Generated by ReScript, PLEASE EDIT WITH CARE import * as Mocha from "mocha"; -import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; import * as Test_utils from "./test_utils.mjs"; import * as Ffi_js_test from "./ffi_js_test.mjs"; @@ -23,7 +22,13 @@ function g(a) { return "" }); let regression2 = Math.max; - regression(a, Pervasives.failwith); + regression(a, s => { + throw { + RE_EXN_ID: "Failure", + _1: s, + Error: new Error() + }; + }); regression2(3, 2); regression3(3, 2); regression4(3, x => x); diff --git a/tests/tests/src/unsafe_ppx_test.res b/tests/tests/src/unsafe_ppx_test.res index 37e0bdb3f78..c98e97331a9 100644 --- a/tests/tests/src/unsafe_ppx_test.res +++ b/tests/tests/src/unsafe_ppx_test.res @@ -20,7 +20,7 @@ let g = a => { }`) let regression2: (float, float) => float = %raw("Math.max") - ignore(regression(a, failwith)) + ignore(regression(a, s => throw(Failure(s)))) ignore(regression2(3., 2.)) ignore(regression3(3., 2.)) ignore(regression4(3., x => x)) From 7b0ea27facbcef9a78811ce573a328a4970632f3 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Mon, 26 Oct 2026 10:10:22 +0000 Subject: [PATCH 4/4] Patch the test repo's bindings for the removed stdlib APIs rescript-nodejs 17.0.0 and rescript-bun 2.1.0, the latest releases, call failwith and catch Exn.Error, so the rewatch test repo stopped compiling. Yarn patches replace them with throw(Failure(...)) and JsExn, which v12 accepts as well. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01FrejUgZbjj4wX44oqa67V5 Signed-off-by: Christoph Knittel --- .../rescript-bun-npm-2.1.0-d9adc91a04.patch | 36 +++++++++++++++++++ ...escript-nodejs-npm-17.0.0-stdlib-v13.patch | 24 +++++++++++++ .../packages/with-dev-deps/package.json | 2 +- .../testrepo/packages/with-ppx/package.json | 2 +- rewatch/testrepo/yarn.lock | 15 +++++--- 5 files changed, 73 insertions(+), 6 deletions(-) create mode 100644 rewatch/testrepo/.yarn/patches/rescript-nodejs-npm-17.0.0-stdlib-v13.patch diff --git a/rewatch/testrepo/.yarn/patches/rescript-bun-npm-2.1.0-d9adc91a04.patch b/rewatch/testrepo/.yarn/patches/rescript-bun-npm-2.1.0-d9adc91a04.patch index c0cb5691a85..2fb3c687692 100644 --- a/rewatch/testrepo/.yarn/patches/rescript-bun-npm-2.1.0-d9adc91a04.patch +++ b/rewatch/testrepo/.yarn/patches/rescript-bun-npm-2.1.0-d9adc91a04.patch @@ -240,3 +240,39 @@ index 76d8dd579740d5a1b0d21b2818093b06061f031f..b6e40acd97b1e52b44a18725619da86e - // external setInterval: (int, 'a) => Js.Promise.t<'a> = "setTimeout" + // external setInterval: (int, 'a) => promise<'a> = "setTimeout" } +diff --git a/src/BunSqlite.res b/src/BunSqlite.res +--- a/src/BunSqlite.res ++++ b/src/BunSqlite.res +@@ -66,7 +66,7 @@ + + ```rescript + let users = switch db->Database.query("SELECT * FROM users WHERE age > :age")->Statement.all({"age": 90}) { +- | exception Exn.Error(e) => Error(#DatabaseFailed) ++ | exception JsExn(e) => Error(#DatabaseFailed) + | [] => Error(#NoUsersFound) + | users => Ok(users->usersFromJson) + } +diff --git a/src/Errors.res b/src/Errors.res +--- a/src/Errors.res ++++ b/src/Errors.res +@@ -220,7 +220,7 @@ + + let classifyExn: JsExn.t => case = value => + switch classifyOpt(value) { +- | None => failwith("Unknown data type") ++ | None => throw(Failure("Unknown data type")) + | Some(err) => err + } + +diff --git a/src/StringBuffer.res b/src/StringBuffer.res +--- a/src/StringBuffer.res ++++ b/src/StringBuffer.res +@@ -22,7 +22,7 @@ + } else if Buffer.isBuffer(value) { + Buffer(Obj.magic(value)) + } else { +- failwith("Unknown data type") ++ throw(Failure("Unknown data type")) + } + + let classify = value => diff --git a/rewatch/testrepo/.yarn/patches/rescript-nodejs-npm-17.0.0-stdlib-v13.patch b/rewatch/testrepo/.yarn/patches/rescript-nodejs-npm-17.0.0-stdlib-v13.patch new file mode 100644 index 00000000000..c85364ba9f6 --- /dev/null +++ b/rewatch/testrepo/.yarn/patches/rescript-nodejs-npm-17.0.0-stdlib-v13.patch @@ -0,0 +1,24 @@ +diff --git a/src/Errors.res b/src/Errors.res +--- a/src/Errors.res ++++ b/src/Errors.res +@@ -220,7 +220,7 @@ + + let classifyExn: JsExn.t => case = value => + switch classifyOpt(value) { +- | None => failwith("Unknown data type") ++ | None => throw(Failure("Unknown data type")) + | Some(err) => err + } + +diff --git a/src/StringBuffer.res b/src/StringBuffer.res +--- a/src/StringBuffer.res ++++ b/src/StringBuffer.res +@@ -22,7 +22,7 @@ + } else if Buffer.isBuffer(value) { + Buffer(Obj.magic(value)) + } else { +- failwith("Unknown data type") ++ throw(Failure("Unknown data type")) + } + + let classify = value => diff --git a/rewatch/testrepo/packages/with-dev-deps/package.json b/rewatch/testrepo/packages/with-dev-deps/package.json index 160c569034c..14fb94bcc93 100644 --- a/rewatch/testrepo/packages/with-dev-deps/package.json +++ b/rewatch/testrepo/packages/with-dev-deps/package.json @@ -10,6 +10,6 @@ "@rescript/webapi": "patch:@rescript/webapi@npm%3A0.1.0-experimental-73e6a0d#~/.yarn/patches/@rescript-webapi-npm-0.1.0-experimental-73e6a0d-288a2072f7.patch" }, "dependencies": { - "rescript-nodejs": "17.0.0" + "rescript-nodejs": "patch:rescript-nodejs@npm%3A17.0.0#~/.yarn/patches/rescript-nodejs-npm-17.0.0-stdlib-v13.patch" } } diff --git a/rewatch/testrepo/packages/with-ppx/package.json b/rewatch/testrepo/packages/with-ppx/package.json index 42daade8995..28cf4fa0d77 100644 --- a/rewatch/testrepo/packages/with-ppx/package.json +++ b/rewatch/testrepo/packages/with-ppx/package.json @@ -7,7 +7,7 @@ "author": "", "license": "MIT", "dependencies": { - "rescript-nodejs": "17.0.0", + "rescript-nodejs": "patch:rescript-nodejs@npm%3A17.0.0#~/.yarn/patches/rescript-nodejs-npm-17.0.0-stdlib-v13.patch", "sury": "11.0.0-rc.0", "sury-ppx": "11.0.0-rc.0" } diff --git a/rewatch/testrepo/yarn.lock b/rewatch/testrepo/yarn.lock index 2dbf4d87f53..2282d151866 100644 --- a/rewatch/testrepo/yarn.lock +++ b/rewatch/testrepo/yarn.lock @@ -208,7 +208,7 @@ __metadata: resolution: "@testrepo/with-dev-deps@workspace:packages/with-dev-deps" dependencies: "@rescript/webapi": "patch:@rescript/webapi@npm%3A0.1.0-experimental-73e6a0d#~/.yarn/patches/@rescript-webapi-npm-0.1.0-experimental-73e6a0d-288a2072f7.patch" - rescript-nodejs: "npm:17.0.0" + rescript-nodejs: "patch:rescript-nodejs@npm%3A17.0.0#~/.yarn/patches/rescript-nodejs-npm-17.0.0-stdlib-v13.patch" languageName: unknown linkType: soft @@ -216,7 +216,7 @@ __metadata: version: 0.0.0-use.local resolution: "@testrepo/with-ppx@workspace:packages/with-ppx" dependencies: - rescript-nodejs: "npm:17.0.0" + rescript-nodejs: "patch:rescript-nodejs@npm%3A17.0.0#~/.yarn/patches/rescript-nodejs-npm-17.0.0-stdlib-v13.patch" sury: "npm:11.0.0-rc.0" sury-ppx: "npm:11.0.0-rc.0" languageName: unknown @@ -233,10 +233,10 @@ __metadata: "rescript-bun@patch:rescript-bun@npm%3A2.1.0#~/.yarn/patches/rescript-bun-npm-2.1.0-d9adc91a04.patch": version: 2.1.0 - resolution: "rescript-bun@patch:rescript-bun@npm%3A2.1.0#~/.yarn/patches/rescript-bun-npm-2.1.0-d9adc91a04.patch::version=2.1.0&hash=cc7d77" + resolution: "rescript-bun@patch:rescript-bun@npm%3A2.1.0#~/.yarn/patches/rescript-bun-npm-2.1.0-d9adc91a04.patch::version=2.1.0&hash=422c2f" peerDependencies: rescript: ">= 12.0.0-alpha.4" - checksum: 10c0/e58a68cc5cc0b3aef0198ad44ad80535f962c4a50d1085b9aaa2d8454fa4203907aa2b4e14939e909778b0c52ba6767175469ec51ddc5238d2674fe6d65f6a79 + checksum: 10c0/aec846f87d07e4433bf3060abcaaae896d2c48e21f7c1f97bdb60733f9ccf458f4b0eeef75906d22638099689fe1faaa9fbb6ae5c039458f1967f9712137e9f5 languageName: node linkType: hard @@ -247,6 +247,13 @@ __metadata: languageName: node linkType: hard +"rescript-nodejs@patch:rescript-nodejs@npm%3A17.0.0#~/.yarn/patches/rescript-nodejs-npm-17.0.0-stdlib-v13.patch": + version: 17.0.0 + resolution: "rescript-nodejs@patch:rescript-nodejs@npm%3A17.0.0#~/.yarn/patches/rescript-nodejs-npm-17.0.0-stdlib-v13.patch::version=17.0.0&hash=121416" + checksum: 10c0/31def0dda716c3803ef3f35ba51cfd7d5f214d3cec0a7e06202690725ffb4ea7eeee9ca465cee09b7538d31ac17a258c60ebfe0f5c2fda2d06f86625b0f3e711 + languageName: node + linkType: hard + "rescript@npm:12.0.0": version: 12.0.0 resolution: "rescript@npm:12.0.0"