Skip to content

Commit

Permalink
refactor modality, trivial
Browse files Browse the repository at this point in the history
  • Loading branch information
riaqn committed Apr 6, 2024
1 parent 00f880f commit 64dbf60
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 87 deletions.
17 changes: 9 additions & 8 deletions ocaml/.depend
Original file line number Diff line number Diff line change
Expand Up @@ -687,20 +687,23 @@ typing/annot.cmi : \
typing/btype.cmo : \
typing/types.cmi \
typing/path.cmi \
parsing/parsetree.cmi \
utils/local_store.cmi \
typing/ident.cmi \
parsing/asttypes.cmi \
typing/btype.cmi
typing/btype.cmx : \
typing/types.cmx \
typing/path.cmx \
parsing/parsetree.cmi \
utils/local_store.cmx \
typing/ident.cmx \
parsing/asttypes.cmi \
typing/btype.cmi
typing/btype.cmi : \
typing/types.cmi \
typing/path.cmi \
parsing/parsetree.cmi \
typing/jkind.cmi \
parsing/asttypes.cmi
typing/cmt2annot.cmo : \
Expand Down Expand Up @@ -998,6 +1001,7 @@ typing/includecore.cmi : \
typing/types.cmi \
typing/typedtree.cmi \
typing/path.cmi \
typing/mode.cmi \
parsing/location.cmi \
typing/jkind.cmi \
typing/ident.cmi \
Expand Down Expand Up @@ -1445,12 +1449,12 @@ typing/printtyp.cmi : \
typing/shape.cmi \
typing/path.cmi \
typing/outcometree.cmi \
typing/mode.cmi \
parsing/longident.cmi \
parsing/location.cmi \
typing/ident.cmi \
typing/errortrace.cmi \
typing/env.cmi \
parsing/asttypes.cmi
typing/env.cmi
typing/printtyped.cmo : \
typing/types.cmi \
typing/typedtree.cmi \
Expand Down Expand Up @@ -1910,6 +1914,7 @@ typing/typedecl.cmi : \
typing/typedecl_separability.cmi \
typing/path.cmi \
parsing/parsetree.cmi \
typing/mode.cmi \
parsing/longident.cmi \
parsing/location.cmi \
typing/jkind.cmi \
Expand Down Expand Up @@ -2143,13 +2148,15 @@ typing/typemod.cmi : \
file_formats/cmi_format.cmi
typing/typemode.cmo : \
utils/warnings.cmi \
typing/printtyp.cmi \
typing/mode.cmi \
parsing/location.cmi \
parsing/jane_syntax_parsing.cmi \
parsing/jane_syntax.cmi \
typing/typemode.cmi
typing/typemode.cmx : \
utils/warnings.cmx \
typing/printtyp.cmx \
typing/mode.cmx \
parsing/location.cmx \
parsing/jane_syntax_parsing.cmx \
Expand Down Expand Up @@ -4256,7 +4263,6 @@ lambda/translattribute.cmo : \
utils/config.cmi \
utils/clflags.cmi \
parsing/builtin_attributes.cmi \
parsing/asttypes.cmi \
lambda/assume_info.cmi \
lambda/translattribute.cmi
lambda/translattribute.cmx : \
Expand All @@ -4270,7 +4276,6 @@ lambda/translattribute.cmx : \
utils/config.cmx \
utils/clflags.cmx \
parsing/builtin_attributes.cmx \
parsing/asttypes.cmi \
lambda/assume_info.cmx \
lambda/translattribute.cmi
lambda/translattribute.cmi : \
Expand Down Expand Up @@ -7225,7 +7230,6 @@ toplevel/topprinters.cmo : \
typing/mode.cmi \
typing/ident.cmi \
typing/ctype.cmi \
parsing/asttypes.cmi \
toplevel/topprinters.cmi
toplevel/topprinters.cmx : \
typing/types.cmx \
Expand All @@ -7234,7 +7238,6 @@ toplevel/topprinters.cmx : \
typing/mode.cmx \
typing/ident.cmx \
typing/ctype.cmx \
parsing/asttypes.cmi \
toplevel/topprinters.cmi
toplevel/topprinters.cmi : \
typing/types.cmi
Expand Down Expand Up @@ -7371,7 +7374,6 @@ toplevel/byte/trace.cmo : \
bytecomp/meta.cmi \
parsing/longident.cmi \
typing/ctype.cmi \
parsing/asttypes.cmi \
toplevel/byte/trace.cmi
toplevel/byte/trace.cmx : \
typing/types.cmx \
Expand All @@ -7384,7 +7386,6 @@ toplevel/byte/trace.cmx : \
bytecomp/meta.cmx \
parsing/longident.cmx \
typing/ctype.cmx \
parsing/asttypes.cmi \
toplevel/byte/trace.cmi
toplevel/byte/trace.cmi : \
typing/types.cmi \
Expand Down
2 changes: 1 addition & 1 deletion ocaml/ocamldoc/odoc_sig.ml
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ module Analyser =
let record comments
{ Typedtree.ld_id; ld_mutable; ld_type; ld_loc; ld_attributes } =
get_field env comments @@
{Types.ld_id; ld_mutable; ld_global = Unrestricted;
{Types.ld_id; ld_mutable; ld_modalities = Mode.Modality.Vector.id;
ld_jkind=Jkind.any ~why:Dummy_jkind (* ignored *);
ld_type=ld_type.Typedtree.ctyp_type;
ld_loc; ld_attributes; ld_uid=Types.Uid.internal_not_actually_unique} in
Expand Down
8 changes: 4 additions & 4 deletions ocaml/testsuite/tests/typing-local/local.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1667,7 +1667,7 @@ Error: Signature mismatch:
foo : string;
is not the same as:
global_ foo : string;
The second is global and the first is not.
The second is global_ and the first is not.
|}]
module M : sig
Expand All @@ -1693,7 +1693,7 @@ Error: Signature mismatch:
global_ foo : string;
is not the same as:
foo : string;
The first is global and the second is not.
The first is global_ and the second is not.
|}]
(* Special handling of tuples in matches and let bindings *)
Expand Down Expand Up @@ -2504,7 +2504,7 @@ Error: Signature mismatch:
Bar of int * string
is not the same as:
Bar of int * global_ string
Locality mismatch at argument position 2 : The second is global and the first is not.
Modalities mismatch at argument position 2 : The second is global_ and the first is not.
|}]
Expand All @@ -2531,7 +2531,7 @@ Error: Signature mismatch:
Bar of int * global_ string
is not the same as:
Bar of int * string
Locality mismatch at argument position 2 : The first is global and the second is not.
Modalities mismatch at argument position 2 : The first is global_ and the second is not.
|}]
(* global_ binds closer than star *)
Expand Down
2 changes: 1 addition & 1 deletion ocaml/typing/ctype.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3129,7 +3129,7 @@ and mcomp_record_description type_pairs env =
mcomp type_pairs env l1.ld_type l2.ld_type;
if Ident.name l1.ld_id = Ident.name l2.ld_id &&
l1.ld_mutable = l2.ld_mutable &&
l1.ld_global = l2.ld_global
l1.ld_modalities = l2.ld_modalities
then iter xs ys
else raise Incompatible
| [], [] -> ()
Expand Down
2 changes: 1 addition & 1 deletion ocaml/typing/ctype.mli
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ type existential_treatment =

