Skip to content

Commit c2ad39e

Browse files
nojafcristianoc
andauthored
AST: Remove Pexp_new (#7239)
* Remove Pexp_new * Add changelog entry * Remove Pexp_setinstvar * Remove Pexp_override * Try removing Pexp_poly * Correct changelog * Remove `exp_extra.Texp_poly`, `expression_desc.Texp_new`, `expression_desc.Texp_setinstvar` & `expression_desc.Texp_override` * Remove expression_desc.Texp_instvar --------- Co-authored-by: Cristiano Calcagno <[email protected]>
1 parent e96f2f2 commit c2ad39e

28 files changed

+13
-224
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
- AST cleanup: Prepare for ast async cleanup: Refactor code for "@res.async" payload handling and clean up handling of type and term parameters, so that now each `=>` in a function definition corresponds to a function. https://github.com/rescript-lang/rescript/pull/7223
2525
- AST: always put type parameters first in function definitions. https://github.com/rescript-lang/rescript/pull/7233
2626
- AST cleanup: Remove `@res.async` attribute from the internal representation, and add a flag to untyped and typed ASTs instead. https://github.com/rescript-lang/rescript/pull/7234
27+
- AST cleanup: Remove `expression_desc.Pexp_new`, `expression_desc.Pexp_setinstvar`, `expression_desc.Pexp_override`, `expression_desc.Pexp_poly`, `exp_extra.Texp_poly`, `expression_desc.Texp_new`, `expression_desc.Texp_setinstvar`, `expression_desc.Texp_override` & `expression_desc.Texp_instvar` from AST as it is unused. https://github.com/rescript-lang/rescript/pull/7239
2728
- AST cleanup: Remove `@res.partial` attribute from the internal representation, and add a flag to untyped and typed ASTs instead. https://github.com/rescript-lang/rescript/pull/7238 https://github.com/rescript-lang/rescript/pull/7240
2829

2930
# 12.0.0-alpha.7

analysis/reanalyze/src/Arnold.ml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -982,18 +982,6 @@ module Compile = struct
982982
| Texp_send _ ->
983983
notImplemented "Texp_send";
984984
assert false
985-
| Texp_new _ ->
986-
notImplemented "Texp_new";
987-
assert false
988-
| Texp_instvar _ ->
989-
notImplemented "Texp_instvar";
990-
assert false
991-
| Texp_setinstvar _ ->
992-
notImplemented "Texp_setinstvar";
993-
assert false
994-
| Texp_override _ ->
995-
notImplemented "Texp_override";
996-
assert false
997985
| Texp_letmodule _ ->
998986
notImplemented "Texp_letmodule";
999987
assert false

analysis/reanalyze/src/SideEffects.ml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ let rec exprNoSideEffects (expr : Typedtree.expression) =
6161
e1 |> exprNoSideEffects && e2 |> exprNoSideEffects
6262
&& e3 |> exprNoSideEffects
6363
| Texp_send _ -> false
64-
| Texp_new _ -> true
65-
| Texp_instvar _ -> true
66-
| Texp_setinstvar _ -> false
67-
| Texp_override _ -> false
6864
| Texp_letexception (_ec, e) -> e |> exprNoSideEffects
6965
| Texp_pack _ -> false
7066
| Texp_extension_constructor _ when true -> true

analysis/src/Utils.ml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,10 @@ let identifyPexp pexp =
103103
| Pexp_constraint _ -> "Pexp_constraint"
104104
| Pexp_coerce _ -> "Pexp_coerce"
105105
| Pexp_send _ -> "Pexp_send"
106-
| Pexp_new _ -> "Pexp_new"
107-
| Pexp_setinstvar _ -> "Pexp_setinstvar"
108-
| Pexp_override _ -> "Pexp_override"
109106
| Pexp_letmodule _ -> "Pexp_letmodule"
110107
| Pexp_letexception _ -> "Pexp_letexception"
111108
| Pexp_assert _ -> "Pexp_assert"
112109
| Pexp_lazy _ -> "Pexp_lazy"
113-
| Pexp_poly _ -> "Pexp_poly"
114110
| Pexp_newtype _ -> "Pexp_newtype"
115111
| Pexp_pack _ -> "Pexp_pack"
116112
| Pexp_extension _ -> "Pexp_extension"

compiler/frontend/bs_ast_invariant.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ let emit_external_warnings : iterator =
9494
(fun self ({pexp_loc = loc} as a) ->
9595
match a.pexp_desc with
9696
| Pexp_constant const -> check_constant loc const
97-
| Pexp_new _ ->
98-
Location.raise_errorf ~loc "OCaml style objects are not supported"
9997
| Pexp_variant (s, None) when Ext_string.is_valid_hash_number s -> (
10098
try ignore (Ext_string.hash_number_as_i32_exn s : int32)
10199
with _ ->

compiler/frontend/bs_ast_mapper.ml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -355,12 +355,6 @@ module E = struct
355355
| Pexp_constraint (e, t) ->
356356
constraint_ ~loc ~attrs (sub.expr sub e) (sub.typ sub t)
357357
| Pexp_send (e, s) -> send ~loc ~attrs (sub.expr sub e) (map_loc sub s)
358-
| Pexp_new lid -> new_ ~loc ~attrs (map_loc sub lid)
359-
| Pexp_setinstvar (s, e) ->
360-
setinstvar ~loc ~attrs (map_loc sub s) (sub.expr sub e)
361-
| Pexp_override sel ->
362-
override ~loc ~attrs
363-
(List.map (map_tuple (map_loc sub) (sub.expr sub)) sel)
364358
| Pexp_letmodule (s, me, e) ->
365359
letmodule ~loc ~attrs (map_loc sub s) (sub.module_expr sub me)
366360
(sub.expr sub e)
@@ -370,8 +364,6 @@ module E = struct
370364
(sub.expr sub e)
371365
| Pexp_assert e -> assert_ ~loc ~attrs (sub.expr sub e)
372366
| Pexp_lazy e -> lazy_ ~loc ~attrs (sub.expr sub e)
373-
| Pexp_poly (e, t) ->
374-
poly ~loc ~attrs (sub.expr sub e) (map_opt (sub.typ sub) t)
375367
| Pexp_newtype (s, e) ->
376368
newtype ~loc ~attrs (map_loc sub s) (sub.expr sub e)
377369
| Pexp_pack me -> pack ~loc ~attrs (sub.module_expr sub me)

compiler/frontend/bs_builtin_ppx.ml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -87,24 +87,6 @@ let expr_mapper ~async_context ~in_function_def (self : mapper)
8787
(* Its output should not be rewritten anymore *)
8888
| Pexp_extension extension ->
8989
Ast_exp_extension.handle_extension e self extension
90-
| Pexp_setinstvar ({txt; loc}, expr) ->
91-
if Stack.is_empty Js_config.self_stack then
92-
Location.raise_errorf ~loc:e.pexp_loc
93-
"This assignment can only happen in object context";
94-
let name = Stack.top Js_config.self_stack in
95-
if name = "" then
96-
Location.raise_errorf ~loc:e.pexp_loc
97-
"The current object does not assign a name";
98-
let open Ast_helper in
99-
self.expr self
100-
(Exp.apply ~loc:e.pexp_loc
101-
(Exp.ident ~loc {loc; txt = Lident "#="})
102-
[
103-
( Nolabel,
104-
Exp.send ~loc (Exp.ident ~loc {loc; txt = Lident name}) {loc; txt}
105-
);
106-
(Nolabel, expr);
107-
])
10890
| Pexp_constant (Pconst_string (s, Some delim)) ->
10991
Ast_utf8_string_interp.transform_exp e s delim
11092
| Pexp_constant (Pconst_integer (s, Some 'l')) ->

compiler/ml/ast_helper.ml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,10 @@ module Exp = struct
172172
let constraint_ ?loc ?attrs a b = mk ?loc ?attrs (Pexp_constraint (a, b))
173173
let coerce ?loc ?attrs a c = mk ?loc ?attrs (Pexp_coerce (a, (), c))
174174
let send ?loc ?attrs a b = mk ?loc ?attrs (Pexp_send (a, b))
175-
let new_ ?loc ?attrs a = mk ?loc ?attrs (Pexp_new a)
176-
let setinstvar ?loc ?attrs a b = mk ?loc ?attrs (Pexp_setinstvar (a, b))
177-
let override ?loc ?attrs a = mk ?loc ?attrs (Pexp_override a)
178175
let letmodule ?loc ?attrs a b c = mk ?loc ?attrs (Pexp_letmodule (a, b, c))
179176
let letexception ?loc ?attrs a b = mk ?loc ?attrs (Pexp_letexception (a, b))
180177
let assert_ ?loc ?attrs a = mk ?loc ?attrs (Pexp_assert a)
181178
let lazy_ ?loc ?attrs a = mk ?loc ?attrs (Pexp_lazy a)
182-
let poly ?loc ?attrs a b = mk ?loc ?attrs (Pexp_poly (a, b))
183179
let newtype ?loc ?attrs a b = mk ?loc ?attrs (Pexp_newtype (a, b))
184180
let pack ?loc ?attrs a = mk ?loc ?attrs (Pexp_pack a)
185181
let open_ ?loc ?attrs a b c = mk ?loc ?attrs (Pexp_open (a, b, c))

compiler/ml/ast_helper.mli

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,6 @@ module Exp : sig
193193
val constraint_ :
194194
?loc:loc -> ?attrs:attrs -> expression -> core_type -> expression
195195
val send : ?loc:loc -> ?attrs:attrs -> expression -> str -> expression
196-
val new_ : ?loc:loc -> ?attrs:attrs -> lid -> expression
197-
val setinstvar : ?loc:loc -> ?attrs:attrs -> str -> expression -> expression
198-
val override :
199-
?loc:loc -> ?attrs:attrs -> (str * expression) list -> expression
200196
val letmodule :
201197
?loc:loc -> ?attrs:attrs -> str -> module_expr -> expression -> expression
202198
val letexception :
@@ -207,8 +203,6 @@ module Exp : sig
207203
expression
208204
val assert_ : ?loc:loc -> ?attrs:attrs -> expression -> expression
209205
val lazy_ : ?loc:loc -> ?attrs:attrs -> expression -> expression
210-
val poly :
211-
?loc:loc -> ?attrs:attrs -> expression -> core_type option -> expression
212206
val newtype : ?loc:loc -> ?attrs:attrs -> str -> expression -> expression
213207
val pack : ?loc:loc -> ?attrs:attrs -> module_expr -> expression
214208
val open_ :

compiler/ml/ast_iterator.ml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,6 @@ module E = struct
333333
sub.expr sub e;
334334
sub.typ sub t
335335
| Pexp_send (e, _s) -> sub.expr sub e
336-
| Pexp_new lid -> iter_loc sub lid
337-
| Pexp_setinstvar (s, e) ->
338-
iter_loc sub s;
339-
sub.expr sub e
340-
| Pexp_override sel ->
341-
List.iter (iter_tuple (iter_loc sub) (sub.expr sub)) sel
342336
| Pexp_letmodule (s, me, e) ->
343337
iter_loc sub s;
344338
sub.module_expr sub me;
@@ -348,9 +342,6 @@ module E = struct
348342
sub.expr sub e
349343
| Pexp_assert e -> sub.expr sub e
350344
| Pexp_lazy e -> sub.expr sub e
351-
| Pexp_poly (e, t) ->
352-
sub.expr sub e;
353-
iter_opt (sub.typ sub) t
354345
| Pexp_newtype (_s, e) -> sub.expr sub e
355346
| Pexp_pack me -> sub.module_expr sub me
356347
| Pexp_open (_ovf, lid, e) ->

0 commit comments

Comments
 (0)