diff --git a/CHANGELOG.md b/CHANGELOG.md index e6d250c84c..128fcf744d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ #### :house: Internal +- Remove dead compiler code: warning 24, the `J.String_index` JS IR node, the `Pisint` and `Parraysets` Lambda primitives with their unused `%` primitive names (`%obj_is_int`, `%obj_dup`, `%obj_field`, `%array_safe_set`, `%null_to_opt`, `%nullable_to_opt`), the no-op `-pp` bsc flag and unread `Clflags` fields (`-unsafe` stays accepted as an explicit no-op), and the unused `unit` slot of `Pexp_coerce`. https://github.com/rescript-lang/rescript/pull/8731 - Represent inline record definitions with an explicit parsetree origin while retaining the existing PPX wire representation. https://github.com/rescript-lang/rescript/pull/8686 - Make expression attributes immutable in the current parsetree, now that editor refactors construct new expression nodes. https://github.com/rescript-lang/rescript/pull/8685 - Remove the unused `pat_record_label` alias from the current parsetree. https://github.com/rescript-lang/rescript/pull/8684 diff --git a/compiler/bsc/rescript_compiler_main.ml b/compiler/bsc/rescript_compiler_main.ml index b3d51c1e98..949d42f6c5 100644 --- a/compiler/bsc/rescript_compiler_main.ml +++ b/compiler/bsc/rescript_compiler_main.ml @@ -437,7 +437,6 @@ let command_line_flags : (string * Bsc_args.spec * string) array = ("-only-parse", set Clflags.only_parse, "*internal* stop after parsing"); ( "-editor-mode", unit_call (fun () -> - Clflags.editor_mode := true; Clflags.ignore_parse_errors := true; Js_config.cmi_only := true), "*internal* Enable editor mode." ); @@ -458,9 +457,6 @@ let command_line_flags : (string * Bsc_args.spec * string) array = unit_call print_version_string, "Print compiler version and location of standard library and exit" ); ("-version", unit_call print_version_string, "Print version and exit"); - ( "-pp", - string_optional_set Clflags.preprocessor, - "*internal* Pipe sources through preprocessor " ); ( "-absname", set absname, "*internal* Show absolute filenames in error messages" ); @@ -475,9 +471,7 @@ let command_line_flags : (string * Bsc_args.spec * string) array = ( "-short-paths", clear Clflags.real_paths, "*internal* Shorten paths in types" ); - ( "-unsafe", - set Clflags.fast, - "*internal* Do not compile bounds checking on array and string access" ); + ("-unsafe", Unit_dummy, "*internal* No longer used and is a no-op."); ( "-runtime-path", string_call setup_runtime_path, "*internal* Set the path of the runtime package (@rescript/runtime)" ); diff --git a/compiler/core/j.ml b/compiler/core/j.ml index bae9a7886a..1424757f02 100644 --- a/compiler/core/j.ml +++ b/compiler/core/j.ml @@ -99,8 +99,6 @@ and expression_desc = some primitive call is translated into a plain call, it's better to keep them *) - | String_index of expression * expression - (* str.[i])*) | Array_index of expression * expression (* arr.(i) Invariant: diff --git a/compiler/core/js_analyzer.ml b/compiler/core/js_analyzer.ml index a920b1750c..9b084de23d 100644 --- a/compiler/core/js_analyzer.ml +++ b/compiler/core/js_analyzer.ml @@ -110,8 +110,7 @@ let rec no_side_effect_expression_desc (x : J.expression_desc) = | Json_literal _ -> true | Static_index (obj, (_name : string), (_pos : int32 option)) -> no_side_effect obj - | String_index (a, b) | Array_index (a, b) -> - no_side_effect a && no_side_effect b + | Array_index (a, b) -> no_side_effect a && no_side_effect b | Is_null_or_undefined b -> no_side_effect b | Str _ | Template_literal _ -> true | Interpolated_template {values} -> Ext_list.for_all values no_side_effect @@ -217,10 +216,6 @@ let rec eq_expression ({expression_desc = x0} : J.expression) false (* conservative *) | _ -> false end *) - | String_index (a0, a1) -> ( - match y0 with - | String_index (b0, b1) -> eq_expression a0 b0 && eq_expression a1 b1 - | _ -> false) | Array_index (a0, a1) -> ( match y0 with | Array_index (b0, b1) -> eq_expression a0 b0 && eq_expression a1 b1 diff --git a/compiler/core/js_dump.ml b/compiler/core/js_dump.ml index a23255c8c2..46889b6cb5 100644 --- a/compiler/core/js_dump.ml +++ b/compiler/core/js_dump.ml @@ -142,10 +142,9 @@ let rec exp_need_paren ?(arrow = false) (e : J.expression) = | Json_literal _ -> true | Raw_js_code {code_info = Stmt _} | Length _ | Call _ | Caml_block_tag _ | Seq _ | Static_index _ | Cond _ - | Bin _ | Is_null_or_undefined _ | String_index _ | Array_index _ - | String_append _ | Var _ | Undefined _ | Null | Str _ | Template_literal _ - | Array _ | Caml_block _ | Typeof _ | Number _ | Js_not _ | Js_bnot _ | In _ - | Bool _ | New _ -> + | Bin _ | Is_null_or_undefined _ | Array_index _ | String_append _ | Var _ + | Undefined _ | Null | Str _ | Template_literal _ | Array _ | Caml_block _ + | Typeof _ | Number _ | Js_not _ | Js_bnot _ | In _ | Bool _ | New _ -> false | Await _ -> false | Spread _ -> false @@ -715,13 +714,6 @@ and expression_desc cxt ~(level : int) f x : cxt = let cxt = print_segments cxt segments values in P.string f "`"; cxt - | String_index (a, b) -> - P.group f 1 (fun _ -> - let cxt = expression ~level:15 cxt f a in - P.string f L.dot; - P.string f L.code_point_at; - (* FIXME: use code_point_at *) - P.paren_group f 1 (fun _ -> expression ~level:0 cxt f b)) | Str txt -> Js_dump_string.pp_string f txt; cxt diff --git a/compiler/core/js_dump_lit.ml b/compiler/core/js_dump_lit.ml index b43b2d4591..52869920cc 100644 --- a/compiler/core/js_dump_lit.ml +++ b/compiler/core/js_dump_lit.ml @@ -70,8 +70,6 @@ let default = "default" let length = "length" -let code_point_at = "codePointAt" - let new_ = "new" let question = "?" diff --git a/compiler/core/js_exp_make.ml b/compiler/core/js_exp_make.ml index 2e15b1a20f..5ddd6ce935 100644 --- a/compiler/core/js_exp_make.ml +++ b/compiler/core/js_exp_make.ml @@ -1491,9 +1491,6 @@ let string_comp (cmp : Lambda.comparison) ?comment (e0 : t) (e1 : t) = let string_equal ?comment (e0 : t) (e1 : t) : t = string_comp Ceq ?comment e0 e1 -let is_type_number ?comment (e : t) : t = - string_equal ?comment (typeof e) (str "number") - let is_type_object (e : t) : t = string_equal (typeof e) (str "object") let obj_length ?comment e : t = diff --git a/compiler/core/js_exp_make.mli b/compiler/core/js_exp_make.mli index 9f2e6681a6..a534a21200 100644 --- a/compiler/core/js_exp_make.mli +++ b/compiler/core/js_exp_make.mli @@ -179,8 +179,6 @@ val eq_null_undefined_boolean : ?comment:string -> t -> t -> t val neq_null_undefined_boolean : ?comment:string -> t -> t -> t -val is_type_number : ?comment:string -> t -> t - val is_int_tag : ?has_null_undefined_other:bool * bool * bool -> t -> t val is_a_literal_case : diff --git a/compiler/core/js_record_fold.ml b/compiler/core/js_record_fold.ml index dd98db728a..e4b79a519e 100644 --- a/compiler/core/js_record_fold.ml +++ b/compiler/core/js_record_fold.ml @@ -130,10 +130,6 @@ let expression_desc : 'a. ('a, expression_desc) fn = let st = list _self.expression _self st _x2 in st | Interpolated_template {values} -> list _self.expression _self st values - | String_index (_x0, _x1) -> - let st = _self.expression _self st _x0 in - let st = _self.expression _self st _x1 in - st | Array_index (_x0, _x1) -> let st = _self.expression _self st _x0 in let st = _self.expression _self st _x1 in diff --git a/compiler/core/js_record_iter.ml b/compiler/core/js_record_iter.ml index d532ad3f96..6f6e89cfec 100644 --- a/compiler/core/js_record_iter.ml +++ b/compiler/core/js_record_iter.ml @@ -105,9 +105,6 @@ let expression_desc : expression_desc fn = _self.expression _self _x0; list _self.expression _self _x2 | Interpolated_template {values} -> list _self.expression _self values - | String_index (_x0, _x1) -> - _self.expression _self _x0; - _self.expression _self _x1 | Array_index (_x0, _x1) -> _self.expression _self _x0; _self.expression _self _x1 diff --git a/compiler/core/js_record_map.ml b/compiler/core/js_record_map.ml index 198d4b39d5..68ba6f5e5b 100644 --- a/compiler/core/js_record_map.ml +++ b/compiler/core/js_record_map.ml @@ -134,10 +134,6 @@ let expression_desc : expression_desc fn = | Interpolated_template ({values} as template) -> let values = list _self.expression _self values in Interpolated_template {template with values} - | String_index (_x0, _x1) -> - let _x0 = _self.expression _self _x0 in - let _x1 = _self.expression _self _x1 in - String_index (_x0, _x1) | Array_index (_x0, _x1) -> let _x0 = _self.expression _self _x0 in let _x1 = _self.expression _self _x1 in diff --git a/compiler/core/lam_analysis.ml b/compiler/core/lam_analysis.ml index a53290427f..1b90637c48 100644 --- a/compiler/core/lam_analysis.ml +++ b/compiler/core/lam_analysis.ml @@ -85,7 +85,7 @@ let rec no_side_effects (lam : Lambda.t) : bool = (* dict primitives *) | Pmakedict | Pdict_has (* Test if the argument is a block or an immediate integer *) - | Pisint | Pis_poly_var_block + | Pis_poly_var_block (* Test if the (integer) argument is outside an interval *) (* Operations on big arrays: (unsafe, #dimensions, kind, layout) *) (* Compile time constants *) @@ -104,7 +104,7 @@ let rec no_side_effects (lam : Lambda.t) : bool = (* TODO *) | Praw_js_code _ (* byte swap *) - | Parraysets | Parraysetu | Praise | Psetfield _ + | Parraysetu | Praise | Psetfield _ (* bounds-checked reads throw when the index is out of range *) | Parrayrefs | Pstringrefs | Pstringrefu -> false) diff --git a/compiler/core/lam_compile_primitive.ml b/compiler/core/lam_compile_primitive.ml index a6f3c4eb49..c1d859b02d 100644 --- a/compiler/core/lam_compile_primitive.ml +++ b/compiler/core/lam_compile_primitive.ml @@ -558,7 +558,6 @@ let translate output_prefix loc (cxt : Lam_compile_context.t) | [e; e1] -> Js_of_lam_array.ref_array e e1 (* Todo: Constant Folding *) | _ -> assert false) | Parrayrefs -> E.runtime_call Primitive_modules.array "get" args - | Parraysets -> E.runtime_call Primitive_modules.array "set" args | Pmakearray -> Js_of_lam_array.make_array args | Pmakelist -> Js_of_lam_block.make_block @@ -604,7 +603,6 @@ let translate output_prefix loc (cxt : Lam_compile_context.t) Lam_compile_external_call.translate_ffi cxt arg_types ~prim_name ffi args ~transformed_jsx (* FIXME, this can be removed later *) - | Pisint -> E.is_type_number (Ext_list.singleton_exn args) | Pis_poly_var_block -> E.is_type_object (Ext_list.singleton_exn args) | Pduprecord -> ( match args with diff --git a/compiler/ext/warnings.ml b/compiler/ext/warnings.ml index 9e09285b5b..0dfa7fe440 100644 --- a/compiler/ext/warnings.ml +++ b/compiler/ext/warnings.ml @@ -40,7 +40,6 @@ type t = | Nonreturning_statement (* 21 *) | Preprocessor of string (* 22 *) | Useless_record_with (* 23 *) - | Bad_module_name of string (* 24 *) | All_clauses_guarded (* 8, used to be 25 *) | Unused_var of string (* 26 *) | Unused_var_strict of string (* 27 *) @@ -95,7 +94,6 @@ let number = function | Nonreturning_statement -> 21 | Preprocessor _ -> 22 | Useless_record_with -> 23 - | Bad_module_name _ -> 24 | All_clauses_guarded -> 8 (* used to be 25 *) | Unused_var _ -> 26 | Unused_var_strict _ -> 27 @@ -299,12 +297,6 @@ let message = function | Useless_record_with -> "All the fields are already explicitly listed in this record. You can \ remove the `...` spread." - | Bad_module_name modname -> - "This file's name is potentially invalid. The build systems conventionally \ - turn a file name into a module name by upper-casing the first letter. " - ^ modname ^ " isn't a valid module name.\n" - ^ "Note: some build systems might e.g. turn kebab-case into CamelCase \ - module, which is why this isn't a hard error." | All_clauses_guarded -> "this pattern-matching is not exhaustive.\n\ All clauses in this pattern-matching are guarded." @@ -523,9 +515,6 @@ let descriptions = (21, "Non-returning statement."); (22, "Preprocessor warning."); (23, "Useless record \"with\" clause."); - ( 24, - "Bad module name: the source file name is not a valid ReScript module \ - name." ); (25, "Deprecated: now part of warning 8."); ( 26, "Suspicious unused variable: unused variable that is bound\n\ diff --git a/compiler/ext/warnings.mli b/compiler/ext/warnings.mli index 0d71b855b5..3e5529b66c 100644 --- a/compiler/ext/warnings.mli +++ b/compiler/ext/warnings.mli @@ -33,7 +33,6 @@ type t = | Nonreturning_statement (* 21 *) | Preprocessor of string (* 22 *) | Useless_record_with (* 23 *) - | Bad_module_name of string (* 24 *) | All_clauses_guarded (* 8, used to be 25 *) | Unused_var of string (* 26 *) | Unused_var_strict of string (* 27 *) diff --git a/compiler/ml/ast_helper.ml b/compiler/ml/ast_helper.ml index 5aebf79cf2..e6f6d82dea 100644 --- a/compiler/ml/ast_helper.ml +++ b/compiler/ml/ast_helper.ml @@ -187,7 +187,7 @@ module Exp = struct let for_await_of ?loc ?attrs a b c = mk ?loc ?attrs (Pexp_for_await_of (a, b, c)) let constraint_ ?loc ?attrs a b = mk ?loc ?attrs (Pexp_constraint (a, b)) - let coerce ?loc ?attrs a c = mk ?loc ?attrs (Pexp_coerce (a, (), c)) + let coerce ?loc ?attrs a c = mk ?loc ?attrs (Pexp_coerce (a, c)) let object_get ?loc ?attrs a b = mk ?loc ?attrs (Pexp_object_get (a, b)) let object_set ?loc ?attrs a b c = mk ?loc ?attrs (Pexp_object_set (a, b, c)) let object_literal ?loc ?attrs a = mk ?loc ?attrs (Pexp_object_literal a) diff --git a/compiler/ml/ast_iterator.ml b/compiler/ml/ast_iterator.ml index f05bab284d..301d38efe5 100644 --- a/compiler/ml/ast_iterator.ml +++ b/compiler/ml/ast_iterator.ml @@ -368,7 +368,7 @@ module E = struct sub.pat sub p; sub.expr sub e1; sub.expr sub e2 - | Pexp_coerce (e, (), t2) -> + | Pexp_coerce (e, t2) -> sub.expr sub e; sub.typ sub t2 | Pexp_constraint (e, t) -> diff --git a/compiler/ml/ast_mapper.ml b/compiler/ml/ast_mapper.ml index a8b4da96b8..52117a481b 100644 --- a/compiler/ml/ast_mapper.ml +++ b/compiler/ml/ast_mapper.ml @@ -369,7 +369,7 @@ module E = struct Exp.tagged_template ~loc ~attrs (sub.expr sub tag) (List.map (map_loc sub) raw_sources) (List.map (sub.expr sub) values) - | Pexp_coerce (e, (), t2) -> + | Pexp_coerce (e, t2) -> coerce ~loc ~attrs (sub.expr sub e) (sub.typ sub t2) | Pexp_constraint (e, t) -> constraint_ ~loc ~attrs (sub.expr sub e) (sub.typ sub t) diff --git a/compiler/ml/ast_mapper_to0.ml b/compiler/ml/ast_mapper_to0.ml index c1bf3b8855..980c358755 100644 --- a/compiler/ml/ast_mapper_to0.ml +++ b/compiler/ml/ast_mapper_to0.ml @@ -721,7 +721,7 @@ module E = struct ( Asttypes.Noloc.Nolabel, Ast_helper0.Exp.array ~loc (List.map (sub.expr sub) values) ); ] - | Pexp_coerce (e, (), t2) -> + | Pexp_coerce (e, t2) -> coerce ~loc ~attrs (sub.expr sub e) (sub.typ sub t2) | Pexp_constraint (e, t) -> constraint_ ~loc ~attrs (sub.expr sub e) (sub.typ sub t) diff --git a/compiler/ml/clflags.ml b/compiler/ml/clflags.ml index f4db4c370f..a21c3626b8 100644 --- a/compiler/ml/clflags.ml +++ b/compiler/ml/clflags.ml @@ -4,12 +4,8 @@ and include_dirs = ref ([] : string list) (* -I *) and debug = ref false (* -g *) -and fast = ref false (* -unsafe *) - and nopervasives = ref false (* -nopervasives *) -and preprocessor = ref (None : string option) (* -pp *) - and all_ppx = ref ([] : string list) (* -ppx *) @@ -23,8 +19,6 @@ and open_modules = ref [] (* -open *) and real_paths = ref true (* -short-paths *) -and applicative_functors = ref true (* -no-app-funct *) - and error_size = ref 400 (* -error-size, in heap words *) and transparent_modules = ref false (* -trans-mod *) @@ -39,8 +33,6 @@ and dump_coercions = ref false (* -draw-coercions *) and only_parse = ref false (* -only-parse *) -and editor_mode = ref false (* -editor-mode *) - and ignore_parse_errors = ref false (* -ignore-parse-errors *) let dont_write_files = ref false (* set to true under ocamldoc *) diff --git a/compiler/ml/clflags.mli b/compiler/ml/clflags.mli index 79ecb6ecff..587857714f 100644 --- a/compiler/ml/clflags.mli +++ b/compiler/ml/clflags.mli @@ -2,17 +2,14 @@ val output_name : string option ref val include_dirs : string list ref val debug : bool ref -val fast : bool ref val nopervasives : bool ref val open_modules : string list ref -val preprocessor : string option ref val all_ppx : string list ref val binary_annotations : bool ref val noassert : bool ref val verbose : bool ref val real_paths : bool ref -val applicative_functors : bool ref val error_size : int ref val transparent_modules : bool ref val dump_source : bool ref @@ -24,7 +21,6 @@ val dont_write_files : bool ref val keep_locs : bool ref val only_parse : bool ref val ignore_parse_errors : bool ref -val editor_mode : bool ref val parse_color_setting : string -> Misc.Color.setting option val color : Misc.Color.setting option ref diff --git a/compiler/ml/depend.ml b/compiler/ml/depend.ml index 50a4b5aee2..e18d5040cc 100644 --- a/compiler/ml/depend.ml +++ b/compiler/ml/depend.ml @@ -277,7 +277,7 @@ let rec add_expr bv exp = add_pattern bv pat |> ignore; add_expr bv e1; add_expr bv e2 - | Pexp_coerce (e1, (), ty3) -> + | Pexp_coerce (e1, ty3) -> add_expr bv e1; add_type bv ty3 | Pexp_constraint (e1, ty2) -> diff --git a/compiler/ml/lambda.ml b/compiler/ml/lambda.ml index 7988f06da6..20f8202156 100644 --- a/compiler/ml/lambda.ml +++ b/compiler/ml/lambda.ml @@ -227,7 +227,6 @@ type primitive = | Parrayrefu | Parraysetu | Parrayrefs - | Parraysets (* List primitives *) | Pmakelist (* dict primitives *) @@ -245,7 +244,6 @@ type primitive = | Phash_mixstring | Phash_finalmix (* Test if the argument is a block or an immediate integer *) - | Pisint (* Test if the (integer) argument is outside an interval *) (* Test if the argument is null or undefined *) | Pis_null_undefined @@ -464,7 +462,7 @@ let eq_primitive_approx (lhs : primitive) (rhs : primitive) = (* bool primitives *) | Psequand | Psequor | Pnot | Pboolcomp _ | Pboolorder | Pboolmin | Pboolmax (* int primitives *) - | Pisint | Pnegint | Paddint | Psubint | Pmulint | Pdivint | Pmodint | Ppowint + | Pnegint | Paddint | Psubint | Pmulint | Pdivint | Pmodint | Ppowint | Pnotint | Pandint | Porint | Pxorint | Plslint | Plsrint | Pasrint | Pintorder | Pintmin | Pintmax (* float primitives *) @@ -488,7 +486,7 @@ let eq_primitive_approx (lhs : primitive) (rhs : primitive) = | Pnull_undefined_to_opt | Pis_null | Pis_not_none | Psome | Psome_not_nest | Pis_undefined | Pis_null_undefined | Ptypeof | Pis_poly_var_block | Pdebugger | Pinit_mod | Pupdate_mod | Pduprecord | Pmakearray | Parraylength - | Parrayrefu | Parraysetu | Parrayrefs | Parraysets | Pjs_fn_method | Phash + | Parrayrefu | Parraysetu | Parrayrefs | Pjs_fn_method | Phash | Phash_mixstring | Phash_mixint | Phash_finalmix | Precord_rest _ -> rhs = lhs (* Reachable only via the optimizer's term-equality comparison, which the @@ -1194,44 +1192,7 @@ let if_ (a : t) (b : t) (c : t) : t = matching's own exit bookkeeping inspects after the term is assembled, and doing it here leaves static raises without their catch. It is {!Lam_pass_guard_raises} instead. *) - | _ -> ( - match a with - | Lprim {primitive = Pisint; args = [Lvar i]; _} -> ( - match b with - | Lifthenelse - (Lprim {primitive = Pintcomp Ceq; args = [Lvar j; Lconst _]}, _, b_f) - when Ident.same i j && eq_approx b_f c -> - b - | Lprim {primitive = Pintcomp Ceq; args = [Lvar j; Lconst _]} - when Ident.same i j && eq_approx lambda_false c -> - b - | Lifthenelse - ( Lprim - ({primitive = Pintcomp Cneq; args = [Lvar j; Lconst _]} as - b_pred), - b_t, - b_f ) - when Ident.same i j && eq_approx b_t c -> - Lifthenelse (Lprim {b_pred with primitive = Pintcomp Ceq}, b_f, b_t) - | Lprim - {primitive = Pintcomp Cneq; args = [Lvar j; Lconst _] as args; loc} - | Lprim - { - primitive = Pnot; - args = - [ - Lprim - { - primitive = Pintcomp Ceq; - args = [Lvar j; Lconst _] as args; - loc; - }; - ]; - } - when Ident.same i j && eq_approx lambda_true c -> - Lprim {primitive = Pintcomp Cneq; args; loc} - | _ -> Lifthenelse (a, b, c)) - | _ -> Lifthenelse (a, b, c))) + | _ -> Lifthenelse (a, b, c)) let sequor l r = if_ l lambda_true r diff --git a/compiler/ml/lambda.mli b/compiler/ml/lambda.mli index 03b9ecdafe..e39c9bb11c 100644 --- a/compiler/ml/lambda.mli +++ b/compiler/ml/lambda.mli @@ -228,7 +228,6 @@ type primitive = | Parrayrefu | Parraysetu | Parrayrefs - | Parraysets (* List primitives *) | Pmakelist (* dict primitives *) @@ -245,8 +244,6 @@ type primitive = | Phash_mixint | Phash_mixstring | Phash_finalmix - (* Test if the argument is a block or an immediate integer *) - | Pisint (* Test if the (integer) argument is outside an interval *) (* Test if the argument is null or undefined *) | Pis_null_undefined @@ -444,8 +441,7 @@ val const_is_allocating : structured_constant -> bool collapses a module record rebuilt field-by-field from another module back to that module. - [if_] resolves a constant condition, collapses a branch that asserts - false, turns boolean branches into the condition or its negation, and - recognizes a few [Pisint] shapes. + false, turns boolean branches into the condition or its negation. - [switch] and [stringswitch] pick the matching case when the scrutinee is constant. - [not_] rewrites a negated inequality into an equality. diff --git a/compiler/ml/mtype.ml b/compiler/ml/mtype.ml index 8fb04fdc84..dddeb68223 100644 --- a/compiler/ml/mtype.ml +++ b/compiler/ml/mtype.ml @@ -30,8 +30,7 @@ let freshen mty = Subst.modtype Subst.identity mty let rec strengthen ~aliasable env mty p = match scrape env mty with | Mty_signature sg -> Mty_signature (strengthen_sig ~aliasable env sg p 0) - | Mty_functor (param, arg, res) - when !Clflags.applicative_functors && Ident.name param <> "*" -> + | Mty_functor (param, arg, res) when Ident.name param <> "*" -> Mty_functor ( param, arg, diff --git a/compiler/ml/parsetree.ml b/compiler/ml/parsetree.ml index ece42423b0..752ad78fe0 100644 --- a/compiler/ml/parsetree.ml +++ b/compiler/ml/parsetree.ml @@ -356,9 +356,7 @@ and expression_desc = for i = E1 downto E2 do E3 done (flag = Downto) *) | Pexp_constraint of expression * core_type (* (E : T) *) - | Pexp_coerce of expression * unit * core_type - (* (E :> T) (None, T) - *) + | Pexp_coerce of expression * core_type (* (E :> T) *) | Pexp_object_get of expression * label loc (* obj["x"] *) | Pexp_object_set of expression * label loc * expression (* obj["x"] = v *) | Pexp_object_literal of (label loc * expression) list diff --git a/compiler/ml/pprintast.ml b/compiler/ml/pprintast.ml index 358bd50a88..626797d3f9 100644 --- a/compiler/ml/pprintast.ml +++ b/compiler/ml/pprintast.ml @@ -841,7 +841,7 @@ and simple_expr ctxt f x = pp f "@[(%a)@]" (list (simple_expr ctxt) ~sep:",@;") l | Pexp_constraint (e, ct) -> pp f "(%a :@ %a)" (expression ctxt) e (core_type ctxt) ct - | Pexp_coerce (e, (), ct) -> + | Pexp_coerce (e, ct) -> pp f "(%a :> %a)" (expression ctxt) e (core_type ctxt) ct | Pexp_variant (l, {txt = []}) -> pp f "`%s" l | Pexp_record (l, eo) -> diff --git a/compiler/ml/printast.ml b/compiler/ml/printast.ml index 549ede858b..c4767e7b3d 100644 --- a/compiler/ml/printast.ml +++ b/compiler/ml/printast.ml @@ -357,7 +357,7 @@ and expression i ppf x = line i ppf "Pexp_constraint\n"; expression i ppf e; core_type i ppf ct - | Pexp_coerce (e, (), cto2) -> + | Pexp_coerce (e, cto2) -> line i ppf "Pexp_coerce\n"; expression i ppf e; core_type i ppf cto2 diff --git a/compiler/ml/printlambda.ml b/compiler/ml/printlambda.ml index 95499f5c20..123bc4c1b9 100644 --- a/compiler/ml/printlambda.ml +++ b/compiler/ml/printlambda.ml @@ -192,11 +192,9 @@ let primitive ppf = function | Parrayrefu -> fprintf ppf "array.unsafe_get" | Parraysetu -> fprintf ppf "array.unsafe_set" | Parrayrefs -> fprintf ppf "array.get" - | Parraysets -> fprintf ppf "array.set" | Pmakelist -> fprintf ppf "makelist" | Pmakedict -> fprintf ppf "makedict" | Pdict_has -> fprintf ppf "dict.has" - | Pisint -> fprintf ppf "isint" | Pis_null -> fprintf ppf "is_null" | Pis_undefined -> fprintf ppf "is_undefined" | Pis_null_undefined -> fprintf ppf "isnullable" diff --git a/compiler/ml/translcore.ml b/compiler/ml/translcore.ml index ac0c4bac27..0079a7e351 100644 --- a/compiler/ml/translcore.ml +++ b/compiler/ml/translcore.ml @@ -269,7 +269,6 @@ let primitive_builtins : (string * Lambda.builtin) array = (* Finish Triples for ref data type *) ("%field0", Pfield (0, Fld_tuple)); ("%field1", Pfield (1, Fld_tuple)); - ("%obj_dup", Pduprecord); ("%obj_tag", Pobjtag); ("%obj_size", Pobjsize); ("%obj_get_field", Parrayrefu); @@ -283,7 +282,6 @@ let primitive_builtins : (string * Lambda.builtin) array = ("%boolmin", Pboolmin); ("%boolmax", Pboolmax); (* int primitives *) - ("%obj_is_int", Pisint); ("%negint", Pnegint); ("%addint", Paddint); ("%subint", Psubint); @@ -356,7 +354,6 @@ let primitive_builtins : (string * Lambda.builtin) array = (* array primitives *) ("%array_length", Parraylength); ("%array_safe_get", Parrayrefs); - ("%array_safe_set", Parraysets); ("%array_unsafe_get", Parrayrefu); ("%array_unsafe_set", Parraysetu); (* dict primitives *) @@ -382,8 +379,6 @@ let primitive_builtins : (string * Lambda.builtin) array = ("%unsafe_gt", Pjscomp Cgt); ("%unsafe_ge", Pjscomp Cge); ("%is_nullable", Pis_null_undefined); - ("%null_to_opt", Pnull_to_opt); - ("%nullable_to_opt", Pnull_undefined_to_opt); ("%makemutablelist", Pmakelist); ("%unsafe_to_method", Pjs_fn_method); (* Compiler internals, never expose to ReScript files *) @@ -393,8 +388,6 @@ let primitive_builtins : (string * Lambda.builtin) array = ("#null_to_opt", Pnull_to_opt); ("#nullable_to_opt", Pnull_undefined_to_opt); ("#makemutablelist", Pmakelist); - (* FIXME: Deprecated *) - ("%obj_field", Parrayrefu); |] let builtins_table : (string, Lambda.builtin) Hashtbl.t = diff --git a/compiler/ml/typecore.ml b/compiler/ml/typecore.ml index 234803b3a6..9f4f96a845 100644 --- a/compiler/ml/typecore.ml +++ b/compiler/ml/typecore.ml @@ -195,7 +195,7 @@ let iter_expression f e = | Pexp_open (_, _, e) | Pexp_assert e | Pexp_constraint (e, _) - | Pexp_coerce (e, _, _) + | Pexp_coerce (e, _) | Pexp_letexception (_, e) | Pexp_object_get (e, _) | Pexp_field (e, _) -> @@ -2057,7 +2057,7 @@ let rec type_approx env sexp = raise (Error (sexp.pexp_loc, env, Expr_type_clash {trace; context = None}))); ty1 - | Pexp_coerce (e, (), sty2) -> + | Pexp_coerce (e, sty2) -> let approx_ty_opt = function | None -> newvar () | Some sty -> approx_type env sty @@ -3294,7 +3294,7 @@ and type_expect_ ?deprecated_context ~context ?(recarg = Rejected) env sexp exp_extra = (Texp_constraint cty, loc, sexp.pexp_attributes) :: arg.exp_extra; } - | Pexp_coerce (sarg, (), sty') -> + | Pexp_coerce (sarg, sty') -> let separate = true in (* always separate, 1% slowdown for lablgtk *) (* Also see PR#7199 for a problem with the following: diff --git a/compiler/ml/typemod.ml b/compiler/ml/typemod.ml index e8fae41c9b..b472ea5262 100644 --- a/compiler/ml/typemod.ml +++ b/compiler/ml/typemod.ml @@ -982,7 +982,7 @@ exception Not_a_path let rec path_of_module mexp = match mexp.mod_desc with | Tmod_ident (p, _) -> p - | Tmod_apply (funct, arg, _coercion) when !Clflags.applicative_functors -> + | Tmod_apply (funct, arg, _coercion) -> Papply (path_of_module funct, path_of_module arg) | Tmod_constraint (mexp, _, _, _) -> path_of_module mexp | _ -> raise Not_a_path diff --git a/compiler/syntax/src/res_ast_debugger.ml b/compiler/syntax/src/res_ast_debugger.ml index c3b58b1b6c..5f041e7d85 100644 --- a/compiler/syntax/src/res_ast_debugger.ml +++ b/compiler/syntax/src/res_ast_debugger.ml @@ -742,7 +742,7 @@ module Sexp_ast = struct | Pexp_constraint (expr, typexpr) -> Sexp.list [Sexp.atom "Pexp_constraint"; expression expr; core_type typexpr] - | Pexp_coerce (expr, (), typexpr) -> + | Pexp_coerce (expr, typexpr) -> Sexp.list [Sexp.atom "Pexp_coerce"; expression expr; core_type typexpr] | Pexp_object_get _ -> Sexp.list [Sexp.atom "Pexp_object_get"] | Pexp_object_set (e1, _, e2) -> diff --git a/compiler/syntax/src/res_comments_table.ml b/compiler/syntax/src/res_comments_table.ml index 6591522507..ec01a935a7 100644 --- a/compiler/syntax/src/res_comments_table.ml +++ b/compiler/syntax/src/res_comments_table.ml @@ -1151,7 +1151,7 @@ and walk_expression expr t comments = attach t.leading expr.pexp_loc leading; walk_expression expr t inside; attach t.trailing expr.pexp_loc trailing - | Pexp_coerce (expr, (), typexpr) -> + | Pexp_coerce (expr, typexpr) -> let leading, inside, trailing = partition_by_loc comments expr.pexp_loc in attach t.leading expr.pexp_loc leading; walk_expression expr t inside; diff --git a/compiler/syntax/src/res_printer.ml b/compiler/syntax/src/res_printer.ml index 7ffe10d8fb..1701bd2ef5 100644 --- a/compiler/syntax/src/res_printer.ml +++ b/compiler/syntax/src/res_printer.ml @@ -3745,7 +3745,7 @@ and print_expression ~state (e : Parsetree.expression) cmt_tbl = Doc.space; print_cases ~state cases cmt_tbl; ] - | Pexp_coerce (expr, (), typ) -> + | Pexp_coerce (expr, typ) -> let doc_expr = print_expression_with_comments_and_parens ~state expr cmt_tbl in diff --git a/packages/@rescript/belt/rescript.json b/packages/@rescript/belt/rescript.json index 791e43cd34..5fb8388b9a 100644 --- a/packages/@rescript/belt/rescript.json +++ b/packages/@rescript/belt/rescript.json @@ -23,7 +23,6 @@ "-bs-no-version-header", "-bs-no-check-div-by-zero", "-bs-cross-module-opt", - "-unsafe", "-w -3+50", "-warn-error A" ] diff --git a/packages/@rescript/runtime/Primitive_array.res b/packages/@rescript/runtime/Primitive_array.res index 7bfef9b575..b1be572549 100644 --- a/packages/@rescript/runtime/Primitive_array.res +++ b/packages/@rescript/runtime/Primitive_array.res @@ -7,13 +7,6 @@ let get = (xs, index) => xs->Primitive_array_extern.getUnsafe(index) } -let set = (xs, index, newval) => - if index < 0 || index >= length(xs) { - throw(Invalid_argument("index out of bounds")) - } else { - xs->Primitive_array_extern.setUnsafe(index, newval) - } - // Note: this is exposed to support syntax @new external makeUninitializedUnsafe: int => array<'a> = "Array" diff --git a/packages/@rescript/runtime/lib/es6/Primitive_array.mjs b/packages/@rescript/runtime/lib/es6/Primitive_array.mjs index b85c60c323..26c89564be 100644 --- a/packages/@rescript/runtime/lib/es6/Primitive_array.mjs +++ b/packages/@rescript/runtime/lib/es6/Primitive_array.mjs @@ -16,17 +16,6 @@ function get(xs, index) { return xs[index]; } -function set(xs, index, newval) { - if (index < 0 || index >= xs.length) { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "index out of bounds", - Error: new Error() - }; - } - xs[index] = newval; -} - function spread(arrays) { let arraysLength = arrays.length; let resultLength = 0; @@ -48,7 +37,6 @@ function spread(arrays) { export { length, get, - set, spread, } /* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Primitive_array.cjs b/packages/@rescript/runtime/lib/js/Primitive_array.cjs index d4eeabe9f7..97e51f5a2a 100644 --- a/packages/@rescript/runtime/lib/js/Primitive_array.cjs +++ b/packages/@rescript/runtime/lib/js/Primitive_array.cjs @@ -16,17 +16,6 @@ function get(xs, index) { return xs[index]; } -function set(xs, index, newval) { - if (index < 0 || index >= xs.length) { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "index out of bounds", - Error: new Error() - }; - } - xs[index] = newval; -} - function spread(arrays) { let arraysLength = arrays.length; let resultLength = 0; @@ -47,6 +36,5 @@ function spread(arrays) { exports.length = length; exports.get = get; -exports.set = set; exports.spread = spread; /* No side effect */ diff --git a/packages/@rescript/runtime/rescript.json b/packages/@rescript/runtime/rescript.json index 1f2d69fd12..61a19dbf0f 100644 --- a/packages/@rescript/runtime/rescript.json +++ b/packages/@rescript/runtime/rescript.json @@ -30,7 +30,6 @@ "-bs-no-version-header", "-bs-no-check-div-by-zero", "-bs-cross-module-opt", - "-unsafe", "-w -3+50", "-warn-error A" ] diff --git a/tests/ERROR_VARIANTS.md b/tests/ERROR_VARIANTS.md index 3901ef2c98..f6d6e471f2 100644 --- a/tests/ERROR_VARIANTS.md +++ b/tests/ERROR_VARIANTS.md @@ -564,6 +564,9 @@ The warning constructors listed in **Removed in `jono/remove-dead-errors`** were deleted. Their numeric warning slots remain holes; no warning number was reused. +Warning 24 (`Bad_module_name`) was removed later for the same reason: it +had no raise site. Its slot is likewise left unused. + ### Live but no fixture yet These warnings have `prerr_warning` raise sites in `compiler/` and are diff --git a/tools/src/migrate.ml b/tools/src/migrate.ml index 6505c78be7..892d81ee76 100644 --- a/tools/src/migrate.ml +++ b/tools/src/migrate.ml @@ -56,7 +56,7 @@ module Expr_utils = struct true | Pexp_construct (_, {txt = [e]}) | Pexp_constraint (e, _) - | Pexp_coerce (e, _, _) + | Pexp_coerce (e, _) | Pexp_let (_, _, e) | Pexp_sequence (e, _) | Pexp_letmodule (_, _, e)