val instance_constructor: existential_treatment ->
constructor_description ->
(type_expr * Global_flag.t) list * type_expr * type_expr list
(type_expr * Modality.Vector.t) list * type_expr * type_expr list
(* Same, for a constructor. Also returns existentials. *)
val instance_parameterized_type:
?keep_names:bool ->
Expand Down
6 changes: 3 additions & 3 deletions ocaml/typing/datarepr.ml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ let constructor_args ~current_unit priv cd_args cd_res path rep =
}
in
existentials,
[ newgenconstr path type_params, Global_flag.Unrestricted ],
[ newgenconstr path type_params, Modality.Vector.id ],
Some tdecl

let constructor_descrs ~current_unit ty_path decl cstrs rep =
Expand Down Expand Up @@ -199,7 +199,7 @@ let none =

let dummy_label =
{ lbl_name = ""; lbl_res = none; lbl_arg = none;
lbl_mut = Immutable; lbl_global = Unrestricted;
lbl_mut = Immutable; lbl_modalities = Modality.Vector.id;
lbl_jkind = Jkind.any ~why:Dummy_jkind;
lbl_num = -1; lbl_pos = -1; lbl_all = [||];
lbl_repres = Record_unboxed;
Expand All @@ -220,7 +220,7 @@ let label_descrs ty_res lbls repres priv =
lbl_res = ty_res;
lbl_arg = l.ld_type;
lbl_mut = l.ld_mutable;
lbl_global = l.ld_global;
lbl_modalities = l.ld_modalities;
lbl_jkind = l.ld_jkind;
lbl_pos = if is_void then lbl_pos_void else pos;
lbl_num = num;
Expand Down
10 changes: 5 additions & 5 deletions ocaml/typing/predef.ml
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ let build_initial_env add_type add_extension empty_env =
add_extension id
{ ext_type_path = path_exn;
ext_type_params = [];
ext_args = Cstr_tuple (List.map (fun x -> (x, Global_flag.Unrestricted)) args);
ext_args = Cstr_tuple (List.map (fun x -> (x, Modality.Vector.id)) args);
ext_arg_jkinds = jkinds;
ext_constant = args = [];
ext_ret_type = None;
Expand Down Expand Up @@ -322,8 +322,8 @@ let build_initial_env add_type add_extension empty_env =
~separability:Separability.Ind
~kind:(fun tvar ->
variant [cstr ident_nil [];
cstr ident_cons [tvar, Unrestricted;
type_list tvar, Unrestricted]]
cstr ident_cons [tvar, Modality.Vector.id;
type_list tvar, Modality.Vector.id]]
[| [| |]; [| list_argument_jkind;
Jkind.value ~why:Boxed_variant |] |] )
~jkind:(Jkind.value ~why:Boxed_variant)
Expand All @@ -332,7 +332,7 @@ let build_initial_env add_type add_extension empty_env =
~variance:Variance.covariant
~separability:Separability.Ind
~kind:(fun tvar ->
variant [cstr ident_none []; cstr ident_some [tvar, Unrestricted]]
variant [cstr ident_none []; cstr ident_some [tvar, Modality.Vector.id]]
[| [| |]; [| option_argument_jkind |] |])
~jkind:(Jkind.value ~why:Boxed_variant)
|> add_type ident_lexing_position
Expand All @@ -342,7 +342,7 @@ let build_initial_env add_type add_extension empty_env =
{
ld_id=id;
ld_mutable=Immutable;
ld_global=Unrestricted;
ld_modalities=Modality.Vector.id;
ld_type=field_type;
ld_jkind=jkind;
ld_loc=Location.none;
Expand Down
2 changes: 1 addition & 1 deletion ocaml/typing/subst.ml
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ let label_declaration copy_scope s l =
{
ld_id = l.ld_id;
ld_mutable = l.ld_mutable;
ld_global = l.ld_global;
ld_modalities = l.ld_modalities;
ld_jkind = apply_prepare_jkind s l.ld_jkind l.ld_loc;
ld_type = typexp copy_scope s l.ld_loc l.ld_type;
ld_loc = loc s l.ld_loc;
Expand Down
Loading

0 comments on commit 64dbf60

Please sign in to comment.