Skip to content

Support for mod syntax #2676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 43 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
44c0472
Promote tests that remove redundant kind from error message history
liam923 Jul 18, 2024
a4a9a38
Rename Primitive to Builtin
liam923 Aug 13, 2024
2c3452d
Remove Const.Sort and Const.Layout aliases
liam923 Jul 5, 2024
1af7cc4
Remove pointless const definition
liam923 Jul 5, 2024
b9e1091
Remove stale crs about eg layout_float64
liam923 Jul 5, 2024
1d9fc67
Remove legacy layout usage in printing
liam923 Jul 5, 2024
3987dcf
Remove legacy layout usage in extension universe check
liam923 Jul 17, 2024
b7e4c77
Rename has_imported_history to is_imported
liam923 Jul 5, 2024
aec5ec6
Remove Legacy module
liam923 Jul 17, 2024
086b8b3
Remove unused builtins
liam923 Aug 13, 2024
5784a6f
Move const_of_user_written_annotation into Const module
liam923 Jul 17, 2024
feff6b6
Update comment
liam923 Jul 18, 2024
1a6ed90
Remove redundant layout definition
liam923 Jul 18, 2024
3989465
Remove unnecessary layout aliases
liam923 Jul 18, 2024
c7f02ba
Document jkind printing
liam923 Jul 18, 2024
011a88e
Rename ModeParser to Mode_parser
liam923 Jul 18, 2024
189dc56
Fix cr formatting
liam923 Aug 5, 2024
5b83c9e
Remove stale cr
liam923 Jul 18, 2024
edf7a7f
Remove incorrect CRs
liam923 Jul 18, 2024
6ddef62
Replace any with abstract layout in error message
liam923 Jul 18, 2024
f4a3b3b
Assert layout is value in value_kind_of_value_jkind
liam923 Jul 18, 2024
8663a90
Don't print : value
liam923 Jul 18, 2024
373cfd6
Add CRs to remove annotation
liam923 Jul 19, 2024
a71daaa
Improve debug printing
liam923 Jul 22, 2024
3cb1cd9
Share parsing logic between modes and jkinds
liam923 Aug 5, 2024
752c511
Simplify parsing
liam923 Aug 5, 2024
fda818a
Add tests
liam923 Jul 25, 2024
15b8e26
Create test for not calling caml_modify
liam923 Jul 25, 2024
26db06e
Reformat files
liam923 Jul 25, 2024
bcc4e5b
Add comments to caml_modify test
liam923 Aug 13, 2024
7771d4c
Rename external_record to internal_record
liam923 Aug 13, 2024
b5be0a7
Hide external_variant's immediacy
liam923 Aug 13, 2024
d90dd2a
Add inlining test for caml_modify
liam923 Aug 13, 2024
164538f
Add copyright header
liam923 Aug 13, 2024
839bbd8
Clean up typemodifier
liam923 Aug 13, 2024
e1c3101
Fix prining typo
liam923 Aug 13, 2024
64f5459
Add CR to Builtin
liam923 Aug 13, 2024
c5cd778
Stop calling crossing of nullability mode-crossing
liam923 Aug 13, 2024
befb479
Improve warning 211 message
liam923 Aug 13, 2024
f2ca79f
Restore PRs about incorrect error messages
liam923 Aug 13, 2024
24a3a15
Cleanup typemodifier more
liam923 Aug 13, 2024
6c84274
Fix bug in required maturity level for modes
liam923 Aug 13, 2024
83248db
Fix floatarray kind and promote tests
liam923 Aug 14, 2024
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
4 changes: 2 additions & 2 deletions chamelon/compat.jst.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ open Typedtree
open Types
open Mode

let dummy_jkind = Jkind.Primitive.value ~why:(Unknown "dummy_layout")
let dummy_jkind = Jkind.Builtin.value ~why:(Unknown "dummy_layout")
let dummy_value_mode = Value.disallow_right Value.legacy

let dummy_alloc_mode =
Expand Down Expand Up @@ -102,7 +102,7 @@ let texp_function_cases_identifier_defaults =
last_arg_exp_extra = None;
last_arg_attributes = [];
env = Env.empty;
ret_type = Ctype.newvar (Jkind.Primitive.any ~why:Dummy_jkind);
ret_type = Ctype.newvar (Jkind.Builtin.any ~why:Dummy_jkind);
}

