Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 0 additions & 6 deletions analysis/src/create_interface.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 0 additions & 27 deletions compiler/core/lam_print.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions compiler/gentype/translate_signature_from_types.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions compiler/gentype/translate_type_expr_from_types.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
2 changes: 0 additions & 2 deletions compiler/ml/btype.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 1 addition & 7 deletions compiler/ml/env.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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) ->
Expand Down Expand Up @@ -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
Expand Down
17 changes: 3 additions & 14 deletions compiler/ml/includemod.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 *)

Expand Down Expand Up @@ -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 ->
Expand Down Expand Up @@ -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 ->
Expand Down Expand Up @@ -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 =
Expand Down
21 changes: 6 additions & 15 deletions compiler/ml/mtype.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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 *)

Expand Down Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions compiler/ml/printtyp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
{
Expand Down Expand Up @@ -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 =
Expand Down
4 changes: 0 additions & 4 deletions compiler/ml/subst.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 =
{
Expand Down
2 changes: 0 additions & 2 deletions compiler/ml/transl_recmodule.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion compiler/ml/translmod.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions compiler/ml/types.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions compiler/ml/types.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading