Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion analysis/reanalyze/src/exn.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion analysis/reanalyze/src/exn.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
65 changes: 10 additions & 55 deletions analysis/reanalyze/src/exn_lib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand All @@ -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 =
[
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion analysis/src/completion_back_end.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
[
Expand Down
1 change: 1 addition & 0 deletions changes/remove-v12-deprecated-stdlib.breaking.md
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 0 additions & 6 deletions compiler/core/lam_analysis.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 .. *)

Expand Down
3 changes: 1 addition & 2 deletions compiler/gentype/translate_type_expr_from_types.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 0 additions & 6 deletions packages/@rescript/runtime/JsxDOM.res
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,6 @@ type domProps = {
baselineShift?: string,
bbox?: string,
begin?: string,
@deprecated("Please use begin")
begin_?: string,
bias?: string,
by?: string,
calcMode?: string,
Expand Down Expand Up @@ -406,8 +404,6 @@ type domProps = {
elevation?: string,
enableBackground?: string,
end?: string,
@deprecated("Please use end")
end_?: string,
exponent?: string,
externalResourcesRequired?: string,
fill?: string,
Expand Down Expand Up @@ -555,8 +551,6 @@ type domProps = {
textLength?: string,
textRendering?: string,
to?: string,
@deprecated("Please use to")
to_?: string,
transform?: string,
u1?: string,
u2?: string,
Expand Down
14 changes: 0 additions & 14 deletions packages/@rescript/runtime/Pervasives.res
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 1 addition & 7 deletions packages/@rescript/runtime/Stdlib.res
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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) => {
Expand Down
62 changes: 1 addition & 61 deletions packages/@rescript/runtime/Stdlib_Array.res
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,16 @@ 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<string> = "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) =>
if length <= 0 {
[]
} else {
let arr = makeUninitializedUnsafe(length)
arr->fillAll(x)
arr->fill(x)
arr
}

Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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) => string = "join"

@deprecated({
reason: "Use `join` instead",
migrate: Array.join(),
})
@send
external joinWith: (array<string>, 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"

Expand Down
Loading
Loading