Skip to content

Commit b15ccd1

Browse files
cknittclaude
andauthored
Remove dead internal compiler code (#8731)
* Remove dead internal compiler code - Warning 24 (Bad_module_name), which is never raised. - The J.String_index JS IR node, which is never constructed. - The Pisint and Parraysets Lambda primitives, their only producers (%obj_is_int, %array_safe_set), and Primitive_array.set and E.is_type_number, which only they used. - The unused %obj_dup, %obj_field, %null_to_opt and %nullable_to_opt primitive names. - The unread Clflags fields fast, preprocessor, editor_mode and applicative_functors, and the -pp flag. -unsafe stays accepted as a no-op and is dropped from the runtime and belt configs. - The unit slot of Pexp_coerce in the current parsetree. The frozen v0 parsetree keeps it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Christoph Knittel <ck@cca.io> * Add PR link to changelog entry Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Christoph Knittel <ck@cca.io> --------- Signed-off-by: Christoph Knittel <ck@cca.io> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 1cc1da7 commit b15ccd1

42 files changed

Lines changed: 32 additions & 181 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
#### :house: Internal
4343

44+
- 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
4445
- Represent inline record definitions with an explicit parsetree origin while retaining the existing PPX wire representation. https://github.com/rescript-lang/rescript/pull/8686
4546
- Make expression attributes immutable in the current parsetree, now that editor refactors construct new expression nodes. https://github.com/rescript-lang/rescript/pull/8685
4647
- Remove the unused `pat_record_label` alias from the current parsetree. https://github.com/rescript-lang/rescript/pull/8684

‎compiler/bsc/rescript_compiler_main.ml‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,6 @@ let command_line_flags : (string * Bsc_args.spec * string) array =
437437
("-only-parse", set Clflags.only_parse, "*internal* stop after parsing");
438438
( "-editor-mode",
439439
unit_call (fun () ->
440-
Clflags.editor_mode := true;
441440
Clflags.ignore_parse_errors := true;
442441
Js_config.cmi_only := true),
443442
"*internal* Enable editor mode." );
@@ -458,9 +457,6 @@ let command_line_flags : (string * Bsc_args.spec * string) array =
458457
unit_call print_version_string,
459458
"Print compiler version and location of standard library and exit" );
460459
("-version", unit_call print_version_string, "Print version and exit");
461-
( "-pp",
462-
string_optional_set Clflags.preprocessor,
463-
"*internal* <command> Pipe sources through preprocessor <command>" );
464460
( "-absname",
465461
set absname,
466462
"*internal* Show absolute filenames in error messages" );
@@ -475,9 +471,7 @@ let command_line_flags : (string * Bsc_args.spec * string) array =
475471
( "-short-paths",
476472
clear Clflags.real_paths,
477473
"*internal* Shorten paths in types" );
478-
( "-unsafe",
479-
set Clflags.fast,
480-
"*internal* Do not compile bounds checking on array and string access" );
474+
("-unsafe", Unit_dummy, "*internal* No longer used and is a no-op.");
481475
( "-runtime-path",
482476
string_call setup_runtime_path,
483477
"*internal* Set the path of the runtime package (@rescript/runtime)" );

