From 1b5b1dc34b1f92ef4d07da8ef9c194ffe222e5d2 Mon Sep 17 00:00:00 2001 From: nojaf Date: Fri, 10 Jan 2025 16:10:20 +0100 Subject: [PATCH 1/8] Remove Pexp_new --- analysis/src/Utils.ml | 1 - compiler/frontend/bs_ast_invariant.ml | 2 -- compiler/frontend/bs_ast_mapper.ml | 1 - compiler/ml/ast_helper.ml | 1 - compiler/ml/ast_helper.mli | 1 - compiler/ml/ast_iterator.ml | 1 - compiler/ml/ast_mapper.ml | 1 - compiler/ml/ast_mapper_from0.ml | 2 +- compiler/ml/ast_mapper_to0.ml | 1 - compiler/ml/depend.ml | 1 - compiler/ml/parsetree.ml | 1 - compiler/ml/pprintast.ml | 1 - compiler/ml/printast.ml | 1 - compiler/ml/typecore.ml | 4 ++-- compiler/syntax/src/res_ast_debugger.ml | 1 - compiler/syntax/src/res_printer.ml | 1 - 16 files changed, 3 insertions(+), 18 deletions(-) diff --git a/analysis/src/Utils.ml b/analysis/src/Utils.ml index 127ceef0f3..03e7ec9a1e 100644 --- a/analysis/src/Utils.ml +++ b/analysis/src/Utils.ml @@ -103,7 +103,6 @@ let identifyPexp pexp = | Pexp_constraint _ -> "Pexp_constraint" | Pexp_coerce _ -> "Pexp_coerce" | Pexp_send _ -> "Pexp_send" - | Pexp_new _ -> "Pexp_new" | Pexp_setinstvar _ -> "Pexp_setinstvar" | Pexp_override _ -> "Pexp_override" | Pexp_letmodule _ -> "Pexp_letmodule" diff --git a/compiler/frontend/bs_ast_invariant.ml b/compiler/frontend/bs_ast_invariant.ml index 6870c6d160..7da08fea57 100644 --- a/compiler/frontend/bs_ast_invariant.ml +++ b/compiler/frontend/bs_ast_invariant.ml @@ -94,8 +94,6 @@ let emit_external_warnings : iterator = (fun self ({pexp_loc = loc} as a) -> match a.pexp_desc with | Pexp_constant const -> check_constant loc const - | Pexp_new _ -> - Location.raise_errorf ~loc "OCaml style objects are not supported" | Pexp_variant (s, None) when Ext_string.is_valid_hash_number s -> ( try ignore (Ext_string.hash_number_as_i32_exn s : int32) with _ -> diff --git a/compiler/frontend/bs_ast_mapper.ml b/compiler/frontend/bs_ast_mapper.ml index 99742c849c..3f5ca1e102 100644 --- a/compiler/frontend/bs_ast_mapper.ml +++ b/compiler/frontend/bs_ast_mapper.ml @@ -354,7 +354,6 @@ module E = struct | Pexp_constraint (e, t) -> constraint_ ~loc ~attrs (sub.expr sub e) (sub.typ sub t) | Pexp_send (e, s) -> send ~loc ~attrs (sub.expr sub e) (map_loc sub s) - | Pexp_new lid -> new_ ~loc ~attrs (map_loc sub lid) | Pexp_setinstvar (s, e) -> setinstvar ~loc ~attrs (map_loc sub s) (sub.expr sub e) | Pexp_override sel -> diff --git a/compiler/ml/ast_helper.ml b/compiler/ml/ast_helper.ml index e9ddd8630b..e8a333c575 100644 --- a/compiler/ml/ast_helper.ml +++ b/compiler/ml/ast_helper.ml @@ -171,7 +171,6 @@ module Exp = struct 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 send ?loc ?attrs a b = mk ?loc ?attrs (Pexp_send (a, b)) - let new_ ?loc ?attrs a = mk ?loc ?attrs (Pexp_new a) let setinstvar ?loc ?attrs a b = mk ?loc ?attrs (Pexp_setinstvar (a, b)) let override ?loc ?attrs a = mk ?loc ?attrs (Pexp_override a) let letmodule ?loc ?attrs a b c = mk ?loc ?attrs (Pexp_letmodule (a, b, c)) diff --git a/compiler/ml/ast_helper.mli b/compiler/ml/ast_helper.mli index 99b5018583..8be8753a25 100644 --- a/compiler/ml/ast_helper.mli +++ b/compiler/ml/ast_helper.mli @@ -192,7 +192,6 @@ module Exp : sig val constraint_ : ?loc:loc -> ?attrs:attrs -> expression -> core_type -> expression val send : ?loc:loc -> ?attrs:attrs -> expression -> str -> expression - val new_ : ?loc:loc -> ?attrs:attrs -> lid -> expression val setinstvar : ?loc:loc -> ?attrs:attrs -> str -> expression -> expression val override : ?loc:loc -> ?attrs:attrs -> (str * expression) list -> expression diff --git a/compiler/ml/ast_iterator.ml b/compiler/ml/ast_iterator.ml index 4013ba4d29..93a5978732 100644 --- a/compiler/ml/ast_iterator.ml +++ b/compiler/ml/ast_iterator.ml @@ -333,7 +333,6 @@ module E = struct sub.expr sub e; sub.typ sub t | Pexp_send (e, _s) -> sub.expr sub e - | Pexp_new lid -> iter_loc sub lid | Pexp_setinstvar (s, e) -> iter_loc sub s; sub.expr sub e diff --git a/compiler/ml/ast_mapper.ml b/compiler/ml/ast_mapper.ml index eb08e516f0..4f6759cd75 100644 --- a/compiler/ml/ast_mapper.ml +++ b/compiler/ml/ast_mapper.ml @@ -317,7 +317,6 @@ module E = struct | Pexp_constraint (e, t) -> constraint_ ~loc ~attrs (sub.expr sub e) (sub.typ sub t) | Pexp_send (e, s) -> send ~loc ~attrs (sub.expr sub e) (map_loc sub s) - | Pexp_new lid -> new_ ~loc ~attrs (map_loc sub lid) | Pexp_setinstvar (s, e) -> setinstvar ~loc ~attrs (map_loc sub s) (sub.expr sub e) | Pexp_override sel -> diff --git a/compiler/ml/ast_mapper_from0.ml b/compiler/ml/ast_mapper_from0.ml index 345354d616..23a87d799d 100644 --- a/compiler/ml/ast_mapper_from0.ml +++ b/compiler/ml/ast_mapper_from0.ml @@ -376,7 +376,7 @@ module E = struct | Pexp_constraint (e, t) -> constraint_ ~loc ~attrs (sub.expr sub e) (sub.typ sub t) | Pexp_send (e, s) -> send ~loc ~attrs (sub.expr sub e) (map_loc sub s) - | Pexp_new lid -> new_ ~loc ~attrs (map_loc sub lid) + | Pexp_new _ -> failwith "Pexp_new is no longer present in ReScript" | Pexp_setinstvar (s, e) -> setinstvar ~loc ~attrs (map_loc sub s) (sub.expr sub e) | Pexp_override sel -> diff --git a/compiler/ml/ast_mapper_to0.ml b/compiler/ml/ast_mapper_to0.ml index c23c292b9b..82faf061c7 100644 --- a/compiler/ml/ast_mapper_to0.ml +++ b/compiler/ml/ast_mapper_to0.ml @@ -365,7 +365,6 @@ module E = struct | Pexp_constraint (e, t) -> constraint_ ~loc ~attrs (sub.expr sub e) (sub.typ sub t) | Pexp_send (e, s) -> send ~loc ~attrs (sub.expr sub e) (map_loc sub s) - | Pexp_new lid -> new_ ~loc ~attrs (map_loc sub lid) | Pexp_setinstvar (s, e) -> setinstvar ~loc ~attrs (map_loc sub s) (sub.expr sub e) | Pexp_override sel -> diff --git a/compiler/ml/depend.ml b/compiler/ml/depend.ml index d7114db984..4f85c4ebb7 100644 --- a/compiler/ml/depend.ml +++ b/compiler/ml/depend.ml @@ -271,7 +271,6 @@ let rec add_expr bv exp = add_expr bv e1; add_type bv ty2 | Pexp_send (e, _m) -> add_expr bv e - | Pexp_new li -> add bv li | Pexp_setinstvar (_v, e) -> add_expr bv e | Pexp_override sel -> List.iter (fun (_s, e) -> add_expr bv e) sel | Pexp_letmodule (id, m, e) -> diff --git a/compiler/ml/parsetree.ml b/compiler/ml/parsetree.ml index d4a75b32e3..c40efb0755 100644 --- a/compiler/ml/parsetree.ml +++ b/compiler/ml/parsetree.ml @@ -291,7 +291,6 @@ and expression_desc = (* (E :> T) (None, T) *) | Pexp_send of expression * label loc (* E # m *) - | Pexp_new of Longident.t loc (* new M.c *) | Pexp_setinstvar of label loc * expression (* x <- 2 *) | Pexp_override of (label loc * expression) list (* {< x1 = E1; ...; Xn = En >} *) diff --git a/compiler/ml/pprintast.ml b/compiler/ml/pprintast.ml index ea826c2689..5548417f8c 100644 --- a/compiler/ml/pprintast.ml +++ b/compiler/ml/pprintast.ml @@ -702,7 +702,6 @@ and expression ctxt f x = in let lst = sequence_helper [] x in pp f "@[%a@]" (list (expression (under_semi ctxt)) ~sep:";@;") lst - | Pexp_new li -> pp f "@[new@ %a@]" longident_loc li | Pexp_setinstvar (s, e) -> pp f "@[%s@ <-@ %a@]" s.txt (expression ctxt) e | Pexp_override l -> diff --git a/compiler/ml/printast.ml b/compiler/ml/printast.ml index b521072bb8..3041d8bc47 100644 --- a/compiler/ml/printast.ml +++ b/compiler/ml/printast.ml @@ -317,7 +317,6 @@ and expression i ppf x = | Pexp_send (e, s) -> line i ppf "Pexp_send \"%s\"\n" s.txt; expression i ppf e - | Pexp_new li -> line i ppf "Pexp_new %a\n" fmt_longident_loc li | Pexp_setinstvar (s, e) -> line i ppf "Pexp_setinstvar %a\n" fmt_string_loc s; expression i ppf e diff --git a/compiler/ml/typecore.ml b/compiler/ml/typecore.ml index 43d834a8e2..1becb2b000 100644 --- a/compiler/ml/typecore.ml +++ b/compiler/ml/typecore.ml @@ -134,7 +134,7 @@ let iter_expression f e = f e; match e.pexp_desc with | Pexp_extension _ (* we don't iterate under extension point *) - | Pexp_ident _ | Pexp_new _ | Pexp_constant _ -> + | Pexp_ident _ | Pexp_constant _ -> () | Pexp_fun {default = eo; rhs = e} -> may expr eo; @@ -3034,7 +3034,7 @@ and type_expect_ ?type_clash_context ?in_function ?(recarg = Rejected) env sexp (Error (e.pexp_loc, env, Undefined_method (obj.exp_type, met, valid_methods))) ) - | Pexp_new _ | Pexp_setinstvar _ | Pexp_override _ -> assert false + | Pexp_setinstvar _ | Pexp_override _ -> assert false | Pexp_letmodule (name, smodl, sbody) -> let ty = newvar () in (* remember original level *) diff --git a/compiler/syntax/src/res_ast_debugger.ml b/compiler/syntax/src/res_ast_debugger.ml index e72230596a..91ad834334 100644 --- a/compiler/syntax/src/res_ast_debugger.ml +++ b/compiler/syntax/src/res_ast_debugger.ml @@ -679,7 +679,6 @@ module SexpAst = struct | Pexp_coerce (expr, (), typexpr) -> Sexp.list [Sexp.atom "Pexp_coerce"; expression expr; core_type typexpr] | Pexp_send _ -> Sexp.list [Sexp.atom "Pexp_send"] - | Pexp_new _ -> Sexp.list [Sexp.atom "Pexp_new"] | Pexp_setinstvar _ -> Sexp.list [Sexp.atom "Pexp_setinstvar"] | Pexp_override _ -> Sexp.list [Sexp.atom "Pexp_override"] | Pexp_letmodule (mod_name, mod_expr, expr) -> diff --git a/compiler/syntax/src/res_printer.ml b/compiler/syntax/src/res_printer.ml index 15a85b6345..a0723a1839 100644 --- a/compiler/syntax/src/res_printer.ml +++ b/compiler/syntax/src/res_printer.ml @@ -3390,7 +3390,6 @@ and print_expression ~state (e : Parsetree.expression) cmt_tbl = Doc.concat [Doc.text "\""; member_doc; Doc.text "\""] in Doc.group (Doc.concat [parent_doc; Doc.lbracket; member; Doc.rbracket]) - | Pexp_new _ -> Doc.text "Pexp_new not implemented in printer" | Pexp_setinstvar _ -> Doc.text "Pexp_setinstvar not implemented in printer" | Pexp_override _ -> Doc.text "Pexp_override not implemented in printer" | Pexp_poly _ -> Doc.text "Pexp_poly not implemented in printer" From 5720ace3f5effd5c78912fa1d7676fec5686bcd3 Mon Sep 17 00:00:00 2001 From: nojaf Date: Fri, 10 Jan 2025 17:14:19 +0100 Subject: [PATCH 2/8] Add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c84d8a9cf8..5c9f01e7a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ - 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 - AST: always put type parameters first in function definitions. https://github.com/rescript-lang/rescript/pull/7233 - 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 +- AST cleanup: Remove `expression_desc.Pexp_new` from the untyped typed AST as it is unused. https://github.com/rescript-lang/rescript/pull/7239 # 12.0.0-alpha.7 From 09d0b7b7db5a21415311928a071210ea6be5ec89 Mon Sep 17 00:00:00 2001 From: nojaf Date: Fri, 10 Jan 2025 19:10:20 +0100 Subject: [PATCH 3/8] Remove Pexp_setinstvar --- analysis/src/Utils.ml | 1 - compiler/frontend/bs_ast_mapper.ml | 2 -- compiler/frontend/bs_builtin_ppx.ml | 18 ------------------ compiler/ml/ast_helper.ml | 1 - compiler/ml/ast_helper.mli | 1 - compiler/ml/ast_iterator.ml | 3 --- compiler/ml/ast_mapper.ml | 2 -- compiler/ml/ast_mapper_from0.ml | 4 ++-- compiler/ml/ast_mapper_to0.ml | 2 -- compiler/ml/depend.ml | 1 - compiler/ml/parsetree.ml | 1 - compiler/ml/pprintast.ml | 2 -- compiler/ml/printast.ml | 3 --- compiler/ml/typecore.ml | 3 +-- compiler/syntax/src/res_ast_debugger.ml | 1 - compiler/syntax/src/res_printer.ml | 1 - 16 files changed, 3 insertions(+), 43 deletions(-) diff --git a/analysis/src/Utils.ml b/analysis/src/Utils.ml index 03e7ec9a1e..7fcb3f3f0e 100644 --- a/analysis/src/Utils.ml +++ b/analysis/src/Utils.ml @@ -103,7 +103,6 @@ let identifyPexp pexp = | Pexp_constraint _ -> "Pexp_constraint" | Pexp_coerce _ -> "Pexp_coerce" | Pexp_send _ -> "Pexp_send" - | Pexp_setinstvar _ -> "Pexp_setinstvar" | Pexp_override _ -> "Pexp_override" | Pexp_letmodule _ -> "Pexp_letmodule" | Pexp_letexception _ -> "Pexp_letexception" diff --git a/compiler/frontend/bs_ast_mapper.ml b/compiler/frontend/bs_ast_mapper.ml index 3f5ca1e102..83a57a9351 100644 --- a/compiler/frontend/bs_ast_mapper.ml +++ b/compiler/frontend/bs_ast_mapper.ml @@ -354,8 +354,6 @@ module E = struct | Pexp_constraint (e, t) -> constraint_ ~loc ~attrs (sub.expr sub e) (sub.typ sub t) | Pexp_send (e, s) -> send ~loc ~attrs (sub.expr sub e) (map_loc sub s) - | Pexp_setinstvar (s, e) -> - setinstvar ~loc ~attrs (map_loc sub s) (sub.expr sub e) | Pexp_override sel -> override ~loc ~attrs (List.map (map_tuple (map_loc sub) (sub.expr sub)) sel) diff --git a/compiler/frontend/bs_builtin_ppx.ml b/compiler/frontend/bs_builtin_ppx.ml index 054a9976a3..b15a683ddd 100644 --- a/compiler/frontend/bs_builtin_ppx.ml +++ b/compiler/frontend/bs_builtin_ppx.ml @@ -87,24 +87,6 @@ let expr_mapper ~async_context ~in_function_def (self : mapper) (* Its output should not be rewritten anymore *) | Pexp_extension extension -> Ast_exp_extension.handle_extension e self extension - | Pexp_setinstvar ({txt; loc}, expr) -> - if Stack.is_empty Js_config.self_stack then - Location.raise_errorf ~loc:e.pexp_loc - "This assignment can only happen in object context"; - let name = Stack.top Js_config.self_stack in - if name = "" then - Location.raise_errorf ~loc:e.pexp_loc - "The current object does not assign a name"; - let open Ast_helper in - self.expr self - (Exp.apply ~loc:e.pexp_loc - (Exp.ident ~loc {loc; txt = Lident "#="}) - [ - ( Nolabel, - Exp.send ~loc (Exp.ident ~loc {loc; txt = Lident name}) {loc; txt} - ); - (Nolabel, expr); - ]) | Pexp_constant (Pconst_string (s, Some delim)) -> Ast_utf8_string_interp.transform_exp e s delim | Pexp_constant (Pconst_integer (s, Some 'l')) -> diff --git a/compiler/ml/ast_helper.ml b/compiler/ml/ast_helper.ml index e8a333c575..cf19a669a8 100644 --- a/compiler/ml/ast_helper.ml +++ b/compiler/ml/ast_helper.ml @@ -171,7 +171,6 @@ module Exp = struct 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 send ?loc ?attrs a b = mk ?loc ?attrs (Pexp_send (a, b)) - let setinstvar ?loc ?attrs a b = mk ?loc ?attrs (Pexp_setinstvar (a, b)) let override ?loc ?attrs a = mk ?loc ?attrs (Pexp_override a) let letmodule ?loc ?attrs a b c = mk ?loc ?attrs (Pexp_letmodule (a, b, c)) let letexception ?loc ?attrs a b = mk ?loc ?attrs (Pexp_letexception (a, b)) diff --git a/compiler/ml/ast_helper.mli b/compiler/ml/ast_helper.mli index 8be8753a25..35028fe4ed 100644 --- a/compiler/ml/ast_helper.mli +++ b/compiler/ml/ast_helper.mli @@ -192,7 +192,6 @@ module Exp : sig val constraint_ : ?loc:loc -> ?attrs:attrs -> expression -> core_type -> expression val send : ?loc:loc -> ?attrs:attrs -> expression -> str -> expression - val setinstvar : ?loc:loc -> ?attrs:attrs -> str -> expression -> expression val override : ?loc:loc -> ?attrs:attrs -> (str * expression) list -> expression val letmodule : diff --git a/compiler/ml/ast_iterator.ml b/compiler/ml/ast_iterator.ml index 93a5978732..2a11a99d96 100644 --- a/compiler/ml/ast_iterator.ml +++ b/compiler/ml/ast_iterator.ml @@ -333,9 +333,6 @@ module E = struct sub.expr sub e; sub.typ sub t | Pexp_send (e, _s) -> sub.expr sub e - | Pexp_setinstvar (s, e) -> - iter_loc sub s; - sub.expr sub e | Pexp_override sel -> List.iter (iter_tuple (iter_loc sub) (sub.expr sub)) sel | Pexp_letmodule (s, me, e) -> diff --git a/compiler/ml/ast_mapper.ml b/compiler/ml/ast_mapper.ml index 4f6759cd75..fdb42d772d 100644 --- a/compiler/ml/ast_mapper.ml +++ b/compiler/ml/ast_mapper.ml @@ -317,8 +317,6 @@ module E = struct | Pexp_constraint (e, t) -> constraint_ ~loc ~attrs (sub.expr sub e) (sub.typ sub t) | Pexp_send (e, s) -> send ~loc ~attrs (sub.expr sub e) (map_loc sub s) - | Pexp_setinstvar (s, e) -> - setinstvar ~loc ~attrs (map_loc sub s) (sub.expr sub e) | Pexp_override sel -> override ~loc ~attrs (List.map (map_tuple (map_loc sub) (sub.expr sub)) sel) diff --git a/compiler/ml/ast_mapper_from0.ml b/compiler/ml/ast_mapper_from0.ml index 23a87d799d..c486e679cd 100644 --- a/compiler/ml/ast_mapper_from0.ml +++ b/compiler/ml/ast_mapper_from0.ml @@ -377,8 +377,8 @@ module E = struct constraint_ ~loc ~attrs (sub.expr sub e) (sub.typ sub t) | Pexp_send (e, s) -> send ~loc ~attrs (sub.expr sub e) (map_loc sub s) | Pexp_new _ -> failwith "Pexp_new is no longer present in ReScript" - | Pexp_setinstvar (s, e) -> - setinstvar ~loc ~attrs (map_loc sub s) (sub.expr sub e) + | Pexp_setinstvar _ -> + failwith "Pexp_setinstvar is no longer present in ReScript" | Pexp_override sel -> override ~loc ~attrs (List.map (map_tuple (map_loc sub) (sub.expr sub)) sel) diff --git a/compiler/ml/ast_mapper_to0.ml b/compiler/ml/ast_mapper_to0.ml index 82faf061c7..2adf42693e 100644 --- a/compiler/ml/ast_mapper_to0.ml +++ b/compiler/ml/ast_mapper_to0.ml @@ -365,8 +365,6 @@ module E = struct | Pexp_constraint (e, t) -> constraint_ ~loc ~attrs (sub.expr sub e) (sub.typ sub t) | Pexp_send (e, s) -> send ~loc ~attrs (sub.expr sub e) (map_loc sub s) - | Pexp_setinstvar (s, e) -> - setinstvar ~loc ~attrs (map_loc sub s) (sub.expr sub e) | Pexp_override sel -> override ~loc ~attrs (List.map (map_tuple (map_loc sub) (sub.expr sub)) sel) diff --git a/compiler/ml/depend.ml b/compiler/ml/depend.ml index 4f85c4ebb7..20d60c1467 100644 --- a/compiler/ml/depend.ml +++ b/compiler/ml/depend.ml @@ -271,7 +271,6 @@ let rec add_expr bv exp = add_expr bv e1; add_type bv ty2 | Pexp_send (e, _m) -> add_expr bv e - | Pexp_setinstvar (_v, e) -> add_expr bv e | Pexp_override sel -> List.iter (fun (_s, e) -> add_expr bv e) sel | Pexp_letmodule (id, m, e) -> let b = add_module_binding bv m in diff --git a/compiler/ml/parsetree.ml b/compiler/ml/parsetree.ml index c40efb0755..45edd23132 100644 --- a/compiler/ml/parsetree.ml +++ b/compiler/ml/parsetree.ml @@ -291,7 +291,6 @@ and expression_desc = (* (E :> T) (None, T) *) | Pexp_send of expression * label loc (* E # m *) - | Pexp_setinstvar of label loc * expression (* x <- 2 *) | Pexp_override of (label loc * expression) list (* {< x1 = E1; ...; Xn = En >} *) | Pexp_letmodule of string loc * module_expr * expression diff --git a/compiler/ml/pprintast.ml b/compiler/ml/pprintast.ml index 5548417f8c..d311aae197 100644 --- a/compiler/ml/pprintast.ml +++ b/compiler/ml/pprintast.ml @@ -702,8 +702,6 @@ and expression ctxt f x = in let lst = sequence_helper [] x in pp f "@[%a@]" (list (expression (under_semi ctxt)) ~sep:";@;") lst - | Pexp_setinstvar (s, e) -> - pp f "@[%s@ <-@ %a@]" s.txt (expression ctxt) e | Pexp_override l -> (* FIXME *) let string_x_expression f (s, e) = diff --git a/compiler/ml/printast.ml b/compiler/ml/printast.ml index 3041d8bc47..ce8498c37d 100644 --- a/compiler/ml/printast.ml +++ b/compiler/ml/printast.ml @@ -317,9 +317,6 @@ and expression i ppf x = | Pexp_send (e, s) -> line i ppf "Pexp_send \"%s\"\n" s.txt; expression i ppf e - | Pexp_setinstvar (s, e) -> - line i ppf "Pexp_setinstvar %a\n" fmt_string_loc s; - expression i ppf e | Pexp_override l -> line i ppf "Pexp_override\n"; list i string_x_expression ppf l diff --git a/compiler/ml/typecore.ml b/compiler/ml/typecore.ml index 1becb2b000..7f518d4e6e 100644 --- a/compiler/ml/typecore.ml +++ b/compiler/ml/typecore.ml @@ -158,7 +158,6 @@ let iter_expression f e = | Pexp_poly (e, _) | Pexp_lazy e | Pexp_assert e - | Pexp_setinstvar (_, e) | Pexp_send (e, _) | Pexp_constraint (e, _) | Pexp_coerce (e, _, _) @@ -3034,7 +3033,7 @@ and type_expect_ ?type_clash_context ?in_function ?(recarg = Rejected) env sexp (Error (e.pexp_loc, env, Undefined_method (obj.exp_type, met, valid_methods))) ) - | Pexp_setinstvar _ | Pexp_override _ -> assert false + | Pexp_override _ -> assert false | Pexp_letmodule (name, smodl, sbody) -> let ty = newvar () in (* remember original level *) diff --git a/compiler/syntax/src/res_ast_debugger.ml b/compiler/syntax/src/res_ast_debugger.ml index 91ad834334..7627968392 100644 --- a/compiler/syntax/src/res_ast_debugger.ml +++ b/compiler/syntax/src/res_ast_debugger.ml @@ -679,7 +679,6 @@ module SexpAst = struct | Pexp_coerce (expr, (), typexpr) -> Sexp.list [Sexp.atom "Pexp_coerce"; expression expr; core_type typexpr] | Pexp_send _ -> Sexp.list [Sexp.atom "Pexp_send"] - | Pexp_setinstvar _ -> Sexp.list [Sexp.atom "Pexp_setinstvar"] | Pexp_override _ -> Sexp.list [Sexp.atom "Pexp_override"] | Pexp_letmodule (mod_name, mod_expr, expr) -> Sexp.list diff --git a/compiler/syntax/src/res_printer.ml b/compiler/syntax/src/res_printer.ml index a0723a1839..950b93c20e 100644 --- a/compiler/syntax/src/res_printer.ml +++ b/compiler/syntax/src/res_printer.ml @@ -3390,7 +3390,6 @@ and print_expression ~state (e : Parsetree.expression) cmt_tbl = Doc.concat [Doc.text "\""; member_doc; Doc.text "\""] in Doc.group (Doc.concat [parent_doc; Doc.lbracket; member; Doc.rbracket]) - | Pexp_setinstvar _ -> Doc.text "Pexp_setinstvar not implemented in printer" | Pexp_override _ -> Doc.text "Pexp_override not implemented in printer" | Pexp_poly _ -> Doc.text "Pexp_poly not implemented in printer" in From be8aedde2c054e27200e3daf3a54ae787eca5d8c Mon Sep 17 00:00:00 2001 From: nojaf Date: Fri, 10 Jan 2025 19:17:26 +0100 Subject: [PATCH 4/8] Remove Pexp_override --- CHANGELOG.md | 2 +- analysis/src/Utils.ml | 1 - compiler/frontend/bs_ast_mapper.ml | 3 --- compiler/ml/ast_helper.ml | 1 - compiler/ml/ast_helper.mli | 2 -- compiler/ml/ast_iterator.ml | 2 -- compiler/ml/ast_mapper.ml | 3 --- compiler/ml/ast_mapper_from0.ml | 5 ++--- compiler/ml/ast_mapper_to0.ml | 3 --- compiler/ml/depend.ml | 1 - compiler/ml/parsetree.ml | 2 -- compiler/ml/pprintast.ml | 6 ------ compiler/ml/printast.ml | 7 ------- compiler/ml/typecore.ml | 2 -- compiler/syntax/src/res_ast_debugger.ml | 1 - compiler/syntax/src/res_printer.ml | 1 - 16 files changed, 3 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c9f01e7a1..90bc49b9b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,7 @@ - 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 - AST: always put type parameters first in function definitions. https://github.com/rescript-lang/rescript/pull/7233 - 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 -- AST cleanup: Remove `expression_desc.Pexp_new` from the untyped typed AST as it is unused. https://github.com/rescript-lang/rescript/pull/7239 +- AST cleanup: Remove `expression_desc.Pexp_new`, `expression_desc.Pexp_setinstvar` & `expression_desc.Pexp_override` from the untyped typed AST as it is unused. https://github.com/rescript-lang/rescript/pull/7239 # 12.0.0-alpha.7 diff --git a/analysis/src/Utils.ml b/analysis/src/Utils.ml index 7fcb3f3f0e..ae59178d70 100644 --- a/analysis/src/Utils.ml +++ b/analysis/src/Utils.ml @@ -103,7 +103,6 @@ let identifyPexp pexp = | Pexp_constraint _ -> "Pexp_constraint" | Pexp_coerce _ -> "Pexp_coerce" | Pexp_send _ -> "Pexp_send" - | Pexp_override _ -> "Pexp_override" | Pexp_letmodule _ -> "Pexp_letmodule" | Pexp_letexception _ -> "Pexp_letexception" | Pexp_assert _ -> "Pexp_assert" diff --git a/compiler/frontend/bs_ast_mapper.ml b/compiler/frontend/bs_ast_mapper.ml index 83a57a9351..8788932848 100644 --- a/compiler/frontend/bs_ast_mapper.ml +++ b/compiler/frontend/bs_ast_mapper.ml @@ -354,9 +354,6 @@ module E = struct | Pexp_constraint (e, t) -> constraint_ ~loc ~attrs (sub.expr sub e) (sub.typ sub t) | Pexp_send (e, s) -> send ~loc ~attrs (sub.expr sub e) (map_loc sub s) - | Pexp_override sel -> - override ~loc ~attrs - (List.map (map_tuple (map_loc sub) (sub.expr sub)) sel) | Pexp_letmodule (s, me, e) -> letmodule ~loc ~attrs (map_loc sub s) (sub.module_expr sub me) (sub.expr sub e) diff --git a/compiler/ml/ast_helper.ml b/compiler/ml/ast_helper.ml index cf19a669a8..c01771ef4f 100644 --- a/compiler/ml/ast_helper.ml +++ b/compiler/ml/ast_helper.ml @@ -171,7 +171,6 @@ module Exp = struct 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 send ?loc ?attrs a b = mk ?loc ?attrs (Pexp_send (a, b)) - let override ?loc ?attrs a = mk ?loc ?attrs (Pexp_override a) let letmodule ?loc ?attrs a b c = mk ?loc ?attrs (Pexp_letmodule (a, b, c)) let letexception ?loc ?attrs a b = mk ?loc ?attrs (Pexp_letexception (a, b)) let assert_ ?loc ?attrs a = mk ?loc ?attrs (Pexp_assert a) diff --git a/compiler/ml/ast_helper.mli b/compiler/ml/ast_helper.mli index 35028fe4ed..329b1201b4 100644 --- a/compiler/ml/ast_helper.mli +++ b/compiler/ml/ast_helper.mli @@ -192,8 +192,6 @@ module Exp : sig val constraint_ : ?loc:loc -> ?attrs:attrs -> expression -> core_type -> expression val send : ?loc:loc -> ?attrs:attrs -> expression -> str -> expression - val override : - ?loc:loc -> ?attrs:attrs -> (str * expression) list -> expression val letmodule : ?loc:loc -> ?attrs:attrs -> str -> module_expr -> expression -> expression val letexception : diff --git a/compiler/ml/ast_iterator.ml b/compiler/ml/ast_iterator.ml index 2a11a99d96..e9d206446f 100644 --- a/compiler/ml/ast_iterator.ml +++ b/compiler/ml/ast_iterator.ml @@ -333,8 +333,6 @@ module E = struct sub.expr sub e; sub.typ sub t | Pexp_send (e, _s) -> sub.expr sub e - | Pexp_override sel -> - List.iter (iter_tuple (iter_loc sub) (sub.expr sub)) sel | Pexp_letmodule (s, me, e) -> iter_loc sub s; sub.module_expr sub me; diff --git a/compiler/ml/ast_mapper.ml b/compiler/ml/ast_mapper.ml index fdb42d772d..4b55df4dec 100644 --- a/compiler/ml/ast_mapper.ml +++ b/compiler/ml/ast_mapper.ml @@ -317,9 +317,6 @@ module E = struct | Pexp_constraint (e, t) -> constraint_ ~loc ~attrs (sub.expr sub e) (sub.typ sub t) | Pexp_send (e, s) -> send ~loc ~attrs (sub.expr sub e) (map_loc sub s) - | Pexp_override sel -> - override ~loc ~attrs - (List.map (map_tuple (map_loc sub) (sub.expr sub)) sel) | Pexp_letmodule (s, me, e) -> letmodule ~loc ~attrs (map_loc sub s) (sub.module_expr sub me) (sub.expr sub e) diff --git a/compiler/ml/ast_mapper_from0.ml b/compiler/ml/ast_mapper_from0.ml index c486e679cd..fd370acb43 100644 --- a/compiler/ml/ast_mapper_from0.ml +++ b/compiler/ml/ast_mapper_from0.ml @@ -379,9 +379,8 @@ module E = struct | Pexp_new _ -> failwith "Pexp_new is no longer present in ReScript" | Pexp_setinstvar _ -> failwith "Pexp_setinstvar is no longer present in ReScript" - | Pexp_override sel -> - override ~loc ~attrs - (List.map (map_tuple (map_loc sub) (sub.expr sub)) sel) + | Pexp_override _ -> + failwith "Pexp_override is no longer present in ReScript" | Pexp_letmodule (s, me, e) -> letmodule ~loc ~attrs (map_loc sub s) (sub.module_expr sub me) (sub.expr sub e) diff --git a/compiler/ml/ast_mapper_to0.ml b/compiler/ml/ast_mapper_to0.ml index 2adf42693e..ce899c6ba0 100644 --- a/compiler/ml/ast_mapper_to0.ml +++ b/compiler/ml/ast_mapper_to0.ml @@ -365,9 +365,6 @@ module E = struct | Pexp_constraint (e, t) -> constraint_ ~loc ~attrs (sub.expr sub e) (sub.typ sub t) | Pexp_send (e, s) -> send ~loc ~attrs (sub.expr sub e) (map_loc sub s) - | Pexp_override sel -> - override ~loc ~attrs - (List.map (map_tuple (map_loc sub) (sub.expr sub)) sel) | Pexp_letmodule (s, me, e) -> letmodule ~loc ~attrs (map_loc sub s) (sub.module_expr sub me) (sub.expr sub e) diff --git a/compiler/ml/depend.ml b/compiler/ml/depend.ml index 20d60c1467..557046dba0 100644 --- a/compiler/ml/depend.ml +++ b/compiler/ml/depend.ml @@ -271,7 +271,6 @@ let rec add_expr bv exp = add_expr bv e1; add_type bv ty2 | Pexp_send (e, _m) -> add_expr bv e - | Pexp_override sel -> List.iter (fun (_s, e) -> add_expr bv e) sel | Pexp_letmodule (id, m, e) -> let b = add_module_binding bv m in add_expr (StringMap.add id.txt b bv) e diff --git a/compiler/ml/parsetree.ml b/compiler/ml/parsetree.ml index 45edd23132..8750341ddb 100644 --- a/compiler/ml/parsetree.ml +++ b/compiler/ml/parsetree.ml @@ -291,8 +291,6 @@ and expression_desc = (* (E :> T) (None, T) *) | Pexp_send of expression * label loc (* E # m *) - | Pexp_override of (label loc * expression) list - (* {< x1 = E1; ...; Xn = En >} *) | Pexp_letmodule of string loc * module_expr * expression (* let module M = ME in E *) | Pexp_letexception of extension_constructor * expression diff --git a/compiler/ml/pprintast.ml b/compiler/ml/pprintast.ml index d311aae197..d2d6b8daa9 100644 --- a/compiler/ml/pprintast.ml +++ b/compiler/ml/pprintast.ml @@ -702,12 +702,6 @@ and expression ctxt f x = in let lst = sequence_helper [] x in pp f "@[%a@]" (list (expression (under_semi ctxt)) ~sep:";@;") lst - | Pexp_override l -> - (* FIXME *) - let string_x_expression f (s, e) = - pp f "@[%s@ =@ %a@]" s.txt (expression ctxt) e - in - pp f "@[{<%a>}@]" (list string_x_expression ~sep:";") l | Pexp_letmodule (s, me, e) -> pp f "@[let@ module@ %s@ =@ %a@ in@ %a@]" s.txt (module_expr reset_ctxt) me (expression ctxt) e diff --git a/compiler/ml/printast.ml b/compiler/ml/printast.ml index ce8498c37d..afb4331761 100644 --- a/compiler/ml/printast.ml +++ b/compiler/ml/printast.ml @@ -317,9 +317,6 @@ and expression i ppf x = | Pexp_send (e, s) -> line i ppf "Pexp_send \"%s\"\n" s.txt; expression i ppf e - | Pexp_override l -> - line i ppf "Pexp_override\n"; - list i string_x_expression ppf l | Pexp_letmodule (s, me, e) -> line i ppf "Pexp_letmodule %a\n" fmt_string_loc s; module_expr i ppf me; @@ -661,10 +658,6 @@ and value_binding i ppf x = pattern (i + 1) ppf x.pvb_pat; expression (i + 1) ppf x.pvb_expr -and string_x_expression i ppf (s, e) = - line i ppf " %a\n" fmt_string_loc s; - expression (i + 1) ppf e - and longident_x_expression i ppf (li, e, opt) = line i ppf "%a%s\n" fmt_longident_loc li (if opt then "?" else ""); expression (i + 1) ppf e diff --git a/compiler/ml/typecore.ml b/compiler/ml/typecore.ml index 7f518d4e6e..92adf78f0c 100644 --- a/compiler/ml/typecore.ml +++ b/compiler/ml/typecore.ml @@ -176,7 +176,6 @@ let iter_expression f e = expr e1; expr e2; expr e3 - | Pexp_override sel -> List.iter (fun (_, e) -> expr e) sel | Pexp_letmodule (_, me, e) -> expr e; module_expr me @@ -3033,7 +3032,6 @@ and type_expect_ ?type_clash_context ?in_function ?(recarg = Rejected) env sexp (Error (e.pexp_loc, env, Undefined_method (obj.exp_type, met, valid_methods))) ) - | Pexp_override _ -> assert false | Pexp_letmodule (name, smodl, sbody) -> let ty = newvar () in (* remember original level *) diff --git a/compiler/syntax/src/res_ast_debugger.ml b/compiler/syntax/src/res_ast_debugger.ml index 7627968392..2205e55b32 100644 --- a/compiler/syntax/src/res_ast_debugger.ml +++ b/compiler/syntax/src/res_ast_debugger.ml @@ -679,7 +679,6 @@ module SexpAst = struct | Pexp_coerce (expr, (), typexpr) -> Sexp.list [Sexp.atom "Pexp_coerce"; expression expr; core_type typexpr] | Pexp_send _ -> Sexp.list [Sexp.atom "Pexp_send"] - | Pexp_override _ -> Sexp.list [Sexp.atom "Pexp_override"] | Pexp_letmodule (mod_name, mod_expr, expr) -> Sexp.list [ diff --git a/compiler/syntax/src/res_printer.ml b/compiler/syntax/src/res_printer.ml index 950b93c20e..e1b5568269 100644 --- a/compiler/syntax/src/res_printer.ml +++ b/compiler/syntax/src/res_printer.ml @@ -3390,7 +3390,6 @@ and print_expression ~state (e : Parsetree.expression) cmt_tbl = Doc.concat [Doc.text "\""; member_doc; Doc.text "\""] in Doc.group (Doc.concat [parent_doc; Doc.lbracket; member; Doc.rbracket]) - | Pexp_override _ -> Doc.text "Pexp_override not implemented in printer" | Pexp_poly _ -> Doc.text "Pexp_poly not implemented in printer" in let expr_with_await = From 4f4b88c82d69cebfb90a9c667f96f2bb2c1336d7 Mon Sep 17 00:00:00 2001 From: nojaf Date: Fri, 10 Jan 2025 19:29:18 +0100 Subject: [PATCH 5/8] Try removing Pexp_poly --- analysis/src/Utils.ml | 1 - compiler/frontend/bs_ast_mapper.ml | 2 -- compiler/ml/ast_helper.ml | 1 - compiler/ml/ast_helper.mli | 2 -- compiler/ml/ast_iterator.ml | 3 -- compiler/ml/ast_mapper.ml | 2 -- compiler/ml/ast_mapper_from0.ml | 3 +- compiler/ml/ast_mapper_to0.ml | 2 -- compiler/ml/depend.ml | 3 -- compiler/ml/parsetree.ml | 5 ---- compiler/ml/pprintast.ml | 6 ---- compiler/ml/printast.ml | 4 --- compiler/ml/typecore.ml | 37 ------------------------- compiler/syntax/src/res_ast_debugger.ml | 1 - compiler/syntax/src/res_printer.ml | 1 - 15 files changed, 1 insertion(+), 72 deletions(-) diff --git a/analysis/src/Utils.ml b/analysis/src/Utils.ml index ae59178d70..c274b5a9fb 100644 --- a/analysis/src/Utils.ml +++ b/analysis/src/Utils.ml @@ -107,7 +107,6 @@ let identifyPexp pexp = | Pexp_letexception _ -> "Pexp_letexception" | Pexp_assert _ -> "Pexp_assert" | Pexp_lazy _ -> "Pexp_lazy" - | Pexp_poly _ -> "Pexp_poly" | Pexp_newtype _ -> "Pexp_newtype" | Pexp_pack _ -> "Pexp_pack" | Pexp_extension _ -> "Pexp_extension" diff --git a/compiler/frontend/bs_ast_mapper.ml b/compiler/frontend/bs_ast_mapper.ml index 8788932848..082a0dcf58 100644 --- a/compiler/frontend/bs_ast_mapper.ml +++ b/compiler/frontend/bs_ast_mapper.ml @@ -363,8 +363,6 @@ module E = struct (sub.expr sub e) | Pexp_assert e -> assert_ ~loc ~attrs (sub.expr sub e) | Pexp_lazy e -> lazy_ ~loc ~attrs (sub.expr sub e) - | Pexp_poly (e, t) -> - poly ~loc ~attrs (sub.expr sub e) (map_opt (sub.typ sub) t) | Pexp_newtype (s, e) -> newtype ~loc ~attrs (map_loc sub s) (sub.expr sub e) | Pexp_pack me -> pack ~loc ~attrs (sub.module_expr sub me) diff --git a/compiler/ml/ast_helper.ml b/compiler/ml/ast_helper.ml index c01771ef4f..a1eec7548e 100644 --- a/compiler/ml/ast_helper.ml +++ b/compiler/ml/ast_helper.ml @@ -175,7 +175,6 @@ module Exp = struct let letexception ?loc ?attrs a b = mk ?loc ?attrs (Pexp_letexception (a, b)) let assert_ ?loc ?attrs a = mk ?loc ?attrs (Pexp_assert a) let lazy_ ?loc ?attrs a = mk ?loc ?attrs (Pexp_lazy a) - let poly ?loc ?attrs a b = mk ?loc ?attrs (Pexp_poly (a, b)) let newtype ?loc ?attrs a b = mk ?loc ?attrs (Pexp_newtype (a, b)) let pack ?loc ?attrs a = mk ?loc ?attrs (Pexp_pack a) let open_ ?loc ?attrs a b c = mk ?loc ?attrs (Pexp_open (a, b, c)) diff --git a/compiler/ml/ast_helper.mli b/compiler/ml/ast_helper.mli index 329b1201b4..f11b17a46a 100644 --- a/compiler/ml/ast_helper.mli +++ b/compiler/ml/ast_helper.mli @@ -202,8 +202,6 @@ module Exp : sig expression val assert_ : ?loc:loc -> ?attrs:attrs -> expression -> expression val lazy_ : ?loc:loc -> ?attrs:attrs -> expression -> expression - val poly : - ?loc:loc -> ?attrs:attrs -> expression -> core_type option -> expression val newtype : ?loc:loc -> ?attrs:attrs -> str -> expression -> expression val pack : ?loc:loc -> ?attrs:attrs -> module_expr -> expression val open_ : diff --git a/compiler/ml/ast_iterator.ml b/compiler/ml/ast_iterator.ml index e9d206446f..950fc7964c 100644 --- a/compiler/ml/ast_iterator.ml +++ b/compiler/ml/ast_iterator.ml @@ -342,9 +342,6 @@ module E = struct sub.expr sub e | Pexp_assert e -> sub.expr sub e | Pexp_lazy e -> sub.expr sub e - | Pexp_poly (e, t) -> - sub.expr sub e; - iter_opt (sub.typ sub) t | Pexp_newtype (_s, e) -> sub.expr sub e | Pexp_pack me -> sub.module_expr sub me | Pexp_open (_ovf, lid, e) -> diff --git a/compiler/ml/ast_mapper.ml b/compiler/ml/ast_mapper.ml index 4b55df4dec..2d93a59fb6 100644 --- a/compiler/ml/ast_mapper.ml +++ b/compiler/ml/ast_mapper.ml @@ -326,8 +326,6 @@ module E = struct (sub.expr sub e) | Pexp_assert e -> assert_ ~loc ~attrs (sub.expr sub e) | Pexp_lazy e -> lazy_ ~loc ~attrs (sub.expr sub e) - | Pexp_poly (e, t) -> - poly ~loc ~attrs (sub.expr sub e) (map_opt (sub.typ sub) t) | Pexp_newtype (s, e) -> newtype ~loc ~attrs (map_loc sub s) (sub.expr sub e) | Pexp_pack me -> pack ~loc ~attrs (sub.module_expr sub me) diff --git a/compiler/ml/ast_mapper_from0.ml b/compiler/ml/ast_mapper_from0.ml index fd370acb43..398c42bdbe 100644 --- a/compiler/ml/ast_mapper_from0.ml +++ b/compiler/ml/ast_mapper_from0.ml @@ -390,8 +390,7 @@ module E = struct (sub.expr sub e) | Pexp_assert e -> assert_ ~loc ~attrs (sub.expr sub e) | Pexp_lazy e -> lazy_ ~loc ~attrs (sub.expr sub e) - | Pexp_poly (e, t) -> - poly ~loc ~attrs (sub.expr sub e) (map_opt (sub.typ sub) t) + | Pexp_poly _ -> failwith "Pexp_poly is no longer present in ReScript" | Pexp_object () -> assert false | Pexp_newtype (s, e) -> newtype ~loc ~attrs (map_loc sub s) (sub.expr sub e) diff --git a/compiler/ml/ast_mapper_to0.ml b/compiler/ml/ast_mapper_to0.ml index ce899c6ba0..31ec18fc58 100644 --- a/compiler/ml/ast_mapper_to0.ml +++ b/compiler/ml/ast_mapper_to0.ml @@ -374,8 +374,6 @@ module E = struct (sub.expr sub e) | Pexp_assert e -> assert_ ~loc ~attrs (sub.expr sub e) | Pexp_lazy e -> lazy_ ~loc ~attrs (sub.expr sub e) - | Pexp_poly (e, t) -> - poly ~loc ~attrs (sub.expr sub e) (map_opt (sub.typ sub) t) | Pexp_newtype (s, e) -> newtype ~loc ~attrs (map_loc sub s) (sub.expr sub e) | Pexp_pack me -> pack ~loc ~attrs (sub.module_expr sub me) diff --git a/compiler/ml/depend.ml b/compiler/ml/depend.ml index 557046dba0..e762a729d4 100644 --- a/compiler/ml/depend.ml +++ b/compiler/ml/depend.ml @@ -277,9 +277,6 @@ let rec add_expr bv exp = | Pexp_letexception (_, e) -> add_expr bv e | Pexp_assert e -> add_expr bv e | Pexp_lazy e -> add_expr bv e - | Pexp_poly (e, t) -> - add_expr bv e; - add_opt add_type bv t | Pexp_newtype (_, e) -> add_expr bv e | Pexp_pack m -> add_module bv m | Pexp_open (_ovf, m, e) -> diff --git a/compiler/ml/parsetree.ml b/compiler/ml/parsetree.ml index 8750341ddb..c64e98933a 100644 --- a/compiler/ml/parsetree.ml +++ b/compiler/ml/parsetree.ml @@ -300,11 +300,6 @@ and expression_desc = Note: "assert false" is treated in a special way by the type-checker. *) | Pexp_lazy of expression (* lazy E *) - | Pexp_poly of expression * core_type option - (* Used for method bodies. - - Can only be used as the expression under Cfk_concrete - for methods (not values). *) | Pexp_newtype of string loc * expression (* fun (type t) -> E *) | Pexp_pack of module_expr (* (module ME) diff --git a/compiler/ml/pprintast.ml b/compiler/ml/pprintast.ml index d2d6b8daa9..925cf5f318 100644 --- a/compiler/ml/pprintast.ml +++ b/compiler/ml/pprintast.ml @@ -711,12 +711,6 @@ and expression ctxt f x = cd (expression ctxt) e | Pexp_assert e -> pp f "@[assert@ %a@]" (simple_expr ctxt) e | Pexp_lazy e -> pp f "@[lazy@ %a@]" (simple_expr ctxt) e - (* Pexp_poly: impossible but we should print it anyway, rather than - assert false *) - | Pexp_poly (e, None) -> pp f "@[!poly!@ %a@]" (simple_expr ctxt) e - | Pexp_poly (e, Some ct) -> - pp f "@[(!poly!@ %a@ : %a)@]" (simple_expr ctxt) e (core_type ctxt) - ct | Pexp_open (ovf, lid, e) -> pp f "@[<2>let open%s %a in@;%a@]" (override ovf) longident_loc lid (expression ctxt) e diff --git a/compiler/ml/printast.ml b/compiler/ml/printast.ml index afb4331761..ef467a79a9 100644 --- a/compiler/ml/printast.ml +++ b/compiler/ml/printast.ml @@ -331,10 +331,6 @@ and expression i ppf x = | Pexp_lazy e -> line i ppf "Pexp_lazy\n"; expression i ppf e - | Pexp_poly (e, cto) -> - line i ppf "Pexp_poly\n"; - expression i ppf e; - option i core_type ppf cto | Pexp_newtype (s, e) -> line i ppf "Pexp_newtype \"%s\"\n" s.txt; expression i ppf e diff --git a/compiler/ml/typecore.ml b/compiler/ml/typecore.ml index 92adf78f0c..b2268e9bb0 100644 --- a/compiler/ml/typecore.ml +++ b/compiler/ml/typecore.ml @@ -155,7 +155,6 @@ let iter_expression f e = List.iter (fun (_, e, _) -> expr e) iel | Pexp_open (_, _, e) | Pexp_newtype (_, e) - | Pexp_poly (e, _) | Pexp_lazy e | Pexp_assert e | Pexp_send (e, _) @@ -3107,42 +3106,6 @@ and type_expect_ ?type_clash_context ?in_function ?(recarg = Rejected) env sexp exp_attributes = sexp.pexp_attributes; exp_env = env; } - | Pexp_poly (sbody, sty) -> - let ty, cty = - match sty with - | None -> (repr ty_expected, None) - | Some sty -> - let sty = Ast_helper.Typ.force_poly sty in - let cty = Typetexp.transl_simple_type env false sty in - (repr cty.ctyp_type, Some cty) - in - if sty <> None then - unify_exp_types loc env (instance env ty) (instance env ty_expected); - let exp = - match (expand_head env ty).desc with - | Tpoly (ty', []) -> - let exp = type_expect env sbody ty' in - {exp with exp_type = instance env ty} - | Tpoly (ty', tl) -> - (* One more level to generalize locally *) - begin_def (); - let vars, ty'' = instance_poly true tl ty' in - let exp = type_expect env sbody ty'' in - end_def (); - check_univars env false "method" exp ty_expected vars; - {exp with exp_type = instance env ty} - | Tvar _ -> - let exp = type_exp env sbody in - let exp = {exp with exp_type = newty (Tpoly (exp.exp_type, []))} in - unify_exp env exp ty; - exp - | _ -> assert false - in - re - { - exp with - exp_extra = (Texp_poly cty, loc, sexp.pexp_attributes) :: exp.exp_extra; - } | Pexp_newtype ({txt = name}, sbody) -> let ty = newvar () in (* remember original level *) diff --git a/compiler/syntax/src/res_ast_debugger.ml b/compiler/syntax/src/res_ast_debugger.ml index 2205e55b32..fb5c58896f 100644 --- a/compiler/syntax/src/res_ast_debugger.ml +++ b/compiler/syntax/src/res_ast_debugger.ml @@ -696,7 +696,6 @@ module SexpAst = struct ] | Pexp_assert expr -> Sexp.list [Sexp.atom "Pexp_assert"; expression expr] | Pexp_lazy expr -> Sexp.list [Sexp.atom "Pexp_lazy"; expression expr] - | Pexp_poly _ -> Sexp.list [Sexp.atom "Pexp_poly"] | Pexp_newtype (lbl, expr) -> Sexp.list [Sexp.atom "Pexp_newtype"; string lbl.Asttypes.txt; expression expr] diff --git a/compiler/syntax/src/res_printer.ml b/compiler/syntax/src/res_printer.ml index e1b5568269..9ab6c04084 100644 --- a/compiler/syntax/src/res_printer.ml +++ b/compiler/syntax/src/res_printer.ml @@ -3390,7 +3390,6 @@ and print_expression ~state (e : Parsetree.expression) cmt_tbl = Doc.concat [Doc.text "\""; member_doc; Doc.text "\""] in Doc.group (Doc.concat [parent_doc; Doc.lbracket; member; Doc.rbracket]) - | Pexp_poly _ -> Doc.text "Pexp_poly not implemented in printer" in let expr_with_await = if ParsetreeViewer.has_await_attribute e.pexp_attributes then From 41bf9aa4b8c73ec1e4c502af2d5c77c648126115 Mon Sep 17 00:00:00 2001 From: nojaf Date: Fri, 10 Jan 2025 19:59:17 +0100 Subject: [PATCH 6/8] Correct changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90bc49b9b7..26d6e4e695 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,7 @@ - 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 - AST: always put type parameters first in function definitions. https://github.com/rescript-lang/rescript/pull/7233 - 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 -- AST cleanup: Remove `expression_desc.Pexp_new`, `expression_desc.Pexp_setinstvar` & `expression_desc.Pexp_override` from the untyped typed AST as it is unused. https://github.com/rescript-lang/rescript/pull/7239 +- AST cleanup: Remove `expression_desc.Pexp_new`, `expression_desc.Pexp_setinstvar`, `expression_desc.Pexp_override` & `expression_desc.Pexp_poly` from the untyped typed AST as it is unused. https://github.com/rescript-lang/rescript/pull/7239 # 12.0.0-alpha.7 From 195ae4314b47f58ac0a1aef5643d0ff9a0a68646 Mon Sep 17 00:00:00 2001 From: nojaf Date: Fri, 10 Jan 2025 20:52:39 +0100 Subject: [PATCH 7/8] Remove `exp_extra.Texp_poly`, `expression_desc.Texp_new`, `expression_desc.Texp_setinstvar` & `expression_desc.Texp_override` --- CHANGELOG.md | 2 +- analysis/reanalyze/src/Arnold.ml | 9 --------- analysis/reanalyze/src/SideEffects.ml | 3 --- compiler/ml/printtyped.ml | 5 ----- compiler/ml/rec_check.ml | 14 +++++--------- compiler/ml/tast_iterator.ml | 4 ---- compiler/ml/tast_mapper.ml | 4 +--- compiler/ml/translcore.ml | 3 +-- compiler/ml/typecore.ml | 1 - compiler/ml/typedtree.ml | 4 ---- compiler/ml/typedtree.mli | 4 ---- compiler/ml/typedtreeIter.ml | 3 +-- 12 files changed, 9 insertions(+), 47 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 26d6e4e695..b9256c6092 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,7 @@ - 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 - AST: always put type parameters first in function definitions. https://github.com/rescript-lang/rescript/pull/7233 - 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 -- AST cleanup: Remove `expression_desc.Pexp_new`, `expression_desc.Pexp_setinstvar`, `expression_desc.Pexp_override` & `expression_desc.Pexp_poly` from the untyped typed AST as it is unused. https://github.com/rescript-lang/rescript/pull/7239 +- 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` from AST as it is unused. https://github.com/rescript-lang/rescript/pull/7239 # 12.0.0-alpha.7 diff --git a/analysis/reanalyze/src/Arnold.ml b/analysis/reanalyze/src/Arnold.ml index e4dd423e2f..eee8753377 100644 --- a/analysis/reanalyze/src/Arnold.ml +++ b/analysis/reanalyze/src/Arnold.ml @@ -975,18 +975,9 @@ module Compile = struct | Texp_send _ -> notImplemented "Texp_send"; assert false - | Texp_new _ -> - notImplemented "Texp_new"; - assert false | Texp_instvar _ -> notImplemented "Texp_instvar"; assert false - | Texp_setinstvar _ -> - notImplemented "Texp_setinstvar"; - assert false - | Texp_override _ -> - notImplemented "Texp_override"; - assert false | Texp_letmodule _ -> notImplemented "Texp_letmodule"; assert false diff --git a/analysis/reanalyze/src/SideEffects.ml b/analysis/reanalyze/src/SideEffects.ml index d356ac23ae..46c4eab974 100644 --- a/analysis/reanalyze/src/SideEffects.ml +++ b/analysis/reanalyze/src/SideEffects.ml @@ -61,10 +61,7 @@ let rec exprNoSideEffects (expr : Typedtree.expression) = e1 |> exprNoSideEffects && e2 |> exprNoSideEffects && e3 |> exprNoSideEffects | Texp_send _ -> false - | Texp_new _ -> true | Texp_instvar _ -> true - | Texp_setinstvar _ -> false - | Texp_override _ -> false | Texp_letexception (_ec, e) -> e |> exprNoSideEffects | Texp_pack _ -> false | Texp_extension_constructor _ when true -> true diff --git a/compiler/ml/printtyped.ml b/compiler/ml/printtyped.ml index 686caa4083..f356737c81 100644 --- a/compiler/ml/printtyped.ml +++ b/compiler/ml/printtyped.ml @@ -259,10 +259,6 @@ and expression_extra i ppf x attrs = | Texp_open (ovf, m, _, _) -> line i ppf "Texp_open %a \"%a\"\n" fmt_override_flag ovf fmt_path m; attributes i ppf attrs - | Texp_poly cto -> - line i ppf "Texp_poly\n"; - attributes i ppf attrs; - option i core_type ppf cto | Texp_newtype s -> line i ppf "Texp_newtype \"%s\"\n" s; attributes i ppf attrs @@ -360,7 +356,6 @@ and expression i ppf x = line i ppf "Texp_send \"%s\"\n" s; expression i ppf e; option i expression ppf eo - | Texp_new _ | Texp_setinstvar _ | Texp_override _ -> () | Texp_letmodule (s, _, me, e) -> line i ppf "Texp_letmodule \"%a\"\n" fmt_ident s; module_expr i ppf me; diff --git a/compiler/ml/rec_check.ml b/compiler/ml/rec_check.ml index a669915a57..b467f07ff3 100644 --- a/compiler/ml/rec_check.ml +++ b/compiler/ml/rec_check.ml @@ -195,15 +195,14 @@ let rec classify_expression : Typedtree.expression -> sd = | Texp_sequence (_, e) | Texp_letexception (_, e) -> classify_expression e - | Texp_ident _ | Texp_for _ | Texp_constant _ | Texp_new _ | Texp_instvar _ - | Texp_tuple _ | Texp_array _ | Texp_construct _ | Texp_variant _ - | Texp_record _ | Texp_setfield _ | Texp_while _ | Texp_setinstvar _ - | Texp_pack _ | Texp_function _ | Texp_lazy _ | Texp_extension_constructor _ - -> + | Texp_ident _ | Texp_for _ | Texp_constant _ | Texp_instvar _ | Texp_tuple _ + | Texp_array _ | Texp_construct _ | Texp_variant _ | Texp_record _ + | Texp_setfield _ | Texp_while _ | Texp_pack _ | Texp_function _ | Texp_lazy _ + | Texp_extension_constructor _ -> Static | Texp_apply ({exp_desc = Texp_ident (_, _, vd)}, _) when is_ref vd -> Static | Texp_apply _ | Texp_match _ | Texp_ifthenelse _ | Texp_send _ | Texp_field _ - | Texp_assert _ | Texp_try _ | Texp_override _ -> + | Texp_assert _ | Texp_try _ -> Dynamic let rec expression : Env.env -> Typedtree.expression -> Use.t = @@ -233,7 +232,6 @@ let rec expression : Env.env -> Typedtree.expression -> Use.t = for inclusion in another value *) (discard (expression env e3))) | Texp_constant _ -> Use.empty - | Texp_new _ -> assert false | Texp_instvar _ -> Use.empty | Texp_apply ({exp_desc = Texp_ident (_, _, vd)}, [(_, Some arg)]) when is_ref vd -> @@ -283,7 +281,6 @@ let rec expression : Env.env -> Typedtree.expression -> Use.t = Use.( join (inspect (expression env e1)) (inspect (option expression env eo))) | Texp_field (e, _, _) -> Use.(inspect (expression env e)) - | Texp_setinstvar () -> assert false | Texp_letexception (_, e) -> expression env e | Texp_assert e -> Use.inspect (expression env e) | Texp_pack m -> modexp env m @@ -291,7 +288,6 @@ let rec expression : Env.env -> Typedtree.expression -> Use.t = (* This is more permissive than the old check. *) let case env {Typedtree.c_rhs} = expression env c_rhs in Use.join (expression env e) (list case env cases) - | Texp_override () -> assert false | Texp_function {case = case_} -> Use.delay (list (case ~scrutinee:Use.empty) env [case_]) | Texp_lazy e -> ( diff --git a/compiler/ml/tast_iterator.ml b/compiler/ml/tast_iterator.ml index 62167ea372..1b591b675d 100644 --- a/compiler/ml/tast_iterator.ml +++ b/compiler/ml/tast_iterator.ml @@ -144,7 +144,6 @@ let expr sub {exp_extra; exp_desc; exp_env; _} = | Texp_constraint cty -> sub.typ sub cty | Texp_coerce ((), cty2) -> sub.typ sub cty2 | Texp_newtype _ -> () - | Texp_poly cto -> Option.iter (sub.typ sub) cto | Texp_open (_, _, _, _) -> () in List.iter (fun (e, _, _) -> extra e) exp_extra; @@ -198,10 +197,7 @@ let expr sub {exp_extra; exp_desc; exp_env; _} = | Texp_send (exp, _, expo) -> sub.expr sub exp; Option.iter (sub.expr sub) expo - | Texp_new _ -> () | Texp_instvar _ -> () - | Texp_setinstvar _ -> () - | Texp_override _ -> () | Texp_letmodule (_, _, mexpr, exp) -> sub.module_expr sub mexpr; sub.expr sub exp diff --git a/compiler/ml/tast_mapper.ml b/compiler/ml/tast_mapper.ml index 24541f60e8..b6d17285e0 100644 --- a/compiler/ml/tast_mapper.ml +++ b/compiler/ml/tast_mapper.ml @@ -189,7 +189,6 @@ let expr sub x = | Texp_open (ovf, path, loc, env) -> Texp_open (ovf, path, loc, sub.env sub env) | Texp_newtype _ as d -> d - | Texp_poly cto -> Texp_poly (opt (sub.typ sub) cto) in let exp_extra = List.map (tuple3 extra id id) x.exp_extra in let exp_env = sub.env sub x.exp_env in @@ -244,8 +243,7 @@ let expr sub x = (id, p, sub.expr sub exp1, sub.expr sub exp2, dir, sub.expr sub exp3) | Texp_send (exp, meth, expo) -> Texp_send (sub.expr sub exp, meth, opt (sub.expr sub) expo) - | (Texp_new _ | Texp_instvar _) as d -> d - | Texp_setinstvar _ | Texp_override _ -> assert false + | Texp_instvar _ as d -> d | Texp_letmodule (id, s, mexpr, exp) -> Texp_letmodule (id, s, sub.module_expr sub mexpr, sub.expr sub exp) | Texp_letexception (cd, exp) -> diff --git a/compiler/ml/translcore.ml b/compiler/ml/translcore.ml index 73986b5d57..c6fb2c398a 100644 --- a/compiler/ml/translcore.ml +++ b/compiler/ml/translcore.ml @@ -911,8 +911,7 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda = | Texp_send (expr, Tmeth_name nm, _) -> let obj = transl_exp expr in Lsend (nm, obj, e.exp_loc) - | Texp_new _ | Texp_instvar _ | Texp_setinstvar _ | Texp_override _ -> - assert false + | Texp_instvar _ -> assert false | Texp_letmodule (id, _loc, modl, body) -> let defining_expr = !transl_module Tcoerce_none None modl in Llet (Strict, Pgenval, id, defining_expr, transl_exp body) diff --git a/compiler/ml/typecore.ml b/compiler/ml/typecore.ml index b2268e9bb0..193c6da536 100644 --- a/compiler/ml/typecore.ml +++ b/compiler/ml/typecore.ml @@ -1820,7 +1820,6 @@ let rec is_nonexpansive exp = | Texp_ifthenelse (_cond, ifso, ifnot) -> is_nonexpansive ifso && is_nonexpansive_opt ifnot | Texp_sequence (_e1, e2) -> is_nonexpansive e2 (* PR#4354 *) - | Texp_new _ -> assert false (* Note: nonexpansive only means no _observable_ side effects *) | Texp_lazy e -> is_nonexpansive e | Texp_letmodule (_, _, mexp, e) -> diff --git a/compiler/ml/typedtree.ml b/compiler/ml/typedtree.ml index c3af7028fd..c2884b6243 100644 --- a/compiler/ml/typedtree.ml +++ b/compiler/ml/typedtree.ml @@ -69,7 +69,6 @@ and exp_extra = | Texp_constraint of core_type | Texp_coerce of unit * core_type | Texp_open of override_flag * Path.t * Longident.t loc * Env.t - | Texp_poly of core_type option | Texp_newtype of string and expression_desc = @@ -115,10 +114,7 @@ and expression_desc = * direction_flag * expression | Texp_send of expression * meth * expression option - | Texp_new of unit | Texp_instvar of unit - | Texp_setinstvar of unit - | Texp_override of unit | Texp_letmodule of Ident.t * string loc * module_expr * expression | Texp_letexception of extension_constructor * expression | Texp_assert of expression diff --git a/compiler/ml/typedtree.mli b/compiler/ml/typedtree.mli index 2aabedb4aa..6285a7409f 100644 --- a/compiler/ml/typedtree.mli +++ b/compiler/ml/typedtree.mli @@ -117,7 +117,6 @@ and exp_extra = (** let open[!] M in [Texp_open (!, P, M, env)] where [env] is the environment after opening [P] *) - | Texp_poly of core_type option (** Used for method bodies. *) | Texp_newtype of string (** fun (type t) -> *) and expression_desc = @@ -217,10 +216,7 @@ and expression_desc = * direction_flag * expression | Texp_send of expression * meth * expression option - | Texp_new of unit | Texp_instvar of unit - | Texp_setinstvar of unit - | Texp_override of unit | Texp_letmodule of Ident.t * string loc * module_expr * expression | Texp_letexception of extension_constructor * expression | Texp_assert of expression diff --git a/compiler/ml/typedtreeIter.ml b/compiler/ml/typedtreeIter.ml index 74213d65a9..414975715c 100644 --- a/compiler/ml/typedtreeIter.ml +++ b/compiler/ml/typedtreeIter.ml @@ -221,7 +221,6 @@ end = struct | Texp_constraint ct -> iter_core_type ct | Texp_coerce ((), cty2) -> iter_core_type cty2 | Texp_open _ -> () - | Texp_poly cto -> option iter_core_type cto | Texp_newtype _ -> ())) exp.exp_extra; (match exp.exp_desc with @@ -287,7 +286,7 @@ end = struct match expo with | None -> () | Some exp -> iter_expression exp) - | Texp_new _ | Texp_instvar _ | Texp_setinstvar _ | Texp_override _ -> () + | Texp_instvar _ -> () | Texp_letmodule (_id, _, mexpr, exp) -> iter_module_expr mexpr; iter_expression exp From 09d18bb39ccd6ff31c7970d70e2262102d233f84 Mon Sep 17 00:00:00 2001 From: nojaf Date: Fri, 10 Jan 2025 22:04:26 +0100 Subject: [PATCH 8/8] Remove expression_desc.Texp_instvar --- CHANGELOG.md | 2 +- analysis/reanalyze/src/Arnold.ml | 3 --- analysis/reanalyze/src/SideEffects.ml | 1 - compiler/ml/printtyped.ml | 1 - compiler/ml/rec_check.ml | 7 +++---- compiler/ml/tast_iterator.ml | 1 - compiler/ml/tast_mapper.ml | 1 - compiler/ml/translcore.ml | 1 - compiler/ml/typedtree.ml | 1 - compiler/ml/typedtree.mli | 1 - compiler/ml/typedtreeIter.ml | 1 - 11 files changed, 4 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9256c6092..f8b2156feb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,7 @@ - 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 - AST: always put type parameters first in function definitions. https://github.com/rescript-lang/rescript/pull/7233 - 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 -- 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` from AST as it is unused. https://github.com/rescript-lang/rescript/pull/7239 +- 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 # 12.0.0-alpha.7 diff --git a/analysis/reanalyze/src/Arnold.ml b/analysis/reanalyze/src/Arnold.ml index eee8753377..d6c49357fa 100644 --- a/analysis/reanalyze/src/Arnold.ml +++ b/analysis/reanalyze/src/Arnold.ml @@ -975,9 +975,6 @@ module Compile = struct | Texp_send _ -> notImplemented "Texp_send"; assert false - | Texp_instvar _ -> - notImplemented "Texp_instvar"; - assert false | Texp_letmodule _ -> notImplemented "Texp_letmodule"; assert false diff --git a/analysis/reanalyze/src/SideEffects.ml b/analysis/reanalyze/src/SideEffects.ml index 46c4eab974..338149d659 100644 --- a/analysis/reanalyze/src/SideEffects.ml +++ b/analysis/reanalyze/src/SideEffects.ml @@ -61,7 +61,6 @@ let rec exprNoSideEffects (expr : Typedtree.expression) = e1 |> exprNoSideEffects && e2 |> exprNoSideEffects && e3 |> exprNoSideEffects | Texp_send _ -> false - | Texp_instvar _ -> true | Texp_letexception (_ec, e) -> e |> exprNoSideEffects | Texp_pack _ -> false | Texp_extension_constructor _ when true -> true diff --git a/compiler/ml/printtyped.ml b/compiler/ml/printtyped.ml index f356737c81..f480554744 100644 --- a/compiler/ml/printtyped.ml +++ b/compiler/ml/printtyped.ml @@ -275,7 +275,6 @@ and expression i ppf x = in match x.exp_desc with | Texp_ident (li, _, _) -> line i ppf "Texp_ident %a\n" fmt_path li - | Texp_instvar () -> assert false | Texp_constant c -> line i ppf "Texp_constant %a\n" fmt_constant c | Texp_let (rf, l, e) -> line i ppf "Texp_let %a\n" fmt_rec_flag rf; diff --git a/compiler/ml/rec_check.ml b/compiler/ml/rec_check.ml index b467f07ff3..292bdeb48d 100644 --- a/compiler/ml/rec_check.ml +++ b/compiler/ml/rec_check.ml @@ -195,9 +195,9 @@ let rec classify_expression : Typedtree.expression -> sd = | Texp_sequence (_, e) | Texp_letexception (_, e) -> classify_expression e - | Texp_ident _ | Texp_for _ | Texp_constant _ | Texp_instvar _ | Texp_tuple _ - | Texp_array _ | Texp_construct _ | Texp_variant _ | Texp_record _ - | Texp_setfield _ | Texp_while _ | Texp_pack _ | Texp_function _ | Texp_lazy _ + | Texp_ident _ | Texp_for _ | Texp_constant _ | Texp_tuple _ | Texp_array _ + | Texp_construct _ | Texp_variant _ | Texp_record _ | Texp_setfield _ + | Texp_while _ | Texp_pack _ | Texp_function _ | Texp_lazy _ | Texp_extension_constructor _ -> Static | Texp_apply ({exp_desc = Texp_ident (_, _, vd)}, _) when is_ref vd -> Static @@ -232,7 +232,6 @@ let rec expression : Env.env -> Typedtree.expression -> Use.t = for inclusion in another value *) (discard (expression env e3))) | Texp_constant _ -> Use.empty - | Texp_instvar _ -> Use.empty | Texp_apply ({exp_desc = Texp_ident (_, _, vd)}, [(_, Some arg)]) when is_ref vd -> Use.guard (expression env arg) diff --git a/compiler/ml/tast_iterator.ml b/compiler/ml/tast_iterator.ml index 1b591b675d..2f50911a17 100644 --- a/compiler/ml/tast_iterator.ml +++ b/compiler/ml/tast_iterator.ml @@ -197,7 +197,6 @@ let expr sub {exp_extra; exp_desc; exp_env; _} = | Texp_send (exp, _, expo) -> sub.expr sub exp; Option.iter (sub.expr sub) expo - | Texp_instvar _ -> () | Texp_letmodule (_, _, mexpr, exp) -> sub.module_expr sub mexpr; sub.expr sub exp diff --git a/compiler/ml/tast_mapper.ml b/compiler/ml/tast_mapper.ml index b6d17285e0..f4b8b26eca 100644 --- a/compiler/ml/tast_mapper.ml +++ b/compiler/ml/tast_mapper.ml @@ -243,7 +243,6 @@ let expr sub x = (id, p, sub.expr sub exp1, sub.expr sub exp2, dir, sub.expr sub exp3) | Texp_send (exp, meth, expo) -> Texp_send (sub.expr sub exp, meth, opt (sub.expr sub) expo) - | Texp_instvar _ as d -> d | Texp_letmodule (id, s, mexpr, exp) -> Texp_letmodule (id, s, sub.module_expr sub mexpr, sub.expr sub exp) | Texp_letexception (cd, exp) -> diff --git a/compiler/ml/translcore.ml b/compiler/ml/translcore.ml index c6fb2c398a..02e5ac411a 100644 --- a/compiler/ml/translcore.ml +++ b/compiler/ml/translcore.ml @@ -911,7 +911,6 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda = | Texp_send (expr, Tmeth_name nm, _) -> let obj = transl_exp expr in Lsend (nm, obj, e.exp_loc) - | Texp_instvar _ -> assert false | Texp_letmodule (id, _loc, modl, body) -> let defining_expr = !transl_module Tcoerce_none None modl in Llet (Strict, Pgenval, id, defining_expr, transl_exp body) diff --git a/compiler/ml/typedtree.ml b/compiler/ml/typedtree.ml index c2884b6243..f43e0e8da8 100644 --- a/compiler/ml/typedtree.ml +++ b/compiler/ml/typedtree.ml @@ -114,7 +114,6 @@ and expression_desc = * direction_flag * expression | Texp_send of expression * meth * expression option - | Texp_instvar of unit | Texp_letmodule of Ident.t * string loc * module_expr * expression | Texp_letexception of extension_constructor * expression | Texp_assert of expression diff --git a/compiler/ml/typedtree.mli b/compiler/ml/typedtree.mli index 6285a7409f..5e2f992860 100644 --- a/compiler/ml/typedtree.mli +++ b/compiler/ml/typedtree.mli @@ -216,7 +216,6 @@ and expression_desc = * direction_flag * expression | Texp_send of expression * meth * expression option - | Texp_instvar of unit | Texp_letmodule of Ident.t * string loc * module_expr * expression | Texp_letexception of extension_constructor * expression | Texp_assert of expression diff --git a/compiler/ml/typedtreeIter.ml b/compiler/ml/typedtreeIter.ml index 414975715c..876206c512 100644 --- a/compiler/ml/typedtreeIter.ml +++ b/compiler/ml/typedtreeIter.ml @@ -286,7 +286,6 @@ end = struct match expo with | None -> () | Some exp -> iter_expression exp) - | Texp_instvar _ -> () | Texp_letmodule (_id, _, mexpr, exp) -> iter_module_expr mexpr; iter_expression exp