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: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 1 addition & 7 deletions compiler/bsc/rescript_compiler_main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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." );
Expand All @@ -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* <command> Pipe sources through preprocessor <command>" );
( "-absname",
set absname,
"*internal* Show absolute filenames in error messages" );
Expand All @@ -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)" );
Expand Down
2 changes: 0 additions & 2 deletions compiler/core/j.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 1 addition & 6 deletions compiler/core/js_analyzer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 3 additions & 11 deletions compiler/core/js_dump.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions compiler/core/js_dump_lit.ml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ let default = "default"

let length = "length"

let code_point_at = "codePointAt"

let new_ = "new"

let question = "?"
Expand Down
3 changes: 0 additions & 3 deletions compiler/core/js_exp_make.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
2 changes: 0 additions & 2 deletions compiler/core/js_exp_make.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
Expand Down
4 changes: 0 additions & 4 deletions compiler/core/js_record_fold.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions compiler/core/js_record_iter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions compiler/core/js_record_map.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions compiler/core/lam_analysis.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 *)
Expand All @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions compiler/core/lam_compile_primitive.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
11 changes: 0 additions & 11 deletions compiler/ext/warnings.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 *)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -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\
Expand Down
1 change: 0 additions & 1 deletion compiler/ext/warnings.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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 *)
Expand Down
2 changes: 1 addition & 1 deletion compiler/ml/ast_helper.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion compiler/ml/ast_iterator.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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) ->
Expand Down
2 changes: 1 addition & 1 deletion compiler/ml/ast_mapper.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion compiler/ml/ast_mapper_to0.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 0 additions & 8 deletions compiler/ml/clflags.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 *)
Expand All @@ -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 *)
Expand All @@ -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 *)
Expand Down
4 changes: 0 additions & 4 deletions compiler/ml/clflags.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion compiler/ml/depend.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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) ->
Expand Down
Loading
Loading