diff --git a/CHANGELOG.md b/CHANGELOG.md index 070c866edc..e17f2cbc3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,7 @@ - Refactor analysis CLI helpers to use source input. https://github.com/rescript-lang/rescript/pull/8466 - Include syntax, gentype, analysis, tools, and reanalyze tests in coverage reports. https://github.com/rescript-lang/rescript/pull/8467 - Remove the unreachable `Longident.Lapply` constructor (OCaml's applicative-functor path syntax `F(X).t`, which ReScript's grammar cannot produce). https://github.com/rescript-lang/rescript/pull/8469 +- Remove the dead `Sig_class`/`Sig_class_type` signature variants (OCaml class items, which ReScript cannot produce). https://github.com/rescript-lang/rescript/pull/8470 # 13.0.0-alpha.4 diff --git a/analysis/src/create_interface.ml b/analysis/src/create_interface.ml index 506b52cc77..e9eee9575c 100644 --- a/analysis/src/create_interface.ml +++ b/analysis/src/create_interface.ml @@ -263,12 +263,6 @@ let print_signature ~extractor ~signature = in Buffer.add_string buf (indent ^ new_item_str ^ "\n"); process_signature ~indent items - | Sig_class _ :: items -> - (* not needed *) - process_signature ~indent items - | Sig_class_type _ :: items -> - (* not needed *) - process_signature ~indent items | [] -> () and process_module_type ~indent (mt : Types.module_type) = match mt with diff --git a/compiler/core/lam_print.ml b/compiler/core/lam_print.ml index 9408b11aea..e5224c5f30 100644 --- a/compiler/core/lam_print.ml +++ b/compiler/core/lam_print.ml @@ -254,33 +254,6 @@ let flatten (lam : Lam.t) : (print_kind * Ident.t * Lam.t) list * Lam.t = aux (Ext_list.map bind_args (fun (id, l) -> (Recursive, id, l))) body | _ -> assert false -(* let get_string ((id : Ident.t), (pos : int)) (env : Env.t) : string = - match Env.find_module (Pident id) env with - | {md_type = Mty_signature signature ; _ } -> - (* Env.prefix_idents, could be cached *) - let serializable_sigs = - Ext_list.filter (fun x -> - match x with - | Sig_typext _ - | Sig_module _ - | Sig_class _ -> true - | Sig_value(_, {val_kind = Val_prim _}) -> false - | Sig_value _ -> true - | _ -> false - ) signature in - (begin match Ext_list.nth_opt serializable_sigs pos with - | Some (Sig_value (i,_) - | Sig_module (i,_,_) - | Sig_typext (i,_,_) - | Sig_modtype(i,_) - | Sig_class (i,_,_) - | Sig_class_type(i,_,_) - | Sig_type(i,_,_)) -> i - | None -> assert false - end).name - | _ -> assert false -*) - let lambda ppf v = let rec lam ppf (l : Lam.t) = match l with diff --git a/compiler/gentype/translate_signature_from_types.ml b/compiler/gentype/translate_signature_from_types.ml index 5192129152..72102774f8 100644 --- a/compiler/gentype/translate_signature_from_types.ml +++ b/compiler/gentype/translate_signature_from_types.ml @@ -93,12 +93,6 @@ and translate_signature_item_from_types ~config ~output_file_relative ~resolver | Types.Sig_modtype _ -> log_not_implemented ("Sig_modtype " ^ __LOC__); Translation.empty - | Types.Sig_class _ -> - log_not_implemented ("Sig_class " ^ __LOC__); - Translation.empty - | Types.Sig_class_type _ -> - log_not_implemented ("Sig_class_type " ^ __LOC__); - Translation.empty (** Like translateSignature but from Types not Typedtree *) and translate_signature_from_types ~config ~output_file_relative ~resolver diff --git a/compiler/gentype/translate_type_expr_from_types.ml b/compiler/gentype/translate_type_expr_from_types.ml index f88aedc2f5..96dd88cabe 100644 --- a/compiler/gentype/translate_type_expr_from_types.ml +++ b/compiler/gentype/translate_type_expr_from_types.ml @@ -750,8 +750,7 @@ and signature_to_module_runtime_representation ~config ~type_vars_gen ~type_env } in (dependencies, [field]) - | Types.Sig_type _ | Types.Sig_typext _ | Types.Sig_modtype _ - | Types.Sig_class _ | Types.Sig_class_type _ -> + | Types.Sig_type _ | Types.Sig_typext _ | Types.Sig_modtype _ -> ([], [])) in let dependencies, fields = diff --git a/compiler/ml/btype.ml b/compiler/ml/btype.ml index dc72b0578f..1eeed117f4 100644 --- a/compiler/ml/btype.ml +++ b/compiler/ml/btype.ml @@ -335,8 +335,6 @@ let type_iterators = | Sig_typext (_, td, _) -> it.it_extension_constructor it td | Sig_module (_, md, _) -> it.it_module_declaration it md | Sig_modtype (_, mtd) -> it.it_modtype_declaration it mtd - | Sig_class () -> assert false - | Sig_class_type () -> assert false and it_value_description it vd = it.it_type_expr it vd.val_type and it_type_declaration it td = List.iter (it.it_type_expr it) td.type_params; diff --git a/compiler/ml/env.ml b/compiler/ml/env.ml index a64f79185f..ba57ce091c 100644 --- a/compiler/ml/env.ml +++ b/compiler/ml/env.ml @@ -1454,8 +1454,6 @@ let rec prefix_idents root pos sub = function prefix_idents root pos (Subst.add_modtype id (Mty_ident p) sub) rem in (p :: pl, final_sub) - | Sig_class _ :: _ -> assert false - | Sig_class_type _ :: _ -> assert false let prefix_idents root sub sg = if sub = Subst.identity then ( @@ -1551,9 +1549,7 @@ and components_of_module_maker (env, sub, path, mty) = let decl' = Subst.modtype_declaration sub decl in c.comp_modtypes <- Tbl.add (Ident.name id) (decl', nopos) c.comp_modtypes; - env := store_modtype id decl !env - | Sig_class () -> assert false - | Sig_class_type () -> assert false) + env := store_modtype id decl !env) sg pl; Some (Structure_comps c) | Mty_functor (param, _ty_arg, ty_res) -> @@ -1796,8 +1792,6 @@ let add_item comp env = | Sig_typext (id, ext, _) -> add_extension ~check:false id ext env | Sig_module (id, md, _) -> add_module_declaration ~check:false id md env | Sig_modtype (id, decl) -> add_modtype id decl env - | Sig_class () -> env - | Sig_class_type () -> env let rec add_signature sg env = match sg with diff --git a/compiler/ml/includemod.ml b/compiler/ml/includemod.ml index d4c01d405e..bd2e430030 100644 --- a/compiler/ml/includemod.ml +++ b/compiler/ml/includemod.ml @@ -126,20 +126,13 @@ let item_ident_name = function | Sig_typext (id, d, _) -> (id, d.ext_loc, Field_typext (Ident.name id)) | Sig_module (id, d, _) -> (id, d.md_loc, Field_module (Ident.name id)) | Sig_modtype (id, d) -> (id, d.mtd_loc, Field_modtype (Ident.name id)) - | Sig_class () -> assert false - | Sig_class_type () -> assert false let is_runtime_component = function | Sig_value (_, {val_kind = Val_prim _}) | Sig_type (_, _, _) - | Sig_modtype (_, _) - | Sig_class_type () -> + | Sig_modtype (_, _) -> false - | Sig_value (_, _) - | Sig_typext (_, _, _) - | Sig_module (_, _, _) - | Sig_class () -> - true + | Sig_value (_, _) | Sig_typext (_, _, _) | Sig_module (_, _, _) -> true (* Print a coercion *) @@ -301,7 +294,6 @@ and signatures ~loc env cxt subst sig1 sig2 = | Sig_modtype (i, _) | Sig_type (i, _, _) -> Ident.name i - | Sig_class () | Sig_class_type () -> assert false in List.fold_right (fun item fields -> @@ -360,8 +352,7 @@ and signatures ~loc env cxt subst sig1 sig2 = | Sig_module _ -> Subst.add_module id2 (Pident id1) subst | Sig_modtype _ -> Subst.add_modtype id2 (Mty_ident (Pident id1)) subst - | Sig_value _ | Sig_typext _ | Sig_class _ | Sig_class_type () -> - subst + | Sig_value _ | Sig_typext _ -> subst in pair_components new_subst ((item1, item2, pos1) :: paired) unpaired rem | exception Not_found -> @@ -399,8 +390,6 @@ and signature_components ~loc old_env env cxt subst paired = | (Sig_modtype (id1, info1), Sig_modtype (_id2, info2), _pos) :: rem -> modtype_infos ~loc env cxt subst id1 info1 info2; comps_rec rem - | (Sig_class (), Sig_class (), _) :: _ -> assert false - | (Sig_class_type (), Sig_class_type (), _pos) :: _ -> assert false | _ -> assert false and module_declarations ~loc env cxt subst id1 md1 md2 = diff --git a/compiler/ml/mtype.ml b/compiler/ml/mtype.ml index 4ed00e0054..f6f243ade1 100644 --- a/compiler/ml/mtype.ml +++ b/compiler/ml/mtype.ml @@ -89,11 +89,7 @@ and strengthen_sig ~aliasable env sg p pos = in Sig_modtype (id, newdecl) :: strengthen_sig ~aliasable (Env.add_modtype id decl env) rem p pos - (* Need to add the module type in case it is manifest *) - | (Sig_class _ as sigelt) :: rem -> - sigelt :: strengthen_sig ~aliasable env rem p (pos + 1) - | (Sig_class_type _ as sigelt) :: rem -> - sigelt :: strengthen_sig ~aliasable env rem p pos +(* Need to add the module type in case it is manifest *) and strengthen_decl ~aliasable env md p = match md.md_type with @@ -160,9 +156,7 @@ let nondep_supertype env mid mty = {mtd_type = None; mtd_loc = Location.none; mtd_attributes = []} ) :: rem' - | _ -> raise Not_found)) - | Sig_class () -> assert false - | Sig_class_type () -> assert false) + | _ -> raise Not_found))) and nondep_modtype_decl env mtd = {mtd with mtd_type = Misc.may_map (nondep_mty env Strict) mtd.mtd_type} in @@ -229,8 +223,7 @@ and type_paths_sig env p pos sg = p (pos + 1) rem | Sig_modtype (id, decl) :: rem -> type_paths_sig (Env.add_modtype id decl env) p pos rem - | (Sig_typext _ | Sig_class _) :: rem -> type_paths_sig env p (pos + 1) rem - | Sig_class_type _ :: rem -> type_paths_sig env p pos rem + | Sig_typext _ :: rem -> type_paths_sig env p (pos + 1) rem let rec no_code_needed env mty = match scrape env mty with @@ -252,9 +245,8 @@ and no_code_needed_sig env sg = && no_code_needed_sig (Env.add_module_declaration ~check:false id md env) rem - | (Sig_type _ | Sig_modtype _ | Sig_class_type _) :: rem -> - no_code_needed_sig env rem - | (Sig_typext _ | Sig_class _) :: _ -> false + | (Sig_type _ | Sig_modtype _) :: rem -> no_code_needed_sig env rem + | Sig_typext _ :: _ -> false (* Check whether a module type may return types *) @@ -286,8 +278,7 @@ and contains_type_item env = function is kept local to expressions. *) raise Exit | Sig_module (_, {md_type = mty}, _) -> contains_type env mty - | Sig_value _ | Sig_type _ | Sig_typext _ | Sig_class _ | Sig_class_type _ -> - () + | Sig_value _ | Sig_type _ | Sig_typext _ -> () let contains_type env mty = try diff --git a/compiler/ml/printtyp.ml b/compiler/ml/printtyp.ml index 6dabdb5f61..f1bfdd2260 100644 --- a/compiler/ml/printtyp.ml +++ b/compiler/ml/printtyp.ml @@ -1071,10 +1071,7 @@ let wrap_env fenv ftree arg = set_printing_env env; tree -let filter_rem_sig item rem = - match (item, rem) with - | Sig_class_type _, tydecl1 :: tydecl2 :: rem -> ([tydecl1; tydecl2], rem) - | _ -> ([], rem) +let filter_rem_sig _item rem = ([], rem) let dummy = { @@ -1161,8 +1158,6 @@ and trees_of_sigitem = function in [tree_of_module id md.md_type rs ~ellipsis] | Sig_modtype (id, decl) -> [tree_of_modtype_declaration id decl] - | Sig_class () -> [] - | Sig_class_type () -> [] and tree_of_modtype_declaration id decl = let mty = diff --git a/compiler/ml/subst.ml b/compiler/ml/subst.ml index 6956e90d49..9eeceac118 100644 --- a/compiler/ml/subst.ml +++ b/compiler/ml/subst.ml @@ -337,11 +337,9 @@ let rec rename_bound_idents s idents = function rename_bound_idents (add_modtype id (Mty_ident (Pident id')) s) (id' :: idents) sg - | Sig_class_type () :: _ -> assert false | (Sig_value (id, _) | Sig_typext (id, _, _)) :: sg -> let id' = Ident.rename id in rename_bound_idents s (id' :: idents) sg - | Sig_class _ :: _ -> assert false let rec modtype s = function | Mty_ident p as mty -> ( match p with @@ -371,8 +369,6 @@ and signature_component s comp newid = Sig_typext (newid, extension_constructor s ext, es) | Sig_module (_id, d, rs) -> Sig_module (newid, module_declaration s d, rs) | Sig_modtype (_id, d) -> Sig_modtype (newid, modtype_declaration s d) - | Sig_class () -> Sig_class () - | Sig_class_type () -> Sig_class_type () and module_declaration s decl = { diff --git a/compiler/ml/transl_recmodule.ml b/compiler/ml/transl_recmodule.ml index 77617eda5d..f19f827aa7 100644 --- a/compiler/ml/transl_recmodule.ml +++ b/compiler/ml/transl_recmodule.ml @@ -80,8 +80,6 @@ let init_shape modl = rem | Sig_modtype (id, minfo) :: rem -> init_shape_struct (Env.add_modtype id minfo env) rem - | Sig_class _ :: _ -> assert false - | Sig_class_type _ :: rem -> init_shape_struct env rem in try Some diff --git a/compiler/ml/translmod.ml b/compiler/ml/translmod.ml index 7e846adbb6..aaf8312967 100644 --- a/compiler/ml/translmod.ml +++ b/compiler/ml/translmod.ml @@ -195,7 +195,6 @@ let rec bound_value_identifiers : Types.signature_item list -> Ident.t list = id :: bound_value_identifiers rem | Sig_typext (id, _, _) :: rem -> id :: bound_value_identifiers rem | Sig_module (id, _, _) :: rem -> id :: bound_value_identifiers rem - | Sig_class _ :: _ -> assert false | _ :: rem -> bound_value_identifiers rem (* Compile one or more functors, merging curried functors to produce diff --git a/compiler/ml/types.ml b/compiler/ml/types.ml index 9f443f3c5f..c6b2619803 100644 --- a/compiler/ml/types.ml +++ b/compiler/ml/types.ml @@ -226,8 +226,6 @@ and signature_item = | Sig_typext of Ident.t * extension_constructor * ext_status | Sig_module of Ident.t * module_declaration * rec_status | Sig_modtype of Ident.t * modtype_declaration - | Sig_class of unit - | Sig_class_type of unit (* Dummy AST node *) and module_declaration = { md_type: module_type; diff --git a/compiler/ml/types.mli b/compiler/ml/types.mli index 598030ff12..2ceef397d2 100644 --- a/compiler/ml/types.mli +++ b/compiler/ml/types.mli @@ -357,8 +357,6 @@ and signature_item = | Sig_typext of Ident.t * extension_constructor * ext_status | Sig_module of Ident.t * module_declaration * rec_status | Sig_modtype of Ident.t * modtype_declaration - | Sig_class of unit - | Sig_class_type of unit (* Dummy AST node *) and module_declaration = { md_type: module_type;