‎compiler/core/j.ml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ and expression_desc =
9999
some primitive call is translated
100100
into a plain call, it's better to keep them
101101
*)
102-
| String_index of expression * expression
103-
(* str.[i])*)
104102
| Array_index of expression * expression
105103
(* arr.(i)
106104
Invariant:

‎compiler/core/js_analyzer.ml‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ let rec no_side_effect_expression_desc (x : J.expression_desc) =
110110
| Json_literal _ -> true
111111
| Static_index (obj, (_name : string), (_pos : int32 option)) ->
112112
no_side_effect obj
113-
| String_index (a, b) | Array_index (a, b) ->
114-
no_side_effect a && no_side_effect b
113+
| Array_index (a, b) -> no_side_effect a && no_side_effect b
115114
| Is_null_or_undefined b -> no_side_effect b
116115
| Str _ | Template_literal _ -> true
117116
| Interpolated_template {values} -> Ext_list.for_all values no_side_effect
@@ -217,10 +216,6 @@ let rec eq_expression ({expression_desc = x0} : J.expression)
217216
false (* conservative *)
218217
| _ -> false
219218
end *)
220-
| String_index (a0, a1) -> (
221-
match y0 with
222-
| String_index (b0, b1) -> eq_expression a0 b0 && eq_expression a1 b1
223-
| _ -> false)
224219
| Array_index (a0, a1) -> (
225220
match y0 with
226221
| Array_index (b0, b1) -> eq_expression a0 b0 && eq_expression a1 b1

‎compiler/core/js_dump.ml‎

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,9 @@ let rec exp_need_paren ?(arrow = false) (e : J.expression) =
142142
| Json_literal _ -> true
143143
| Raw_js_code {code_info = Stmt _}
144144
| Length _ | Call _ | Caml_block_tag _ | Seq _ | Static_index _ | Cond _
145-
| Bin _ | Is_null_or_undefined _ | String_index _ | Array_index _
146-
| String_append _ | Var _ | Undefined _ | Null | Str _ | Template_literal _
147-
| Array _ | Caml_block _ | Typeof _ | Number _ | Js_not _ | Js_bnot _ | In _
148-
| Bool _ | New _ ->
145+
| Bin _ | Is_null_or_undefined _ | Array_index _ | String_append _ | Var _
146+
| Undefined _ | Null | Str _ | Template_literal _ | Array _ | Caml_block _
147+
| Typeof _ | Number _ | Js_not _ | Js_bnot _ | In _ | Bool _ | New _ ->
149148
false
150149
| Await _ -> false
151150
| Spread _ -> false
@@ -715,13 +714,6 @@ and expression_desc cxt ~(level : int) f x : cxt =
715714
let cxt = print_segments cxt segments values in
716715
P.string f "`";
717716
cxt
718-
| String_index (a, b) ->
719-
P.group f 1 (fun _ ->
720-
let cxt = expression ~level:15 cxt f a in
721-
P.string f L.dot;
722-
P.string f L.code_point_at;
723-
(* FIXME: use code_point_at *)
724-
P.paren_group f 1 (fun _ -> expression ~level:0 cxt f b))
725717
| Str txt ->
726718
Js_dump_string.pp_string f txt;
727719
cxt

‎compiler/core/js_dump_lit.ml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ let default = "default"
7070

7171
let length = "length"
7272

73-
let code_point_at = "codePointAt"
74-
7573
let new_ = "new"
7674

7775
let question = "?"

‎compiler/core/js_exp_make.ml‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,9 +1491,6 @@ let string_comp (cmp : Lambda.comparison) ?comment (e0 : t) (e1 : t) =
14911491

14921492
let string_equal ?comment (e0 : t) (e1 : t) : t = string_comp Ceq ?comment e0 e1
14931493

1494-
let is_type_number ?comment (e : t) : t =
1495-
string_equal ?comment (typeof e) (str "number")
1496-
14971494
let is_type_object (e : t) : t = string_equal (typeof e) (str "object")
14981495

14991496
let obj_length ?comment e : t =

‎compiler/core/js_exp_make.mli‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,6 @@ val eq_null_undefined_boolean : ?comment:string -> t -> t -> t
179179

180180
val neq_null_undefined_boolean : ?comment:string -> t -> t -> t
181181

182-
val is_type_number : ?comment:string -> t -> t
183-
184182
val is_int_tag : ?has_null_undefined_other:bool * bool * bool -> t -> t
185183

186184
val is_a_literal_case :

‎compiler/core/js_record_fold.ml‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,6 @@ let expression_desc : 'a. ('a, expression_desc) fn =
130130
let st = list _self.expression _self st _x2 in
131131
st
132132
| Interpolated_template {values} -> list _self.expression _self st values
133-
| String_index (_x0, _x1) ->
134-
let st = _self.expression _self st _x0 in
135-
let st = _self.expression _self st _x1 in
136-
st
137133
| Array_index (_x0, _x1) ->
138134
let st = _self.expression _self st _x0 in
139135
let st = _self.expression _self st _x1 in

‎compiler/core/js_record_iter.ml‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,6 @@ let expression_desc : expression_desc fn =
105105
_self.expression _self _x0;
106106
list _self.expression _self _x2
107107
| Interpolated_template {values} -> list _self.expression _self values
108-
| String_index (_x0, _x1) ->
109-
_self.expression _self _x0;
110-
_self.expression _self _x1
111108
| Array_index (_x0, _x1) ->
112109
_self.expression _self _x0;
113110
_self.expression _self _x1

0 commit comments

Comments
 (0)