From 527b37429ea36d7b622ddb2344e76641d4cfe53d Mon Sep 17 00:00:00 2001 From: nojaf Date: Sat, 11 Jan 2025 14:38:43 +0100 Subject: [PATCH 1/8] Remove Pstr_class --- analysis/reanalyze/src/Annotation.ml | 1 - compiler/core/js_implementation.ml | 4 ++-- compiler/frontend/bs_ast_invariant.ml | 3 --- compiler/frontend/bs_ast_mapper.ml | 1 - compiler/gentype/Annotation.ml | 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 | 1 - compiler/ml/typemod.ml | 1 - compiler/syntax/src/res_ast_debugger.ml | 1 - compiler/syntax/src/res_comments_table.ml | 2 +- compiler/syntax/src/res_printer.ml | 2 +- 18 files changed, 5 insertions(+), 21 deletions(-) diff --git a/analysis/reanalyze/src/Annotation.ml b/analysis/reanalyze/src/Annotation.ml index 3e6429fb4a..12e9e17e5a 100644 --- a/analysis/reanalyze/src/Annotation.ml +++ b/analysis/reanalyze/src/Annotation.ml @@ -63,7 +63,6 @@ let rec getAttributePayload checkText (attributes : Typedtree.attributes) = | PStr ({pstr_desc = Pstr_recmodule _} :: _) -> Some UnrecognizedPayload | PStr ({pstr_desc = Pstr_modtype _} :: _) -> Some UnrecognizedPayload | PStr ({pstr_desc = Pstr_open _} :: _) -> Some UnrecognizedPayload - | PStr ({pstr_desc = Pstr_class _} :: _) -> Some UnrecognizedPayload | PStr ({pstr_desc = Pstr_class_type _} :: _) -> Some UnrecognizedPayload | PStr ({pstr_desc = Pstr_include _} :: _) -> Some UnrecognizedPayload | PStr ({pstr_desc = Pstr_attribute _} :: _) -> Some UnrecognizedPayload diff --git a/compiler/core/js_implementation.ml b/compiler/core/js_implementation.ml index 9adcf8d0d0..0ff8090aff 100644 --- a/compiler/core/js_implementation.ml +++ b/compiler/core/js_implementation.ml @@ -96,8 +96,8 @@ let all_module_alias (ast : Parsetree.structure) = | Pstr_attribute _ -> true | Pstr_eval _ | Pstr_value _ | Pstr_primitive _ | Pstr_type _ | Pstr_typext _ | Pstr_exception _ | Pstr_module _ | Pstr_recmodule _ - | Pstr_modtype _ | Pstr_open _ | Pstr_class _ | Pstr_class_type _ - | Pstr_include _ | Pstr_extension _ -> + | Pstr_modtype _ | Pstr_open _ | Pstr_class_type _ | Pstr_include _ + | Pstr_extension _ -> false) let no_export (rest : Parsetree.structure) : Parsetree.structure = diff --git a/compiler/frontend/bs_ast_invariant.ml b/compiler/frontend/bs_ast_invariant.ml index 7da08fea57..fb4bfa370b 100644 --- a/compiler/frontend/bs_ast_invariant.ml +++ b/compiler/frontend/bs_ast_invariant.ml @@ -86,9 +86,6 @@ let emit_external_warnings : iterator = [{ptype_kind = Ptype_variant ({pcd_res = Some _} :: _)}] ) -> Location.raise_errorf ~loc:str_item.pstr_loc "GADT has to be recursive types, please try `type rec'" - | Pstr_class _ -> - Location.raise_errorf ~loc:str_item.pstr_loc - "OCaml style classes are not supported" | _ -> super.structure_item self str_item); expr = (fun self ({pexp_loc = loc} as a) -> diff --git a/compiler/frontend/bs_ast_mapper.ml b/compiler/frontend/bs_ast_mapper.ml index 292fe15b9c..e148d441ad 100644 --- a/compiler/frontend/bs_ast_mapper.ml +++ b/compiler/frontend/bs_ast_mapper.ml @@ -287,7 +287,6 @@ module M = struct | Pstr_recmodule l -> rec_module ~loc (List.map (sub.module_binding sub) l) | Pstr_modtype x -> modtype ~loc (sub.module_type_declaration sub x) | Pstr_open x -> open_ ~loc (sub.open_description sub x) - | Pstr_class () -> {pstr_loc = loc; pstr_desc = Pstr_class ()} | Pstr_class_type () -> {pstr_loc = loc; pstr_desc = Pstr_class_type ()} | Pstr_include x -> include_ ~loc (sub.include_declaration sub x) | Pstr_extension (x, attrs) -> diff --git a/compiler/gentype/Annotation.ml b/compiler/gentype/Annotation.ml index 6f1dbd1dce..17bf25fd5b 100644 --- a/compiler/gentype/Annotation.ml +++ b/compiler/gentype/Annotation.ml @@ -83,7 +83,6 @@ let rec get_attribute_payload check_text (attributes : Typedtree.attributes) = | PStr ({pstr_desc = Pstr_recmodule _} :: _) -> Some UnrecognizedPayload | PStr ({pstr_desc = Pstr_modtype _} :: _) -> Some UnrecognizedPayload | PStr ({pstr_desc = Pstr_open _} :: _) -> Some UnrecognizedPayload - | PStr ({pstr_desc = Pstr_class _} :: _) -> Some UnrecognizedPayload | PStr ({pstr_desc = Pstr_class_type _} :: _) -> Some UnrecognizedPayload | PStr ({pstr_desc = Pstr_include _} :: _) -> Some UnrecognizedPayload | PStr ({pstr_desc = Pstr_attribute _} :: _) -> Some UnrecognizedPayload diff --git a/compiler/ml/ast_iterator.ml b/compiler/ml/ast_iterator.ml index 2c76f6e5b4..2e3640a91b 100644 --- a/compiler/ml/ast_iterator.ml +++ b/compiler/ml/ast_iterator.ml @@ -261,7 +261,6 @@ module M = struct | Pstr_recmodule l -> List.iter (sub.module_binding sub) l | Pstr_modtype x -> sub.module_type_declaration sub x | Pstr_open x -> sub.open_description sub x - | Pstr_class () -> () | Pstr_class_type () -> () | Pstr_include x -> sub.include_declaration sub x | Pstr_extension (x, attrs) -> diff --git a/compiler/ml/ast_mapper.ml b/compiler/ml/ast_mapper.ml index 854e003c99..baf727d388 100644 --- a/compiler/ml/ast_mapper.ml +++ b/compiler/ml/ast_mapper.ml @@ -258,7 +258,6 @@ module M = struct | Pstr_recmodule l -> rec_module ~loc (List.map (sub.module_binding sub) l) | Pstr_modtype x -> modtype ~loc (sub.module_type_declaration sub x) | Pstr_open x -> open_ ~loc (sub.open_description sub x) - | Pstr_class () -> {pstr_loc = loc; pstr_desc = Pstr_class ()} | Pstr_class_type () -> {pstr_loc = loc; pstr_desc = Pstr_class_type ()} | Pstr_include x -> include_ ~loc (sub.include_declaration sub x) | Pstr_extension (x, attrs) -> diff --git a/compiler/ml/ast_mapper_from0.ml b/compiler/ml/ast_mapper_from0.ml index 22d59a792f..9aa388c754 100644 --- a/compiler/ml/ast_mapper_from0.ml +++ b/compiler/ml/ast_mapper_from0.ml @@ -283,7 +283,7 @@ module M = struct | Pstr_recmodule l -> rec_module ~loc (List.map (sub.module_binding sub) l) | Pstr_modtype x -> modtype ~loc (sub.module_type_declaration sub x) | Pstr_open x -> open_ ~loc (sub.open_description sub x) - | Pstr_class () -> {pstr_loc = loc; pstr_desc = Pstr_class ()} + | Pstr_class () -> failwith "Pstr_class is no longer present in ReScript" | Pstr_class_type () -> {pstr_loc = loc; pstr_desc = Pstr_class_type ()} | Pstr_include x -> include_ ~loc (sub.include_declaration sub x) | Pstr_extension (x, attrs) -> diff --git a/compiler/ml/ast_mapper_to0.ml b/compiler/ml/ast_mapper_to0.ml index 68be8b7cbf..6633b9c6cf 100644 --- a/compiler/ml/ast_mapper_to0.ml +++ b/compiler/ml/ast_mapper_to0.ml @@ -275,7 +275,6 @@ module M = struct | Pstr_recmodule l -> rec_module ~loc (List.map (sub.module_binding sub) l) | Pstr_modtype x -> modtype ~loc (sub.module_type_declaration sub x) | Pstr_open x -> open_ ~loc (sub.open_description sub x) - | Pstr_class () -> {pstr_loc = loc; pstr_desc = Pstr_class ()} | Pstr_class_type () -> {pstr_loc = loc; pstr_desc = Pstr_class_type ()} | Pstr_include x -> include_ ~loc (sub.include_declaration sub x) | Pstr_extension (x, attrs) -> diff --git a/compiler/ml/depend.ml b/compiler/ml/depend.ml index 47d54954f6..bf9d439b2c 100644 --- a/compiler/ml/depend.ml +++ b/compiler/ml/depend.ml @@ -471,7 +471,6 @@ and add_struct_item (bv, m) item : _ StringMap.t * _ StringMap.t = | Some mty -> add_modtype bv mty); (bv, m) | Pstr_open od -> (open_module bv od.popen_lid.txt, m) - | Pstr_class () -> (bv, m) | Pstr_class_type () -> (bv, m) | Pstr_include incl -> let (Node (s, m')) = add_module_binding bv incl.pincl_mod in diff --git a/compiler/ml/parsetree.ml b/compiler/ml/parsetree.ml index a56f4c9439..2faa709d27 100644 --- a/compiler/ml/parsetree.ml +++ b/compiler/ml/parsetree.ml @@ -578,7 +578,6 @@ and structure_item_desc = (* module rec X1 = ME1 and ... and Xn = MEn *) | Pstr_modtype of module_type_declaration (* module type S = MT *) | Pstr_open of open_description (* open X *) - | Pstr_class of unit (* Dummy AST node *) | Pstr_class_type of unit (* Dummy AST node *) | Pstr_include of include_declaration (* include ME *) | Pstr_attribute of attribute (* [@@@id] *) diff --git a/compiler/ml/pprintast.ml b/compiler/ml/pprintast.ml index 2517d60e7d..021e1e24fb 100644 --- a/compiler/ml/pprintast.ml +++ b/compiler/ml/pprintast.ml @@ -1115,7 +1115,6 @@ and structure_item ctxt f x = pp_print_space f (); pp f "@ =@ %a" (module_type ctxt) mt) md (item_attributes ctxt) attrs - | Pstr_class () -> () | Pstr_class_type () -> () | Pstr_primitive vd -> pp f "@[external@ %a@ :@ %a@]%a" protect_ident vd.pval_name.txt diff --git a/compiler/ml/printast.ml b/compiler/ml/printast.ml index 9af6ff95fc..05311a6649 100644 --- a/compiler/ml/printast.ml +++ b/compiler/ml/printast.ml @@ -586,7 +586,6 @@ and structure_item i ppf x = line i ppf "Pstr_open %a %a\n" fmt_override_flag od.popen_override fmt_longident_loc od.popen_lid; attributes i ppf od.popen_attributes - | Pstr_class () -> () | Pstr_class_type () -> () | Pstr_include incl -> line i ppf "Pstr_include"; diff --git a/compiler/ml/typecore.ml b/compiler/ml/typecore.ml index 1780de9958..23a945acb4 100644 --- a/compiler/ml/typecore.ml +++ b/compiler/ml/typecore.ml @@ -204,7 +204,6 @@ let iter_expression f e = | Pstr_include {pincl_mod = me} | Pstr_module {pmb_expr = me} -> module_expr me | Pstr_recmodule l -> List.iter (fun x -> module_expr x.pmb_expr) l - | Pstr_class () -> () in expr e diff --git a/compiler/ml/typemod.ml b/compiler/ml/typemod.ml index 8ff9cb44c5..aa01b6569f 100644 --- a/compiler/ml/typemod.ml +++ b/compiler/ml/typemod.ml @@ -1567,7 +1567,6 @@ and type_structure ?(toplevel = false) funct_body anchor env sstr scope = | Pstr_open sod -> let _path, newenv, od = type_open ~toplevel env sod in (Tstr_open od, [], newenv) - | Pstr_class () -> assert false | Pstr_class_type () -> assert false | Pstr_include sincl -> let smodl = sincl.pincl_mod in diff --git a/compiler/syntax/src/res_ast_debugger.ml b/compiler/syntax/src/res_ast_debugger.ml index 6ed8dbbea4..4cdd7e5298 100644 --- a/compiler/syntax/src/res_ast_debugger.ml +++ b/compiler/syntax/src/res_ast_debugger.ml @@ -179,7 +179,6 @@ module SexpAst = struct [Sexp.atom "Pstr_modtype"; module_type_declaration mod_typ_decl] | Pstr_open open_desc -> Sexp.list [Sexp.atom "Pstr_open"; open_description open_desc] - | Pstr_class _ -> Sexp.atom "Pstr_class" | Pstr_class_type _ -> Sexp.atom "Pstr_class_type" | Pstr_include id -> Sexp.list [Sexp.atom "Pstr_include"; include_declaration id] diff --git a/compiler/syntax/src/res_comments_table.ml b/compiler/syntax/src/res_comments_table.ml index 4f40f7f151..4ba0742559 100644 --- a/compiler/syntax/src/res_comments_table.ml +++ b/compiler/syntax/src/res_comments_table.ml @@ -436,7 +436,7 @@ and walk_structure_item si t comments = | Pstr_exception extension_constructor -> walk_extension_constructor extension_constructor t comments | Pstr_typext type_extension -> walk_type_extension type_extension t comments - | Pstr_class_type _ | Pstr_class _ -> () + | Pstr_class_type _ -> () and walk_value_description vd t comments = let leading, trailing = diff --git a/compiler/syntax/src/res_printer.ml b/compiler/syntax/src/res_printer.ml index 60e302a1cb..b03709ba2f 100644 --- a/compiler/syntax/src/res_printer.ml +++ b/compiler/syntax/src/res_printer.ml @@ -614,7 +614,7 @@ and print_structure_item ~state (si : Parsetree.structure_item) cmt_tbl = print_exception_def ~state extension_constructor cmt_tbl | Pstr_typext type_extension -> print_type_extension ~state type_extension cmt_tbl - | Pstr_class _ | Pstr_class_type _ -> Doc.nil + | Pstr_class_type _ -> Doc.nil and print_type_extension ~state (te : Parsetree.type_extension) cmt_tbl = let prefix = Doc.text "type " in From 0b03ab4d1eb40b34bb05ead4e204dc0f5a82a262 Mon Sep 17 00:00:00 2001 From: nojaf Date: Sat, 11 Jan 2025 14:46:22 +0100 Subject: [PATCH 2/8] Remove Psig_class --- compiler/frontend/bs_ast_mapper.ml | 1 - compiler/ml/ast_iterator.ml | 1 - compiler/ml/ast_mapper.ml | 1 - 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/typemod.ml | 2 -- compiler/syntax/src/res_ast_debugger.ml | 1 - compiler/syntax/src/res_comments_table.ml | 2 +- compiler/syntax/src/res_printer.ml | 2 +- 12 files changed, 2 insertions(+), 13 deletions(-) diff --git a/compiler/frontend/bs_ast_mapper.ml b/compiler/frontend/bs_ast_mapper.ml index e148d441ad..9149ba2d21 100644 --- a/compiler/frontend/bs_ast_mapper.ml +++ b/compiler/frontend/bs_ast_mapper.ml @@ -232,7 +232,6 @@ module MT = struct | Psig_modtype x -> modtype ~loc (sub.module_type_declaration sub x) | Psig_open x -> open_ ~loc (sub.open_description sub x) | Psig_include x -> include_ ~loc (sub.include_description sub x) - | Psig_class () -> assert false | Psig_class_type () -> assert false | Psig_extension (x, attrs) -> extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs) diff --git a/compiler/ml/ast_iterator.ml b/compiler/ml/ast_iterator.ml index 2e3640a91b..f7ac769bff 100644 --- a/compiler/ml/ast_iterator.ml +++ b/compiler/ml/ast_iterator.ml @@ -216,7 +216,6 @@ module MT = struct | Psig_modtype x -> sub.module_type_declaration sub x | Psig_open x -> sub.open_description sub x | Psig_include x -> sub.include_description sub x - | Psig_class () -> () | Psig_class_type () -> () | Psig_extension (x, attrs) -> sub.extension sub x; diff --git a/compiler/ml/ast_mapper.ml b/compiler/ml/ast_mapper.ml index baf727d388..81df977cbf 100644 --- a/compiler/ml/ast_mapper.ml +++ b/compiler/ml/ast_mapper.ml @@ -215,7 +215,6 @@ module MT = struct | Psig_modtype x -> modtype ~loc (sub.module_type_declaration sub x) | Psig_open x -> open_ ~loc (sub.open_description sub x) | Psig_include x -> include_ ~loc (sub.include_description sub x) - | Psig_class _ -> assert false | Psig_class_type _ -> assert false | Psig_extension (x, attrs) -> extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs) diff --git a/compiler/ml/ast_mapper_to0.ml b/compiler/ml/ast_mapper_to0.ml index 6633b9c6cf..4babec74f1 100644 --- a/compiler/ml/ast_mapper_to0.ml +++ b/compiler/ml/ast_mapper_to0.ml @@ -232,7 +232,6 @@ module MT = struct | Psig_modtype x -> modtype ~loc (sub.module_type_declaration sub x) | Psig_open x -> open_ ~loc (sub.open_description sub x) | Psig_include x -> include_ ~loc (sub.include_description sub x) - | Psig_class _ -> assert false | Psig_class_type _ -> assert false | Psig_extension (x, attrs) -> extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs) diff --git a/compiler/ml/depend.ml b/compiler/ml/depend.ml index bf9d439b2c..c013ac392b 100644 --- a/compiler/ml/depend.ml +++ b/compiler/ml/depend.ml @@ -385,7 +385,6 @@ and add_sig_item (bv, m) item = add_names s; let add = StringMap.fold StringMap.add m' in (add bv, add m) - | Psig_class () -> (bv, m) | Psig_class_type () -> (bv, m) | Psig_attribute _ -> (bv, m) | Psig_extension (e, _) -> diff --git a/compiler/ml/parsetree.ml b/compiler/ml/parsetree.ml index 2faa709d27..6c27de8f43 100644 --- a/compiler/ml/parsetree.ml +++ b/compiler/ml/parsetree.ml @@ -476,7 +476,6 @@ and signature_item_desc = module type S *) | Psig_open of open_description (* open X *) | Psig_include of include_description (* include MT *) - | Psig_class of unit (* Dummy AST node *) | Psig_class_type of unit (* Dummy AST node *) | Psig_attribute of attribute (* [@@@id] *) | Psig_extension of extension * attributes diff --git a/compiler/ml/pprintast.ml b/compiler/ml/pprintast.ml index 021e1e24fb..e441a59cd4 100644 --- a/compiler/ml/pprintast.ml +++ b/compiler/ml/pprintast.ml @@ -883,7 +883,6 @@ and signature_item ctxt f x : unit = (value_description ctxt) vd (item_attributes ctxt) vd.pval_attributes | Psig_typext te -> type_extension ctxt f te | Psig_exception ed -> exception_declaration ctxt f ed - | Psig_class () -> () | Psig_module ({pmd_type = {pmty_desc = Pmty_alias alias; pmty_attributes = []; _}; _} as pmd) -> diff --git a/compiler/ml/printast.ml b/compiler/ml/printast.ml index 05311a6649..9afeba5e27 100644 --- a/compiler/ml/printast.ml +++ b/compiler/ml/printast.ml @@ -490,7 +490,6 @@ and signature_item i ppf x = line i ppf "Psig_include\n"; module_type i ppf incl.pincl_mod; attributes i ppf incl.pincl_attributes - | Psig_class () -> () | Psig_class_type () -> () | Psig_extension ((s, arg), attrs) -> line i ppf "Psig_extension \"%s\"\n" s.txt; diff --git a/compiler/ml/typemod.ml b/compiler/ml/typemod.ml index aa01b6569f..27872c4966 100644 --- a/compiler/ml/typemod.ml +++ b/compiler/ml/typemod.ml @@ -574,7 +574,6 @@ and approx_sig env ssg = let newenv = Env.add_signature sg env in sg @ approx_sig newenv srem | Psig_class_type () -> assert false - | Psig_class () -> assert false | _ -> approx_sig env srem) and approx_modtype_info env sinfo = @@ -870,7 +869,6 @@ and transl_signature env sg = in let trem, rem, final_env = transl_sig newenv srem in (mksig (Tsig_include incl) env loc :: trem, sg @ rem, final_env) - | Psig_class _ -> assert false | Psig_class_type _ -> assert false | Psig_attribute x -> Builtin_attributes.warning_attribute x; diff --git a/compiler/syntax/src/res_ast_debugger.ml b/compiler/syntax/src/res_ast_debugger.ml index 4cdd7e5298..70f8bb72c4 100644 --- a/compiler/syntax/src/res_ast_debugger.ml +++ b/compiler/syntax/src/res_ast_debugger.ml @@ -360,7 +360,6 @@ module SexpAst = struct Sexp.list [Sexp.atom "Psig_open"; open_description open_desc] | Psig_include incl_decl -> Sexp.list [Sexp.atom "Psig_include"; include_description incl_decl] - | Psig_class _ -> Sexp.list [Sexp.atom "Psig_class"] | Psig_class_type _ -> Sexp.list [Sexp.atom "Psig_class_type"] | Psig_attribute attr -> Sexp.list [Sexp.atom "Psig_attribute"; attribute attr] diff --git a/compiler/syntax/src/res_comments_table.ml b/compiler/syntax/src/res_comments_table.ml index 4ba0742559..72b1250347 100644 --- a/compiler/syntax/src/res_comments_table.ml +++ b/compiler/syntax/src/res_comments_table.ml @@ -545,7 +545,7 @@ and walk_signature_item (si : Parsetree.signature_item) t comments = walk_include_description include_description t comments | Psig_attribute attribute -> walk_attribute attribute t comments | Psig_extension (extension, _) -> walk_extension extension t comments - | Psig_class _ | Psig_class_type _ -> () + | Psig_class_type _ -> () and walk_include_description id t comments = let before, inside, after = partition_by_loc comments id.pincl_mod.pmty_loc in diff --git a/compiler/syntax/src/res_printer.ml b/compiler/syntax/src/res_printer.ml index b03709ba2f..ea80338aad 100644 --- a/compiler/syntax/src/res_printer.ml +++ b/compiler/syntax/src/res_printer.ml @@ -974,7 +974,7 @@ and print_signature_item ~state (si : Parsetree.signature_item) cmt_tbl = Doc.concat [print_extension ~state ~at_module_lvl:true extension cmt_tbl]; ] - | Psig_class _ | Psig_class_type _ -> Doc.nil + | Psig_class_type _ -> Doc.nil and print_rec_module_declarations ~state module_declarations cmt_tbl = print_listi From 78f0565cb869ae8375c1f342d262a5ef539d2f66 Mon Sep 17 00:00:00 2001 From: nojaf Date: Sat, 11 Jan 2025 14:50:42 +0100 Subject: [PATCH 3/8] Remove Pstr_class_type --- analysis/reanalyze/src/Annotation.ml | 1 - compiler/core/js_implementation.ml | 3 +-- compiler/frontend/bs_ast_mapper.ml | 1 - compiler/gentype/Annotation.ml | 1 - compiler/ml/ast_iterator.ml | 1 - compiler/ml/ast_mapper.ml | 1 - compiler/ml/ast_mapper_from0.ml | 3 ++- 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/ml/typemod.ml | 1 - compiler/syntax/src/res_ast_debugger.ml | 1 - compiler/syntax/src/res_comments_table.ml | 1 - compiler/syntax/src/res_printer.ml | 1 - 17 files changed, 4 insertions(+), 20 deletions(-) diff --git a/analysis/reanalyze/src/Annotation.ml b/analysis/reanalyze/src/Annotation.ml index 12e9e17e5a..ad522762dd 100644 --- a/analysis/reanalyze/src/Annotation.ml +++ b/analysis/reanalyze/src/Annotation.ml @@ -63,7 +63,6 @@ let rec getAttributePayload checkText (attributes : Typedtree.attributes) = | PStr ({pstr_desc = Pstr_recmodule _} :: _) -> Some UnrecognizedPayload | PStr ({pstr_desc = Pstr_modtype _} :: _) -> Some UnrecognizedPayload | PStr ({pstr_desc = Pstr_open _} :: _) -> Some UnrecognizedPayload - | PStr ({pstr_desc = Pstr_class_type _} :: _) -> Some UnrecognizedPayload | PStr ({pstr_desc = Pstr_include _} :: _) -> Some UnrecognizedPayload | PStr ({pstr_desc = Pstr_attribute _} :: _) -> Some UnrecognizedPayload | PPat _ -> Some UnrecognizedPayload diff --git a/compiler/core/js_implementation.ml b/compiler/core/js_implementation.ml index 0ff8090aff..5f4e4e6c76 100644 --- a/compiler/core/js_implementation.ml +++ b/compiler/core/js_implementation.ml @@ -96,8 +96,7 @@ let all_module_alias (ast : Parsetree.structure) = | Pstr_attribute _ -> true | Pstr_eval _ | Pstr_value _ | Pstr_primitive _ | Pstr_type _ | Pstr_typext _ | Pstr_exception _ | Pstr_module _ | Pstr_recmodule _ - | Pstr_modtype _ | Pstr_open _ | Pstr_class_type _ | Pstr_include _ - | Pstr_extension _ -> + | Pstr_modtype _ | Pstr_open _ | Pstr_include _ | Pstr_extension _ -> false) let no_export (rest : Parsetree.structure) : Parsetree.structure = diff --git a/compiler/frontend/bs_ast_mapper.ml b/compiler/frontend/bs_ast_mapper.ml index 9149ba2d21..7115605c23 100644 --- a/compiler/frontend/bs_ast_mapper.ml +++ b/compiler/frontend/bs_ast_mapper.ml @@ -286,7 +286,6 @@ module M = struct | Pstr_recmodule l -> rec_module ~loc (List.map (sub.module_binding sub) l) | Pstr_modtype x -> modtype ~loc (sub.module_type_declaration sub x) | Pstr_open x -> open_ ~loc (sub.open_description sub x) - | Pstr_class_type () -> {pstr_loc = loc; pstr_desc = Pstr_class_type ()} | Pstr_include x -> include_ ~loc (sub.include_declaration sub x) | Pstr_extension (x, attrs) -> extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs) diff --git a/compiler/gentype/Annotation.ml b/compiler/gentype/Annotation.ml index 17bf25fd5b..bb810dd439 100644 --- a/compiler/gentype/Annotation.ml +++ b/compiler/gentype/Annotation.ml @@ -83,7 +83,6 @@ let rec get_attribute_payload check_text (attributes : Typedtree.attributes) = | PStr ({pstr_desc = Pstr_recmodule _} :: _) -> Some UnrecognizedPayload | PStr ({pstr_desc = Pstr_modtype _} :: _) -> Some UnrecognizedPayload | PStr ({pstr_desc = Pstr_open _} :: _) -> Some UnrecognizedPayload - | PStr ({pstr_desc = Pstr_class_type _} :: _) -> Some UnrecognizedPayload | PStr ({pstr_desc = Pstr_include _} :: _) -> Some UnrecognizedPayload | PStr ({pstr_desc = Pstr_attribute _} :: _) -> Some UnrecognizedPayload | PPat _ -> Some UnrecognizedPayload diff --git a/compiler/ml/ast_iterator.ml b/compiler/ml/ast_iterator.ml index f7ac769bff..3ef19df637 100644 --- a/compiler/ml/ast_iterator.ml +++ b/compiler/ml/ast_iterator.ml @@ -260,7 +260,6 @@ module M = struct | Pstr_recmodule l -> List.iter (sub.module_binding sub) l | Pstr_modtype x -> sub.module_type_declaration sub x | Pstr_open x -> sub.open_description sub x - | Pstr_class_type () -> () | Pstr_include x -> sub.include_declaration sub x | Pstr_extension (x, attrs) -> sub.extension sub x; diff --git a/compiler/ml/ast_mapper.ml b/compiler/ml/ast_mapper.ml index 81df977cbf..a1a5dd1475 100644 --- a/compiler/ml/ast_mapper.ml +++ b/compiler/ml/ast_mapper.ml @@ -257,7 +257,6 @@ module M = struct | Pstr_recmodule l -> rec_module ~loc (List.map (sub.module_binding sub) l) | Pstr_modtype x -> modtype ~loc (sub.module_type_declaration sub x) | Pstr_open x -> open_ ~loc (sub.open_description sub x) - | Pstr_class_type () -> {pstr_loc = loc; pstr_desc = Pstr_class_type ()} | Pstr_include x -> include_ ~loc (sub.include_declaration sub x) | Pstr_extension (x, attrs) -> extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs) diff --git a/compiler/ml/ast_mapper_from0.ml b/compiler/ml/ast_mapper_from0.ml index 9aa388c754..fbb5194481 100644 --- a/compiler/ml/ast_mapper_from0.ml +++ b/compiler/ml/ast_mapper_from0.ml @@ -284,7 +284,8 @@ module M = struct | Pstr_modtype x -> modtype ~loc (sub.module_type_declaration sub x) | Pstr_open x -> open_ ~loc (sub.open_description sub x) | Pstr_class () -> failwith "Pstr_class is no longer present in ReScript" - | Pstr_class_type () -> {pstr_loc = loc; pstr_desc = Pstr_class_type ()} + | Pstr_class_type () -> + failwith "Pstr_class_type is no longer present in ReScript" | Pstr_include x -> include_ ~loc (sub.include_declaration sub x) | Pstr_extension (x, attrs) -> extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs) diff --git a/compiler/ml/ast_mapper_to0.ml b/compiler/ml/ast_mapper_to0.ml index 4babec74f1..73c7770ac4 100644 --- a/compiler/ml/ast_mapper_to0.ml +++ b/compiler/ml/ast_mapper_to0.ml @@ -274,7 +274,6 @@ module M = struct | Pstr_recmodule l -> rec_module ~loc (List.map (sub.module_binding sub) l) | Pstr_modtype x -> modtype ~loc (sub.module_type_declaration sub x) | Pstr_open x -> open_ ~loc (sub.open_description sub x) - | Pstr_class_type () -> {pstr_loc = loc; pstr_desc = Pstr_class_type ()} | Pstr_include x -> include_ ~loc (sub.include_declaration sub x) | Pstr_extension (x, attrs) -> extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs) diff --git a/compiler/ml/depend.ml b/compiler/ml/depend.ml index c013ac392b..1e948e02b4 100644 --- a/compiler/ml/depend.ml +++ b/compiler/ml/depend.ml @@ -470,7 +470,6 @@ and add_struct_item (bv, m) item : _ StringMap.t * _ StringMap.t = | Some mty -> add_modtype bv mty); (bv, m) | Pstr_open od -> (open_module bv od.popen_lid.txt, m) - | Pstr_class_type () -> (bv, m) | Pstr_include incl -> let (Node (s, m')) = add_module_binding bv incl.pincl_mod in add_names s; diff --git a/compiler/ml/parsetree.ml b/compiler/ml/parsetree.ml index 6c27de8f43..a736b15ab5 100644 --- a/compiler/ml/parsetree.ml +++ b/compiler/ml/parsetree.ml @@ -577,7 +577,6 @@ and structure_item_desc = (* module rec X1 = ME1 and ... and Xn = MEn *) | Pstr_modtype of module_type_declaration (* module type S = MT *) | Pstr_open of open_description (* open X *) - | Pstr_class_type of unit (* Dummy AST node *) | Pstr_include of include_declaration (* include ME *) | Pstr_attribute of attribute (* [@@@id] *) | Pstr_extension of extension * attributes diff --git a/compiler/ml/pprintast.ml b/compiler/ml/pprintast.ml index e441a59cd4..fa1261d699 100644 --- a/compiler/ml/pprintast.ml +++ b/compiler/ml/pprintast.ml @@ -1114,7 +1114,6 @@ and structure_item ctxt f x = pp_print_space f (); pp f "@ =@ %a" (module_type ctxt) mt) md (item_attributes ctxt) attrs - | Pstr_class_type () -> () | Pstr_primitive vd -> pp f "@[external@ %a@ :@ %a@]%a" protect_ident vd.pval_name.txt (value_description ctxt) vd (item_attributes ctxt) vd.pval_attributes diff --git a/compiler/ml/printast.ml b/compiler/ml/printast.ml index 9afeba5e27..c70a8a4e77 100644 --- a/compiler/ml/printast.ml +++ b/compiler/ml/printast.ml @@ -585,7 +585,6 @@ and structure_item i ppf x = line i ppf "Pstr_open %a %a\n" fmt_override_flag od.popen_override fmt_longident_loc od.popen_lid; attributes i ppf od.popen_attributes - | Pstr_class_type () -> () | Pstr_include incl -> line i ppf "Pstr_include"; attributes i ppf incl.pincl_attributes; diff --git a/compiler/ml/typecore.ml b/compiler/ml/typecore.ml index 23a945acb4..0f0d531057 100644 --- a/compiler/ml/typecore.ml +++ b/compiler/ml/typecore.ml @@ -197,9 +197,7 @@ let iter_expression f e = | Pstr_eval (e, _) -> expr e | Pstr_value (_, pel) -> List.iter binding pel | Pstr_primitive _ | Pstr_type _ | Pstr_typext _ | Pstr_exception _ - | Pstr_modtype _ | Pstr_open _ - | Pstr_class_type () - | Pstr_attribute _ | Pstr_extension _ -> + | Pstr_modtype _ | Pstr_open _ | Pstr_attribute _ | Pstr_extension _ -> () | Pstr_include {pincl_mod = me} | Pstr_module {pmb_expr = me} -> module_expr me diff --git a/compiler/ml/typemod.ml b/compiler/ml/typemod.ml index 27872c4966..34380bc648 100644 --- a/compiler/ml/typemod.ml +++ b/compiler/ml/typemod.ml @@ -1565,7 +1565,6 @@ and type_structure ?(toplevel = false) funct_body anchor env sstr scope = | Pstr_open sod -> let _path, newenv, od = type_open ~toplevel env sod in (Tstr_open od, [], newenv) - | Pstr_class_type () -> assert false | Pstr_include sincl -> let smodl = sincl.pincl_mod in let modl = diff --git a/compiler/syntax/src/res_ast_debugger.ml b/compiler/syntax/src/res_ast_debugger.ml index 70f8bb72c4..3356b00da3 100644 --- a/compiler/syntax/src/res_ast_debugger.ml +++ b/compiler/syntax/src/res_ast_debugger.ml @@ -179,7 +179,6 @@ module SexpAst = struct [Sexp.atom "Pstr_modtype"; module_type_declaration mod_typ_decl] | Pstr_open open_desc -> Sexp.list [Sexp.atom "Pstr_open"; open_description open_desc] - | Pstr_class_type _ -> Sexp.atom "Pstr_class_type" | Pstr_include id -> Sexp.list [Sexp.atom "Pstr_include"; include_declaration id] | Pstr_attribute attr -> diff --git a/compiler/syntax/src/res_comments_table.ml b/compiler/syntax/src/res_comments_table.ml index 72b1250347..d487a0fa7c 100644 --- a/compiler/syntax/src/res_comments_table.ml +++ b/compiler/syntax/src/res_comments_table.ml @@ -436,7 +436,6 @@ and walk_structure_item si t comments = | Pstr_exception extension_constructor -> walk_extension_constructor extension_constructor t comments | Pstr_typext type_extension -> walk_type_extension type_extension t comments - | Pstr_class_type _ -> () and walk_value_description vd t comments = let leading, trailing = diff --git a/compiler/syntax/src/res_printer.ml b/compiler/syntax/src/res_printer.ml index ea80338aad..db1532561a 100644 --- a/compiler/syntax/src/res_printer.ml +++ b/compiler/syntax/src/res_printer.ml @@ -614,7 +614,6 @@ and print_structure_item ~state (si : Parsetree.structure_item) cmt_tbl = print_exception_def ~state extension_constructor cmt_tbl | Pstr_typext type_extension -> print_type_extension ~state type_extension cmt_tbl - | Pstr_class_type _ -> Doc.nil and print_type_extension ~state (te : Parsetree.type_extension) cmt_tbl = let prefix = Doc.text "type " in From 402ce9a4ea86dccc81c2f7d3c4b85155e2416cdb Mon Sep 17 00:00:00 2001 From: nojaf Date: Sat, 11 Jan 2025 14:52:44 +0100 Subject: [PATCH 4/8] Remove Psig_class_type --- compiler/frontend/bs_ast_mapper.ml | 1 - compiler/ml/ast_iterator.ml | 1 - compiler/ml/ast_mapper.ml | 1 - 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/typemod.ml | 2 -- compiler/syntax/src/res_ast_debugger.ml | 1 - compiler/syntax/src/res_comments_table.ml | 1 - compiler/syntax/src/res_printer.ml | 1 - 12 files changed, 13 deletions(-) diff --git a/compiler/frontend/bs_ast_mapper.ml b/compiler/frontend/bs_ast_mapper.ml index 7115605c23..dd8ca6cf75 100644 --- a/compiler/frontend/bs_ast_mapper.ml +++ b/compiler/frontend/bs_ast_mapper.ml @@ -232,7 +232,6 @@ module MT = struct | Psig_modtype x -> modtype ~loc (sub.module_type_declaration sub x) | Psig_open x -> open_ ~loc (sub.open_description sub x) | Psig_include x -> include_ ~loc (sub.include_description sub x) - | Psig_class_type () -> assert false | Psig_extension (x, attrs) -> extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs) | Psig_attribute x -> attribute ~loc (sub.attribute sub x) diff --git a/compiler/ml/ast_iterator.ml b/compiler/ml/ast_iterator.ml index 3ef19df637..8bae0d9154 100644 --- a/compiler/ml/ast_iterator.ml +++ b/compiler/ml/ast_iterator.ml @@ -216,7 +216,6 @@ module MT = struct | Psig_modtype x -> sub.module_type_declaration sub x | Psig_open x -> sub.open_description sub x | Psig_include x -> sub.include_description sub x - | Psig_class_type () -> () | Psig_extension (x, attrs) -> sub.extension sub x; sub.attributes sub attrs diff --git a/compiler/ml/ast_mapper.ml b/compiler/ml/ast_mapper.ml index a1a5dd1475..a4d9e5b382 100644 --- a/compiler/ml/ast_mapper.ml +++ b/compiler/ml/ast_mapper.ml @@ -215,7 +215,6 @@ module MT = struct | Psig_modtype x -> modtype ~loc (sub.module_type_declaration sub x) | Psig_open x -> open_ ~loc (sub.open_description sub x) | Psig_include x -> include_ ~loc (sub.include_description sub x) - | Psig_class_type _ -> assert false | Psig_extension (x, attrs) -> extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs) | Psig_attribute x -> attribute ~loc (sub.attribute sub x) diff --git a/compiler/ml/ast_mapper_to0.ml b/compiler/ml/ast_mapper_to0.ml index 73c7770ac4..9cbd9f3303 100644 --- a/compiler/ml/ast_mapper_to0.ml +++ b/compiler/ml/ast_mapper_to0.ml @@ -232,7 +232,6 @@ module MT = struct | Psig_modtype x -> modtype ~loc (sub.module_type_declaration sub x) | Psig_open x -> open_ ~loc (sub.open_description sub x) | Psig_include x -> include_ ~loc (sub.include_description sub x) - | Psig_class_type _ -> assert false | Psig_extension (x, attrs) -> extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs) | Psig_attribute x -> attribute ~loc (sub.attribute sub x) diff --git a/compiler/ml/depend.ml b/compiler/ml/depend.ml index 1e948e02b4..be6e3224fc 100644 --- a/compiler/ml/depend.ml +++ b/compiler/ml/depend.ml @@ -385,7 +385,6 @@ and add_sig_item (bv, m) item = add_names s; let add = StringMap.fold StringMap.add m' in (add bv, add m) - | Psig_class_type () -> (bv, m) | Psig_attribute _ -> (bv, m) | Psig_extension (e, _) -> handle_extension e; diff --git a/compiler/ml/parsetree.ml b/compiler/ml/parsetree.ml index a736b15ab5..0c9beb4bb9 100644 --- a/compiler/ml/parsetree.ml +++ b/compiler/ml/parsetree.ml @@ -476,7 +476,6 @@ and signature_item_desc = module type S *) | Psig_open of open_description (* open X *) | Psig_include of include_description (* include MT *) - | Psig_class_type of unit (* Dummy AST node *) | Psig_attribute of attribute (* [@@@id] *) | Psig_extension of extension * attributes (* [%%id] *) diff --git a/compiler/ml/pprintast.ml b/compiler/ml/pprintast.ml index fa1261d699..d6e4c7f0c2 100644 --- a/compiler/ml/pprintast.ml +++ b/compiler/ml/pprintast.ml @@ -907,7 +907,6 @@ and signature_item ctxt f x : unit = pp_print_space f (); pp f "@ =@ %a" (module_type ctxt) mt) md (item_attributes ctxt) attrs - | Psig_class_type () -> () | Psig_recmodule decls -> let rec string_x_module_type_list f ?(first = true) l = match l with diff --git a/compiler/ml/printast.ml b/compiler/ml/printast.ml index c70a8a4e77..2469a13256 100644 --- a/compiler/ml/printast.ml +++ b/compiler/ml/printast.ml @@ -490,7 +490,6 @@ and signature_item i ppf x = line i ppf "Psig_include\n"; module_type i ppf incl.pincl_mod; attributes i ppf incl.pincl_attributes - | Psig_class_type () -> () | Psig_extension ((s, arg), attrs) -> line i ppf "Psig_extension \"%s\"\n" s.txt; attributes i ppf attrs; diff --git a/compiler/ml/typemod.ml b/compiler/ml/typemod.ml index 34380bc648..be6ac27e51 100644 --- a/compiler/ml/typemod.ml +++ b/compiler/ml/typemod.ml @@ -573,7 +573,6 @@ and approx_sig env ssg = in let newenv = Env.add_signature sg env in sg @ approx_sig newenv srem - | Psig_class_type () -> assert false | _ -> approx_sig env srem) and approx_modtype_info env sinfo = @@ -869,7 +868,6 @@ and transl_signature env sg = in let trem, rem, final_env = transl_sig newenv srem in (mksig (Tsig_include incl) env loc :: trem, sg @ rem, final_env) - | Psig_class_type _ -> assert false | Psig_attribute x -> Builtin_attributes.warning_attribute x; let trem, rem, final_env = transl_sig env srem in diff --git a/compiler/syntax/src/res_ast_debugger.ml b/compiler/syntax/src/res_ast_debugger.ml index 3356b00da3..caaaaa6bdd 100644 --- a/compiler/syntax/src/res_ast_debugger.ml +++ b/compiler/syntax/src/res_ast_debugger.ml @@ -359,7 +359,6 @@ module SexpAst = struct Sexp.list [Sexp.atom "Psig_open"; open_description open_desc] | Psig_include incl_decl -> Sexp.list [Sexp.atom "Psig_include"; include_description incl_decl] - | Psig_class_type _ -> Sexp.list [Sexp.atom "Psig_class_type"] | Psig_attribute attr -> Sexp.list [Sexp.atom "Psig_attribute"; attribute attr] | Psig_extension (ext, attrs) -> diff --git a/compiler/syntax/src/res_comments_table.ml b/compiler/syntax/src/res_comments_table.ml index d487a0fa7c..523d1289c8 100644 --- a/compiler/syntax/src/res_comments_table.ml +++ b/compiler/syntax/src/res_comments_table.ml @@ -544,7 +544,6 @@ and walk_signature_item (si : Parsetree.signature_item) t comments = walk_include_description include_description t comments | Psig_attribute attribute -> walk_attribute attribute t comments | Psig_extension (extension, _) -> walk_extension extension t comments - | Psig_class_type _ -> () and walk_include_description id t comments = let before, inside, after = partition_by_loc comments id.pincl_mod.pmty_loc in diff --git a/compiler/syntax/src/res_printer.ml b/compiler/syntax/src/res_printer.ml index db1532561a..6aa9aa809f 100644 --- a/compiler/syntax/src/res_printer.ml +++ b/compiler/syntax/src/res_printer.ml @@ -973,7 +973,6 @@ and print_signature_item ~state (si : Parsetree.signature_item) cmt_tbl = Doc.concat [print_extension ~state ~at_module_lvl:true extension cmt_tbl]; ] - | Psig_class_type _ -> Doc.nil and print_rec_module_declarations ~state module_declarations cmt_tbl = print_listi From 2e05c259a2050d94b9892bd46353ca74808a352c Mon Sep 17 00:00:00 2001 From: nojaf Date: Sat, 11 Jan 2025 14:58:27 +0100 Subject: [PATCH 5/8] Remove Tstr_class, Tstr_class_type, Tsig_class & Tsig_class_type --- compiler/gentype/Annotation.ml | 6 ++---- compiler/gentype/TranslateSignature.ml | 6 ------ compiler/gentype/TranslateStructure.ml | 6 ------ compiler/ml/printtyped.ml | 4 ---- compiler/ml/rec_check.ml | 2 -- compiler/ml/tast_iterator.ml | 4 ---- compiler/ml/tast_mapper.ml | 6 +----- compiler/ml/translmod.ml | 4 ++-- compiler/ml/typecore.ml | 4 +--- compiler/ml/typedtree.ml | 6 ------ compiler/ml/typedtree.mli | 4 ---- compiler/ml/typedtreeIter.ml | 4 ---- 12 files changed, 6 insertions(+), 50 deletions(-) diff --git a/compiler/gentype/Annotation.ml b/compiler/gentype/Annotation.ml index bb810dd439..9c66678b38 100644 --- a/compiler/gentype/Annotation.ml +++ b/compiler/gentype/Annotation.ml @@ -222,7 +222,7 @@ and signature_item_check_annotation ~check_annotation module_type_declaration |> module_type_declaration_check_annotation ~check_annotation | Tsig_typext _ | Tsig_exception _ | Tsig_recmodule _ | Tsig_open _ - | Tsig_include _ | Tsig_class _ | Tsig_class_type _ -> + | Tsig_include _ -> false and signature_check_annotation ~check_annotation @@ -258,9 +258,7 @@ let rec structure_item_check_annotation ~check_annotation |> module_type_declaration_check_annotation ~check_annotation | Tstr_attribute attribute -> [attribute] |> check_annotation ~loc:structure_item.str_loc - | Tstr_eval _ | Tstr_typext _ | Tstr_exception _ | Tstr_open _ | Tstr_class _ - | Tstr_class_type _ -> - false + | Tstr_eval _ | Tstr_typext _ | Tstr_exception _ | Tstr_open _ -> false and module_expr_check_annotation ~check_annotation (module_expr : Typedtree.module_expr) = diff --git a/compiler/gentype/TranslateSignature.ml b/compiler/gentype/TranslateSignature.ml index 5c3d835f7b..0033ab1edb 100644 --- a/compiler/gentype/TranslateSignature.ml +++ b/compiler/gentype/TranslateSignature.ml @@ -156,12 +156,6 @@ and translate_signature_item ~config ~output_file_relative ~resolver ~type_env | {Typedtree.sig_desc = Typedtree.Tsig_include _} -> log_not_implemented ("Tsig_include " ^ __LOC__); Translation.empty - | {Typedtree.sig_desc = Typedtree.Tsig_class _} -> - log_not_implemented ("Tsig_class " ^ __LOC__); - Translation.empty - | {Typedtree.sig_desc = Typedtree.Tsig_class_type _} -> - log_not_implemented ("Tsig_class_type " ^ __LOC__); - Translation.empty | {Typedtree.sig_desc = Typedtree.Tsig_attribute _} -> log_not_implemented ("Tsig_attribute " ^ __LOC__); Translation.empty diff --git a/compiler/gentype/TranslateStructure.ml b/compiler/gentype/TranslateStructure.ml index 3def28f4a8..9a64cd34a6 100644 --- a/compiler/gentype/TranslateStructure.ml +++ b/compiler/gentype/TranslateStructure.ml @@ -352,12 +352,6 @@ and translate_structure_item ~config ~output_file_relative ~resolver ~type_env | {str_desc = Tstr_open _} -> log_not_implemented ("Tstr_open " ^ __LOC__); Translation.empty - | {str_desc = Tstr_class _} -> - log_not_implemented ("Tstr_class " ^ __LOC__); - Translation.empty - | {str_desc = Tstr_class_type _} -> - log_not_implemented ("Tstr_class_type " ^ __LOC__); - Translation.empty | {str_desc = Tstr_attribute _} -> log_not_implemented ("Tstr_attribute " ^ __LOC__); Translation.empty diff --git a/compiler/ml/printtyped.ml b/compiler/ml/printtyped.ml index 24aea0b5f6..c7ff2df230 100644 --- a/compiler/ml/printtyped.ml +++ b/compiler/ml/printtyped.ml @@ -499,8 +499,6 @@ and signature_item i ppf x = line i ppf "Tsig_include\n"; attributes i ppf incl.incl_attributes; module_type i ppf incl.incl_mod - | Tsig_class () -> () - | Tsig_class_type () -> () | Tsig_attribute (s, arg) -> line i ppf "Tsig_attribute \"%s\"\n" s.txt; Printast.payload i ppf arg @@ -595,8 +593,6 @@ and structure_item i ppf x = line i ppf "Tstr_open %a %a\n" fmt_override_flag od.open_override fmt_path od.open_path; attributes i ppf od.open_attributes - | Tstr_class () -> () - | Tstr_class_type () -> () | Tstr_include incl -> line i ppf "Tstr_include"; attributes i ppf incl.incl_attributes; diff --git a/compiler/ml/rec_check.ml b/compiler/ml/rec_check.ml index e8b523882e..43f13b4e2c 100644 --- a/compiler/ml/rec_check.ml +++ b/compiler/ml/rec_check.ml @@ -356,8 +356,6 @@ and structure_item : Env.env -> Typedtree.structure_item -> Env.env * Use.t = | Tstr_exception _ -> (Env.empty, Use.empty) | Tstr_modtype _ -> (Env.empty, Use.empty) | Tstr_open _ -> (Env.empty, Use.empty) - | Tstr_class () -> (Env.empty, Use.empty) - | Tstr_class_type _ -> (Env.empty, Use.empty) | Tstr_include inc -> (* This is a kind of projection. There's no need to add anything to the environment because everything is used in diff --git a/compiler/ml/tast_iterator.ml b/compiler/ml/tast_iterator.ml index e9d0d1688f..cb546aba4f 100644 --- a/compiler/ml/tast_iterator.ml +++ b/compiler/ml/tast_iterator.ml @@ -69,8 +69,6 @@ let structure_item sub {str_desc; str_env; _} = | Tstr_module mb -> sub.module_binding sub mb | Tstr_recmodule list -> List.iter (sub.module_binding sub) list | Tstr_modtype x -> sub.module_type_declaration sub x - | Tstr_class _ -> () - | Tstr_class_type () -> () | Tstr_include incl -> include_infos (sub.module_expr sub) incl | Tstr_open _ -> () | Tstr_attribute _ -> () @@ -226,8 +224,6 @@ let signature_item sub {sig_desc; sig_env; _} = | Tsig_recmodule list -> List.iter (sub.module_declaration sub) list | Tsig_modtype x -> sub.module_type_declaration sub x | Tsig_include incl -> include_infos (sub.module_type sub) incl - | Tsig_class () -> () - | Tsig_class_type () -> () | Tsig_open _od -> () | Tsig_attribute _ -> () diff --git a/compiler/ml/tast_mapper.ml b/compiler/ml/tast_mapper.ml index 2a351d783e..0b3bbdef67 100644 --- a/compiler/ml/tast_mapper.ml +++ b/compiler/ml/tast_mapper.ml @@ -99,8 +99,6 @@ let structure_item sub {str_desc; str_loc; str_env} = | Tstr_recmodule list -> Tstr_recmodule (List.map (sub.module_binding sub) list) | Tstr_modtype x -> Tstr_modtype (sub.module_type_declaration sub x) - | Tstr_class () -> Tstr_class () - | Tstr_class_type () -> Tstr_class_type () | Tstr_include incl -> Tstr_include (include_infos (sub.module_expr sub) incl) | (Tstr_open _ | Tstr_attribute _) as d -> d @@ -283,9 +281,7 @@ let signature_item sub x = | Tsig_modtype x -> Tsig_modtype (sub.module_type_declaration sub x) | Tsig_include incl -> Tsig_include (include_infos (sub.module_type sub) incl) - | (Tsig_class_type _ | Tsig_class _ | Tsig_open _ | Tsig_attribute _) as d - -> - d + | (Tsig_open _ | Tsig_attribute _) as d -> d in {x with sig_desc; sig_env} diff --git a/compiler/ml/translmod.ml b/compiler/ml/translmod.ml index 60f02bcfc9..e3e0ead663 100644 --- a/compiler/ml/translmod.ml +++ b/compiler/ml/translmod.ml @@ -474,8 +474,8 @@ and transl_structure loc fields cc rootpath final_env = function transl_module Tcoerce_none None modl, body ), size ) - | Tstr_class _ | Tstr_primitive _ | Tstr_type _ | Tstr_modtype _ - | Tstr_open _ | Tstr_class_type _ | Tstr_attribute _ -> + | Tstr_primitive _ | Tstr_type _ | Tstr_modtype _ | Tstr_open _ + | Tstr_attribute _ -> transl_structure loc fields cc rootpath final_env rem) (* Update forward declaration in Translcore *) diff --git a/compiler/ml/typecore.ml b/compiler/ml/typecore.ml index 0f0d531057..90eb7797e3 100644 --- a/compiler/ml/typecore.ml +++ b/compiler/ml/typecore.ml @@ -1850,8 +1850,7 @@ and is_nonexpansive_mod mexp = (fun item -> match item.str_desc with | Tstr_eval _ | Tstr_primitive _ | Tstr_type _ | Tstr_modtype _ - | Tstr_open _ - | Tstr_class_type () -> + | Tstr_open _ -> true | Tstr_value (_, pat_exp_list) -> List.for_all (fun vb -> is_nonexpansive vb.vb_expr) pat_exp_list @@ -1870,7 +1869,6 @@ and is_nonexpansive_mod mexp = | {ext_kind = Text_decl _} -> false | {ext_kind = Text_rebind _} -> true) te.tyext_constructors - | Tstr_class () -> assert false (* impossible *) | Tstr_attribute _ -> true) str.str_items | Tmod_apply _ -> false diff --git a/compiler/ml/typedtree.ml b/compiler/ml/typedtree.ml index 52a08ef16c..4c2f46e875 100644 --- a/compiler/ml/typedtree.ml +++ b/compiler/ml/typedtree.ml @@ -133,8 +133,6 @@ and record_label_definition = | Kept of Types.type_expr | Overridden of Longident.t loc * expression -(* Value expressions for the class language *) - (* Value expressions for the module language *) and module_expr = { mod_desc: module_expr_desc; @@ -180,8 +178,6 @@ and structure_item_desc = | Tstr_recmodule of module_binding list | Tstr_modtype of module_type_declaration | Tstr_open of open_description - | Tstr_class of unit - | Tstr_class_type of unit | Tstr_include of include_declaration | Tstr_attribute of attribute @@ -257,8 +253,6 @@ and signature_item_desc = | Tsig_modtype of module_type_declaration | Tsig_open of open_description | Tsig_include of include_description - | Tsig_class of unit - | Tsig_class_type of unit | Tsig_attribute of attribute and module_declaration = { diff --git a/compiler/ml/typedtree.mli b/compiler/ml/typedtree.mli index 5d8819668f..ac69b510fb 100644 --- a/compiler/ml/typedtree.mli +++ b/compiler/ml/typedtree.mli @@ -286,8 +286,6 @@ and structure_item_desc = | Tstr_recmodule of module_binding list | Tstr_modtype of module_type_declaration | Tstr_open of open_description - | Tstr_class of unit - | Tstr_class_type of unit | Tstr_include of include_declaration | Tstr_attribute of attribute @@ -362,8 +360,6 @@ and signature_item_desc = | Tsig_modtype of module_type_declaration | Tsig_open of open_description | Tsig_include of include_description - | Tsig_class of unit - | Tsig_class_type of unit | Tsig_attribute of attribute and module_declaration = { diff --git a/compiler/ml/typedtreeIter.ml b/compiler/ml/typedtreeIter.ml index 008d9cab56..c616ae257d 100644 --- a/compiler/ml/typedtreeIter.ml +++ b/compiler/ml/typedtreeIter.ml @@ -118,8 +118,6 @@ end = struct | Tstr_recmodule list -> List.iter iter_module_binding list | Tstr_modtype mtd -> iter_module_type_declaration mtd | Tstr_open _ -> () - | Tstr_class () -> () - | Tstr_class_type () -> () | Tstr_include incl -> iter_module_expr incl.incl_mod | Tstr_attribute _ -> ()); Iter.leave_structure_item item @@ -321,8 +319,6 @@ end = struct | Tsig_modtype mtd -> iter_module_type_declaration mtd | Tsig_open _ -> () | Tsig_include incl -> iter_module_type incl.incl_mod - | Tsig_class () -> () - | Tsig_class_type () -> () | Tsig_attribute _ -> ()); Iter.leave_signature_item item From 156f6ca6f12922559ea73d2e24de9300771456c2 Mon Sep 17 00:00:00 2001 From: nojaf Date: Sat, 11 Jan 2025 15:04:44 +0100 Subject: [PATCH 6/8] Add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae187fc1ff..e5d7b64517 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ - 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` & `expression_desc.Texp_instvar` from AST as it is unused. https://github.com/rescript-lang/rescript/pull/7239 - 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 +- AST cleanup: Remove `structure_item_desc.Pstr_class`, `signature_item_desc.Psig_class`, `structure_item_desc.Pstr_class_type`, `signature_item_desc.Psig_class_type`, `structure_item_desc.Tstr_class`, `structure_item_desc.Tstr_class_type`, `signature_item_desc.Tsig_class`, `signature_item_desc.Tsig_class_type` from AST as it is unused. https://github.com/rescript-lang/rescript/pull/7242 # 12.0.0-alpha.7 From b81f4a3e61010155eab3ac6b68db5545eb1185ac Mon Sep 17 00:00:00 2001 From: nojaf Date: Mon, 13 Jan 2025 08:20:11 +0100 Subject: [PATCH 7/8] Remove unit in Texp_coerce --- compiler/ml/printtyped.ml | 2 +- compiler/ml/tast_iterator.ml | 2 +- compiler/ml/tast_mapper.ml | 2 +- compiler/ml/typecore.ml | 2 +- compiler/ml/typedtree.ml | 2 +- compiler/ml/typedtree.mli | 3 +-- compiler/ml/typedtreeIter.ml | 2 +- 7 files changed, 7 insertions(+), 8 deletions(-) diff --git a/compiler/ml/printtyped.ml b/compiler/ml/printtyped.ml index c7ff2df230..31cb9ef213 100644 --- a/compiler/ml/printtyped.ml +++ b/compiler/ml/printtyped.ml @@ -252,7 +252,7 @@ and expression_extra i ppf x attrs = line i ppf "Texp_constraint\n"; attributes i ppf attrs; core_type i ppf ct - | Texp_coerce ((), cto2) -> + | Texp_coerce cto2 -> line i ppf "Texp_coerce\n"; attributes i ppf attrs; core_type i ppf cto2 diff --git a/compiler/ml/tast_iterator.ml b/compiler/ml/tast_iterator.ml index cb546aba4f..3220aa87fe 100644 --- a/compiler/ml/tast_iterator.ml +++ b/compiler/ml/tast_iterator.ml @@ -140,7 +140,7 @@ let pat sub {pat_extra; pat_desc; pat_env; _} = let expr sub {exp_extra; exp_desc; exp_env; _} = let extra = function | Texp_constraint cty -> sub.typ sub cty - | Texp_coerce ((), cty2) -> sub.typ sub cty2 + | Texp_coerce cty2 -> sub.typ sub cty2 | Texp_newtype _ -> () | Texp_open (_, _, _, _) -> () in diff --git a/compiler/ml/tast_mapper.ml b/compiler/ml/tast_mapper.ml index 0b3bbdef67..8064d65990 100644 --- a/compiler/ml/tast_mapper.ml +++ b/compiler/ml/tast_mapper.ml @@ -183,7 +183,7 @@ let pat sub x = let expr sub x = let extra = function | Texp_constraint cty -> Texp_constraint (sub.typ sub cty) - | Texp_coerce ((), cty2) -> Texp_coerce ((), sub.typ sub cty2) + | Texp_coerce cty2 -> Texp_coerce (sub.typ sub cty2) | Texp_open (ovf, path, loc, env) -> Texp_open (ovf, path, loc, sub.env sub env) | Texp_newtype _ as d -> d diff --git a/compiler/ml/typecore.ml b/compiler/ml/typecore.ml index 90eb7797e3..c35a45702f 100644 --- a/compiler/ml/typecore.ml +++ b/compiler/ml/typecore.ml @@ -2974,7 +2974,7 @@ and type_expect_ ?type_clash_context ?in_function ?(recarg = Rejected) env sexp exp_attributes = arg.exp_attributes; exp_env = env; exp_extra = - (Texp_coerce ((), cty'), loc, sexp.pexp_attributes) :: arg.exp_extra; + (Texp_coerce cty', loc, sexp.pexp_attributes) :: arg.exp_extra; } | Pexp_send (e, {txt = met}) -> ( let obj = type_exp env e in diff --git a/compiler/ml/typedtree.ml b/compiler/ml/typedtree.ml index 4c2f46e875..3421de7041 100644 --- a/compiler/ml/typedtree.ml +++ b/compiler/ml/typedtree.ml @@ -67,7 +67,7 @@ and expression = { and exp_extra = | Texp_constraint of core_type - | Texp_coerce of unit * core_type + | Texp_coerce of core_type | Texp_open of override_flag * Path.t * Longident.t loc * Env.t | Texp_newtype of string diff --git a/compiler/ml/typedtree.mli b/compiler/ml/typedtree.mli index ac69b510fb..b28f807aba 100644 --- a/compiler/ml/typedtree.mli +++ b/compiler/ml/typedtree.mli @@ -110,8 +110,7 @@ and expression = { and exp_extra = | Texp_constraint of core_type (** E : T *) - | Texp_coerce of unit * core_type - (** E :> T [Texp_coerce T] + | Texp_coerce of core_type (** E :> T [Texp_coerce T] *) | Texp_open of override_flag * Path.t * Longident.t loc * Env.t (** let open[!] M in [Texp_open (!, P, M, env)] diff --git a/compiler/ml/typedtreeIter.ml b/compiler/ml/typedtreeIter.ml index c616ae257d..e0fe1e228e 100644 --- a/compiler/ml/typedtreeIter.ml +++ b/compiler/ml/typedtreeIter.ml @@ -217,7 +217,7 @@ end = struct | cstr, _, _attrs -> ( match cstr with | Texp_constraint ct -> iter_core_type ct - | Texp_coerce ((), cty2) -> iter_core_type cty2 + | Texp_coerce cty2 -> iter_core_type cty2 | Texp_open _ -> () | Texp_newtype _ -> ())) exp.exp_extra; From 9a02d893b9175ebb504aebe6b48feca746ecc405 Mon Sep 17 00:00:00 2001 From: nojaf Date: Mon, 13 Jan 2025 08:22:53 +0100 Subject: [PATCH 8/8] Remove row_bound in row_desc --- compiler/ml/btype.ml | 1 - compiler/ml/ctype.ml | 4 ---- compiler/ml/typecore.ml | 5 ----- compiler/ml/types.ml | 1 - compiler/ml/types.mli | 1 - compiler/ml/typetexp.ml | 2 -- 6 files changed, 14 deletions(-) diff --git a/compiler/ml/btype.ml b/compiler/ml/btype.ml index 7afaf52f4b..81e8d24cd0 100644 --- a/compiler/ml/btype.ml +++ b/compiler/ml/btype.ml @@ -404,7 +404,6 @@ let copy_row f fixed row keep more = { row_fields = fields; row_more = more; - row_bound = (); row_fixed = row.row_fixed && fixed; row_closed = row.row_closed; row_name = name; diff --git a/compiler/ml/ctype.ml b/compiler/ml/ctype.ml index 9605e37279..de2ad58632 100644 --- a/compiler/ml/ctype.ml +++ b/compiler/ml/ctype.ml @@ -933,7 +933,6 @@ let rec copy ?env ?partial ?keep_names ty = { row_fields = Ext_list.filter row.row_fields not_reither; row_more = more'; - row_bound = (); row_closed = false; row_fixed = false; row_name = None; @@ -1722,7 +1721,6 @@ let mkvariant fields closed = row_fields = fields; row_closed = closed; row_more = newvar (); - row_bound = (); row_fixed = false; row_name = None; }) @@ -2554,7 +2552,6 @@ and unify_row env row1 row2 = { row_fields = []; row_more = more; - row_bound = (); row_closed = closed; row_fixed = fixed; row_name = name; @@ -3486,7 +3483,6 @@ let rec build_subtype env visited loops posi level t = { row_fields = List.map fst fields; row_more = newvar (); - row_bound = (); row_closed = posi; row_fixed = false; row_name = (if c > Unchanged then None else row.row_name); diff --git a/compiler/ml/typecore.ml b/compiler/ml/typecore.ml index c35a45702f..df9b6ddefa 100644 --- a/compiler/ml/typecore.ml +++ b/compiler/ml/typecore.ml @@ -474,7 +474,6 @@ let rec build_as_type env p = { row_fields = [(l, Rpresent ty)]; row_more = newvar (); - row_bound = (); row_name = None; row_fixed = false; row_closed = false; @@ -553,7 +552,6 @@ let build_or_pat env loc lid = { row_fields = List.rev fields; row_more = newvar (); - row_bound = (); row_closed = false; row_fixed = false; row_name = Some (path, tyl); @@ -1429,7 +1427,6 @@ and type_pat_aux ~constrs ~labels ~no_existentials ~mode ~explode ~env sp let row = { row_fields = [(l, Reither (sarg = None, arg_type, true, ref None))]; - row_bound = (); row_closed = false; row_more = newvar (); row_fixed = false; @@ -2124,7 +2121,6 @@ let check_absent_variant env = { row_fields = [(s, Reither (arg = None, ty_arg, true, ref None))]; row_more = newvar (); - row_bound = (); row_closed = false; row_fixed = false; row_name = None; @@ -2559,7 +2555,6 @@ and type_expect_ ?type_clash_context ?in_function ?(recarg = Rejected) env sexp { row_fields = [(l, Rpresent arg_type)]; row_more = newvar (); - row_bound = (); row_closed = false; row_fixed = false; row_name = None; diff --git a/compiler/ml/types.ml b/compiler/ml/types.ml index 215f7e72b6..a7f74ec54e 100644 --- a/compiler/ml/types.ml +++ b/compiler/ml/types.ml @@ -39,7 +39,6 @@ and type_desc = and row_desc = { row_fields: (label * row_field) list; row_more: type_expr; - row_bound: unit; row_closed: bool; row_fixed: bool; row_name: (Path.t * type_expr list) option; diff --git a/compiler/ml/types.mli b/compiler/ml/types.mli index ac09932a09..ce44a9e2ac 100644 --- a/compiler/ml/types.mli +++ b/compiler/ml/types.mli @@ -113,7 +113,6 @@ and type_desc = and row_desc = { row_fields: (label * row_field) list; row_more: type_expr; - row_bound: unit; (* kept for compatibility *) row_closed: bool; row_fixed: bool; row_name: (Path.t * type_expr list) option; diff --git a/compiler/ml/typetexp.ml b/compiler/ml/typetexp.ml index bbd02d5498..30ab5cffd0 100644 --- a/compiler/ml/typetexp.ml +++ b/compiler/ml/typetexp.ml @@ -422,7 +422,6 @@ and transl_type_aux env policy styp = { row_fields = [(l, f)]; row_more = newvar (); - row_bound = (); row_closed = true; row_fixed = false; row_name = None; @@ -509,7 +508,6 @@ and transl_type_aux env policy styp = { row_fields = List.rev fields; row_more = newvar (); - row_bound = (); row_closed = closed = Closed; row_fixed = false; row_name = !name;