let texp_function_param_identifier_defaults =
Expand Down
2 changes: 1 addition & 1 deletion native_toplevel/opttopdirs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ let match_printer_type ppf desc typename =
raise Exit
in
Ctype.with_local_level ~post:Ctype.generalize (fun () ->
let ty_arg = Ctype.newvar (Jkind.Primitive.value ~why:Debug_printer_argument) in
let ty_arg = Ctype.newvar (Jkind.Builtin.value ~why:Debug_printer_argument) in
Ctype.unify !toplevel_env
(Ctype.newconstr printer_type [ty_arg])
(Ctype.instance desc.val_type);
Expand Down
2 changes: 1 addition & 1 deletion ocaml/boot/menhir/parser.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41625,7 +41625,7 @@ module Tables = struct
>>>>>>> origin/main
(
let {txt; loc} = _1 in
Jane_syntax.Jkind.(Primitive_layout_or_abbreviation
Jane_syntax.Jkind.(Builtin_layout_or_abbreviation
(Const.mk txt loc))
)
<<<<<<< HEAD
Expand Down
2 changes: 1 addition & 1 deletion ocaml/debugger/loadprinter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ let eval_value_path env path =

let match_printer_type desc make_printer_type =
Ctype.with_local_level ~post:Ctype.generalize begin fun () ->
let ty_arg = Ctype.newvar (Jkind.Primitive.value ~why:Debug_printer_argument) in
let ty_arg = Ctype.newvar (Jkind.Builtin.value ~why:Debug_printer_argument) in
Ctype.unify (Lazy.force Env.initial)
(make_printer_type ty_arg)
(Ctype.instance desc.val_type);
Expand Down
2 changes: 1 addition & 1 deletion ocaml/debugger4/loadprinter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ let eval_value_path env path =

let match_printer_type desc make_printer_type =
Ctype.with_local_level ~post:Ctype.generalize begin fun () ->
let ty_arg = Ctype.newvar Jkind.Primitive.(value ~why:Debug_printer_argument) in
let ty_arg = Ctype.newvar Jkind.Builtin.(value ~why:Debug_printer_argument) in
Ctype.unify (Lazy.force Env.initial)
(make_printer_type ty_arg)
(Ctype.instance desc.val_type);
Expand Down
3 changes: 2 additions & 1 deletion ocaml/dune
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
typedtree printtyped ctype printtyp includeclass mtype envaux includecore
tast_iterator tast_mapper signature_group cmt_format cms_format untypeast
includemod includemod_errorprinter
typemode typetexp patterns printpat parmatch stypes typedecl typeopt
typemode typemodifier typetexp patterns printpat parmatch stypes typedecl typeopt
value_rec_check typecore solver_intf solver mode_intf mode uniqueness_analysis
typeclass typemod typedecl_variance typedecl_properties
typedecl_separability cmt2annot
Expand Down Expand Up @@ -334,6 +334,7 @@
(untypeast.mli as compiler-libs/untypeast.mli)
(includemod.mli as compiler-libs/includemod.mli)
(typemode.mli as compiler-libs/typemode.mli)
(typemodifier.mli as compiler-libs/typemodifier.mli)
(typetexp.mli as compiler-libs/typetexp.mli)
(printpat.mli as compiler-libs/printpat.mli)
(parmatch.mli as compiler-libs/parmatch.mli)
Expand Down
2 changes: 1 addition & 1 deletion ocaml/lambda/translcore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ and transl_exp0 ~in_new_scope ~scopes sort e =
(* CR layouts v3: here we allow [value_or_null] because this check
happens too late for the typecheker to infer [non_null]. Test that
nothing breaks once we have null pointers. *)
(Jkind.Primitive.value_or_null ~why:Probe)
(Jkind.Builtin.value_or_null ~why:Probe)
with
| Ok _ -> ()
| Error _ -> raise (Error (e.exp_loc, Bad_probe_layout id))
Expand Down
2 changes: 1 addition & 1 deletion ocaml/lambda/translmod.ml
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ let init_shape id modl =
Tarrow(_,ty_arg,_,_) -> begin
(* CR layouts: We should allow any representable layout here. It
will require reworking [camlinternalMod.init_mod]. *)
let jkind = Jkind.Primitive.value ~why:Recmod_fun_arg in
let jkind = Jkind.Builtin.value ~why:Recmod_fun_arg in
let ty_arg = Ctype.correct_levels ty_arg in
match Ctype.check_type_jkind env ty_arg jkind with
| Ok _ -> const_int 0 (* camlinternalMod.Function *)
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 @@ -493,7 +493,7 @@ module Analyser =
{ Typedtree.ld_id; ld_mutable; ld_type; ld_loc; ld_attributes } =
get_field env comments @@
{Types.ld_id; ld_mutable; ld_modalities = Mode.Modality.Value.Const.id;
ld_jkind=Jkind.Primitive.any ~why:Dummy_jkind (* ignored *);
ld_jkind=Jkind.Builtin.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
let open Typedtree in
Expand Down
5 changes: 5 additions & 0 deletions ocaml/otherlibs/dynlink/dune
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
zero_alloc
types
oprint
typemodifier
jkind
value_rec_types
btype
Expand Down Expand Up @@ -195,6 +196,7 @@
(copy_files ../../typing/jkind.ml)
(copy_files ../../typing/jkind_intf.ml)
(copy_files ../../typing/jkind_types.ml)
(copy_files ../../typing/typemodifier.ml)
(copy_files ../../typing/oprint.ml)
(copy_files ../../typing/primitive.ml)
(copy_files ../../typing/shape.ml)
Expand Down Expand Up @@ -266,6 +268,7 @@
(copy_files ../../typing/jkind.mli)
(copy_files ../../typing/jkind_intf.mli)
(copy_files ../../typing/jkind_types.mli)
(copy_files ../../typing/typemodifier.mli)
(copy_files ../../typing/oprint.mli)
(copy_files ../../typing/primitive.mli)
(copy_files ../../typing/shape.mli)
Expand Down Expand Up @@ -390,6 +393,7 @@
.dynlink_compilerlibs.objs/byte/dynlink_compilerlibs__Attr_helper.cmo
.dynlink_compilerlibs.objs/byte/dynlink_compilerlibs__Primitive.cmo
.dynlink_compilerlibs.objs/byte/dynlink_compilerlibs__Oprint.cmo
.dynlink_compilerlibs.objs/byte/dynlink_compilerlibs__Typemodifier.cmo
.dynlink_compilerlibs.objs/byte/dynlink_compilerlibs__Jkind.cmo
.dynlink_compilerlibs.objs/byte/dynlink_compilerlibs__Btype.cmo
.dynlink_compilerlibs.objs/byte/dynlink_compilerlibs__Subst.cmo
Expand Down Expand Up @@ -475,6 +479,7 @@
.dynlink_compilerlibs.objs/native/dynlink_compilerlibs__Attr_helper.cmx
.dynlink_compilerlibs.objs/native/dynlink_compilerlibs__Primitive.cmx
.dynlink_compilerlibs.objs/native/dynlink_compilerlibs__Oprint.cmx
.dynlink_compilerlibs.objs/native/dynlink_compilerlibs__Typemodifier.cmx
.dynlink_compilerlibs.objs/native/dynlink_compilerlibs__Jkind.cmx
.dynlink_compilerlibs.objs/native/dynlink_compilerlibs__Btype.cmx
.dynlink_compilerlibs.objs/native/dynlink_compilerlibs__Subst.cmx
Expand Down
10 changes: 5 additions & 5 deletions ocaml/testsuite/tests/typing-immediate/immediate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ Line 2, characters 2-31:
2 | type t = string [@@immediate]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: The kind of type string is immutable_data
because it is the primitive immutable_data type string.
because it is the primitive type string.
But the kind of type string must be a subkind of immediate
because of the definition of t at line 2, characters 2-31.
|}];;
Expand Down Expand Up @@ -214,7 +214,7 @@ Error: Signature mismatch:
is not included in
type t : immediate
The kind of the first is immutable_data
because it is the primitive immutable_data type string.
because it is the primitive type string.
But the kind of the first must be a subkind of immediate
because of the definition of t at line 1, characters 15-35.
|}];;
Expand All @@ -232,7 +232,7 @@ Error: Signature mismatch:
is not included in
type t : immediate
The kind of the first is immutable_data
because it is the primitive immutable_data type string.
because it is the primitive type string.
But the kind of the first must be a subkind of immediate
because of the definition of t at line 1, characters 20-40.
|}];;
Expand All @@ -249,7 +249,7 @@ Error: Modules do not match: sig type t = string end is not included in
is not included in
type t : immediate
The kind of the first is immutable_data
because it is the primitive immutable_data type string.
because it is the primitive type string.
But the kind of the first must be a subkind of immediate
because of the definition of t at line 1, characters 20-40.
|}];;
Expand All @@ -264,7 +264,7 @@ Line 2, characters 2-26:
2 | type t = s [@@immediate]
^^^^^^^^^^^^^^^^^^^^^^^^
Error: The kind of type s is immutable_data
because it is the primitive immutable_data type string.
because it is the primitive type string.
But the kind of type s must be a subkind of immediate
because of the definition of t at line 2, characters 2-26.
|}];;
Expand Down
8 changes: 4 additions & 4 deletions ocaml/testsuite/tests/typing-layouts-arrays/basics.ml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Line 1, characters 27-28:
Error: This expression has type float# array
but an expression was expected of type 'a array
The layout of float# is float64
because it is the primitive float64 type float#.
because it is the primitive type float#.
But the layout of float# must be a sublayout of value
because of layout requirements from an imported definition.
|}];;
Expand All @@ -102,7 +102,7 @@ Line 1, characters 40-41:
Error: This expression has type float# array
but an expression was expected of type 'a array
The layout of float# is float64
because it is the primitive float64 type float#.
because it is the primitive type float#.
But the layout of float# must be a sublayout of value
because of layout requirements from an imported definition.
|}];;
Expand Down Expand Up @@ -255,7 +255,7 @@ Line 11, characters 79-82:
Error: This expression has type int64# but an expression was expected of type
('a : bits32)
The layout of int64# is bits64
because it is the primitive bits64 type int64#.
because it is the primitive type int64#.
But the layout of int64# must be a sublayout of bits32
because of the definition of get_third at lines 4-7, characters 16-23.
|}]
Expand All @@ -280,7 +280,7 @@ Line 9, characters 24-35:
Error: This expression has type ('a : float64)
but an expression was expected of type int32#
The layout of int32# is bits32
because it is the primitive bits32 type int32#.
because it is the primitive type int32#.
But the layout of int32# must be a sublayout of float64
because of the definition of arr at line 6, characters 12-16.
|}]
Expand Down
8 changes: 4 additions & 4 deletions ocaml/testsuite/tests/typing-layouts-arrays/basics_alpha.ml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Line 1, characters 27-28:
Error: This expression has type float# array
but an expression was expected of type 'a array
The layout of float# is float64
because it is the primitive float64 type float#.
because it is the primitive type float#.
But the layout of float# must be a sublayout of value
because of layout requirements from an imported definition.
|}];;
Expand All @@ -99,7 +99,7 @@ Line 1, characters 40-41:
Error: This expression has type float# array
but an expression was expected of type 'a array
The layout of float# is float64
because it is the primitive float64 type float#.
because it is the primitive type float#.
But the layout of float# must be a sublayout of value
because of layout requirements from an imported definition.
|}];;
Expand Down Expand Up @@ -253,7 +253,7 @@ Line 11, characters 79-82:
Error: This expression has type int64# but an expression was expected of type
('a : bits32)
The layout of int64# is bits64
because it is the primitive bits64 type int64#.
because it is the primitive type int64#.
But the layout of int64# must be a sublayout of bits32
because of the definition of get_third at lines 4-7, characters 16-23.
|}]
Expand All @@ -278,7 +278,7 @@ Line 9, characters 24-35:
Error: This expression has type ('a : float64)
but an expression was expected of type int32#
The layout of int32# is bits32
because it is the primitive bits32 type int32#.
because it is the primitive type int32#.
But the layout of int32# must be a sublayout of float64
because of the definition of arr at line 6, characters 12-16.
|}]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Line 25, characters 13-29:
Error: This expression has type Float_u.t = float#
but an expression was expected of type ('a : value)
The layout of Float_u.t is float64
because it is the primitive float64 type float#.
because it is the primitive type float#.
But the layout of Float_u.t must be a sublayout of value
because it's the element type of array comprehension.
|}];;
14 changes: 7 additions & 7 deletions ocaml/testsuite/tests/typing-layouts-bits32/basics.ml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ Line 1, characters 24-25:
Error: This expression has type int32# but an expression was expected of type
('a : value)
The layout of int32# is bits32
because it is the primitive bits32 type int32#.
because it is the primitive type int32#.
But the layout of int32# must be a sublayout of value
because it's the type of a tuple element.
|}];;
Expand All @@ -166,7 +166,7 @@ Line 1, characters 18-24:
^^^^^^
Error: Tuple element types must have layout value.
The layout of int32# is bits32
because it is the primitive bits32 type int32#.
because it is the primitive type int32#.
But the layout of int32# must be a sublayout of value
because it's the type of a tuple element.
|}];;
Expand Down Expand Up @@ -306,7 +306,7 @@ Line 1, characters 31-37:
^^^^^^
Error: This type signature for x is not a value type.
The layout of type int32# is bits32
because it is the primitive bits32 type int32#.
because it is the primitive type int32#.
But the layout of type int32# must be a sublayout of value
because it's the type of something stored in a module structure.
|}];;
Expand Down Expand Up @@ -348,7 +348,7 @@ Line 1, characters 27-28:
Error: This expression has type int32# but an expression was expected of type
('a : value)
The layout of int32# is bits32
because it is the primitive bits32 type int32#.
because it is the primitive type int32#.
But the layout of int32# must be a sublayout of value
because it's the type of the field of a polymorphic variant.
|}];;
Expand Down Expand Up @@ -426,7 +426,7 @@ Line 1, characters 20-36:
Error: This expression has type int32# but an expression was expected of type
('a : value)
The layout of int32# is bits32
because it is the primitive bits32 type int32#.
because it is the primitive type int32#.
But the layout of int32# must be a sublayout of value
because of the definition of id_value at line 5, characters 13-18.
|}];;
Expand Down Expand Up @@ -631,7 +631,7 @@ Line 1, characters 26-43:
^^^^^^^^^^^^^^^^^
Error: The method x has type int32# but is expected to have type ('a : value)
The layout of int32# is bits32
because it is the primitive bits32 type int32#.
because it is the primitive type int32#.
But the layout of int32# must be a sublayout of value
because it's the type of an object field.
|}];;
Expand All @@ -643,7 +643,7 @@ Line 1, characters 26-40:
^^^^^^^^^^^^^^
Error: Variables bound in a class must have layout value.
The layout of x is bits32
because it is the primitive bits32 type int32#.
because it is the primitive type int32#.
But the layout of x must be a sublayout of value
because it's the type of an instance variable.
|}];;
Expand Down
14 changes: 7 additions & 7 deletions ocaml/testsuite/tests/typing-layouts-bits32/basics_alpha.ml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ Line 1, characters 24-25:
Error: This expression has type int32# but an expression was expected of type
('a : value_or_null)
The layout of int32# is bits32
because it is the primitive bits32 type int32#.
because it is the primitive type int32#.
But the layout of int32# must be a sublayout of value
because it's the type of a tuple element.
|}];;
Expand All @@ -164,7 +164,7 @@ Line 1, characters 18-24:
^^^^^^
Error: Tuple element types must have layout value.
The layout of int32# is bits32
because it is the primitive bits32 type int32#.
because it is the primitive type int32#.
But the layout of int32# must be a sublayout of value
because it's the type of a tuple element.
|}];;
Expand Down Expand Up @@ -295,7 +295,7 @@ Line 1, characters 31-37:
^^^^^^
Error: This type signature for x is not a value type.
The layout of type int32# is bits32
because it is the primitive bits32 type int32#.
because it is the primitive type int32#.
But the layout of type int32# must be a sublayout of value
because it's the type of something stored in a module structure.
|}];;
Expand Down Expand Up @@ -337,7 +337,7 @@ Line 1, characters 27-28:
Error: This expression has type int32# but an expression was expected of type
('a : value_or_null)
The layout of int32# is bits32
because it is the primitive bits32 type int32#.
because it is the primitive type int32#.
But the layout of int32# must be a sublayout of value
because it's the type of the field of a polymorphic variant.
|}];;
Expand Down Expand Up @@ -415,7 +415,7 @@ Line 1, characters 20-36:
Error: This expression has type int32# but an expression was expected of type
('a : value_or_null)
The layout of int32# is bits32
because it is the primitive bits32 type int32#.
because it is the primitive type int32#.
But the layout of int32# must be a sublayout of value
because of the definition of id_value at line 5, characters 13-18.
|}];;
Expand Down Expand Up @@ -620,7 +620,7 @@ Line 1, characters 26-43:
^^^^^^^^^^^^^^^^^
Error: The method x has type int32# but is expected to have type ('a : value)
The layout of int32# is bits32
because it is the primitive bits32 type int32#.
because it is the primitive type int32#.
But the layout of int32# must be a sublayout of value
because it's the type of an object field.
|}];;
Expand All @@ -632,7 +632,7 @@ Line 1, characters 26-40:
^^^^^^^^^^^^^^
Error: Variables bound in a class must have layout value.
The layout of x is bits32
because it is the primitive bits32 type int32#.
because it is the primitive type int32#.
But the layout of x must be a sublayout of value
because it's the type of an instance variable.
|}];;
Expand Down
Loading
Loading