Skip to content

Commit 63a6528

Browse files
authored
Merge 5.2.0minus-29 (#212)
* Import ocaml sources for oxcaml/oxcaml@977afdd4ebd * Automatic merges * Commit conflicts * Resolve trivial conflicts * Resolve trivial type errors * Fix remaining errors * Bump magic numbers * Promote tests and fix some issues * Bump bootstrap compiler for flambda on github * Fix formatting * Import ocaml sources for oxcaml/oxcaml@0a1dc8de0264 * Automatic merges * Fixup jkind printing * Add flags * Import ocaml sources for oxcaml/oxcaml@4ac226a124a5 * Commit conflicts * Resolve conflicts * Update version name * Promote tests
1 parent 0ae2594 commit 63a6528

File tree

195 files changed

+13157
-9887
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

195 files changed

+13157
-9887
lines changed

.github/workflows/flambda-backend.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ jobs:
7272
if: steps.cache.outputs.cache-hit != 'true'
7373
working-directory: flambda-backend
7474
run: |
75-
opam switch create 4.14.0 --yes
76-
opam switch link 4.14.0 --yes
77-
opam install --yes dune.3.19.1 menhir.20231231
75+
opam switch create 5.4.0 --yes
76+
opam switch link 5.4.0 --yes
77+
opam install --yes dune.3.20.2 menhir.20231231
7878
7979
- name: Configure, build, and install flambda-backend
8080
if: steps.cache.outputs.cache-hit != 'true'

src/analysis/completion.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ let classify_node = function
136136
| Open_declaration _ -> `Module
137137
| Include_declaration _ -> `Module
138138
| Include_description _ -> `Module
139-
| Mode _ | Modality _ ->
139+
| Mode _ | Modality _ | Mod_bound _ ->
140140
(* CR-someday: Have proper completion for modes and modalities *)
141141
`Expression
142142
| Jkind_annotation _ ->

src/analysis/construct.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,11 @@ module Gen = struct
223223
| Mty_signature sig_items ->
224224
let env = Env.add_signature sig_items env in
225225
Mod.structure @@ structure env sig_items
226-
| Mty_functor (param, out) ->
226+
| Mty_functor (param, out, _) ->
227227
let param =
228228
match param with
229229
| Unit -> Parsetree.Unit
230-
| Named (id, in_) ->
230+
| Named (id, in_, _) ->
231231
Parsetree.Named
232232
( Location.mknoloc (Option.map ~f:Ident.name id),
233233
Ptyp_of_type.module_type in_,
@@ -524,7 +524,7 @@ module Gen = struct
524524
val_loc = Location.none;
525525
val_attributes = [];
526526
val_zero_alloc = Zero_alloc.default;
527-
val_modalities = Mode.Modality.id;
527+
val_modalities = Mode.Modality.(of_const Const.id);
528528
val_uid = Uid.mk ~current_unit:(Env.get_unit_name ())
529529
}
530530
in

src/analysis/context.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ let inspect_expression ~cursor ~lid e : t =
122122
Constructor (cd, lid_loc.loc)
123123
else Module_path
124124
else Module_path
125-
| Texp_ident (p, lid_loc, _, _, _) ->
125+
| Texp_ident (p, lid_loc, _, _, _, _) ->
126126
let name = Path.last p in
127127
log ~title:"inspect_context" "name is: [%s]" name;
128128
if name = "*type-error*" then

src/analysis/destruct.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ let rec get_every_pattern loc = function
308308
(* We are still in the same branch, going up. *)
309309
get_every_pattern loc parents
310310
| Expression
311-
{ exp_desc = Typedtree.Texp_ident (Path.Pident id, _, _, _, _); _ }
311+
{ exp_desc = Typedtree.Texp_ident (Path.Pident id, _, _, _, _, _); _ }
312312
when Ident.name id = "*type-error*" -> raise Ill_typed
313313
| Expression { exp_desc = Typedtree.Texp_function { params; _ }; _ } ->
314314
begin

src/analysis/inlay_hints.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ let pattern_has_constraint (type a) (pattern : a Typedtree.general_pattern) =
1313
| Typedtree.Tpat_constraint _ -> true
1414
| Typedtree.Tpat_type (_, _)
1515
| Typedtree.Tpat_open (_, _, _)
16-
| Typedtree.Tpat_unpack -> false)
16+
| Typedtree.Tpat_unpack | Typedtree.Tpat_inspected_type _ -> false)
1717
pattern.pat_extra
1818

1919
let structure_iterator hint_let_binding hint_pattern_binding

src/analysis/kind_enclosing.ml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ module Kind_info = struct
1515
kind
1616
in
1717
Printtyp.wrap_printing_env ~verbosity env (fun () ->
18-
let format_jkind =
19-
match Mconfig.Verbosity.to_int ~for_smart:0 verbosity > 0 with
20-
| false -> Jkind.format
21-
| true -> Jkind.format_expanded
18+
let verbosity : Jkind.Format_verbosity.t =
19+
match Mconfig.Verbosity.to_int ~for_smart:0 verbosity with
20+
| 0 -> Not_verbose
21+
| 1 -> Expanded
22+
| _ -> Expanded_with_all_mod_bounds
2223
in
23-
Format.asprintf "%a" format_jkind kind)
24+
Format.asprintf "%a" (Jkind.format_verbose ~verbosity) kind)
2425
end
2526

2627
let loc_contains_cursor (loc : Location.t) ~cursor =

src/analysis/ptyp_of_type.ml

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ let rec module_type =
1717
Ast_helper.Mty.ident (Location.mknoloc (Untypeast.lident_of_path path))
1818
| Mty_alias path ->
1919
Ast_helper.Mty.alias (Location.mknoloc (Untypeast.lident_of_path path))
20-
| Mty_functor (param, type_out) ->
20+
| Mty_functor (param, type_out, ret_mode) ->
2121
let param =
2222
match param with
2323
| Unit -> Parsetree.Unit
24-
| Named (id, type_in) ->
24+
| Named (id, type_in, param_mode) ->
2525
Parsetree.Named
2626
( Location.mknoloc (Option.map ~f:Ident.name id),
2727
module_type type_in,
28-
[] )
28+
modes param_mode )
2929
in
3030
let out = module_type type_out in
31-
Mty.functor_ param out
31+
Mty.functor_ ~ret_mode:(modes ret_mode) param out
3232
| Mty_strengthen (mty, path, _aliasability) ->
3333
Mty.strengthen ~loc:Location.none (module_type mty)
3434
(Location.mknoloc (Untypeast.lident_of_path path))
@@ -55,16 +55,8 @@ and core_type type_expr =
5555
| Labelled l -> (Labelled l, core_type type_expr)
5656
| Optional l -> (Optional l, core_type type_expr)
5757
in
58-
let snap = Btype.snapshot () in
59-
let arg_modes =
60-
Typemode.untransl_mode_annots
61-
@@ Mode.Alloc.(Const.diff (zap_to_legacy arg_alloc_mode) Const.legacy)
62-
in
63-
let ret_modes =
64-
Typemode.untransl_mode_annots
65-
@@ Mode.Alloc.(Const.diff (zap_to_legacy ret_alloc_mode) Const.legacy)
66-
in
67-
Btype.backtrack snap;
58+
let arg_modes = modes arg_alloc_mode in
59+
let ret_modes = modes ret_alloc_mode in
6860
Typ.arrow label type_expr (core_type type_expr_out) arg_modes ret_modes
6961
| Ttuple type_exprs ->
7062
let labeled_type_exprs =
@@ -158,8 +150,17 @@ and extension_constructor id { ext_args; ext_ret_type; ext_attributes; _ } =
158150
?res:(Option.map ~f:core_type ext_ret_type)
159151
(var_of_id id)
160152

161-
and const_modalities modalities =
162-
Typemode.untransl_modalities Immutable modalities
153+
and modes mode =
154+
let snapshot = Btype.snapshot () in
155+
let mode = Mode.Alloc.zap_to_legacy mode in
156+
Btype.backtrack snapshot;
157+
Printtyp.tree_of_modes mode
158+
|> List.map ~f:(fun mode -> Location.mknoloc (Parsetree.Mode mode))
159+
160+
and const_modalities ~mut modality =
161+
Printtyp.tree_of_modalities mut modality
162+
|> List.map ~f:(fun modality ->
163+
Location.mknoloc (Parsetree.Modality modality))
163164

164165
and value_description id
165166
{ val_type; val_kind = _; val_loc; val_attributes; val_modalities; _ } =
@@ -171,14 +172,14 @@ and value_description id
171172
pval_type = type_;
172173
pval_prim = [];
173174
pval_attributes = val_attributes;
174-
pval_modalities = const_modalities modalities;
175+
pval_modalities = const_modalities ~mut:Immutable modalities;
175176
pval_loc = val_loc
176177
}
177178

178179
and constructor_argument { ca_type; ca_loc; ca_modalities; ca_sort = _ } =
179180
{ Parsetree.pca_type = core_type ca_type;
180181
pca_loc = ca_loc;
181-
pca_modalities = const_modalities ca_modalities
182+
pca_modalities = const_modalities ~mut:Immutable ca_modalities
182183
}
183184

184185
and label_declaration
@@ -188,7 +189,7 @@ and label_declaration
188189
(match ld_mutable with
189190
| Mutable _ -> Mutable
190191
| Immutable -> Immutable)
191-
~modalities:(Typemode.untransl_modalities ld_mutable ld_modalities)
192+
~modalities:(const_modalities ~mut:ld_mutable ld_modalities)
192193
(var_of_id ld_id) (core_type ld_type)
193194

194195
and constructor_arguments = function

src/analysis/signature_help.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ let extract_ident (exp_desc : Typedtree.expression_desc) =
2727
| Lapply (p1, p2) -> Format.fprintf ppf "%a(%a)" longident p1 longident p2
2828
in
2929
match exp_desc with
30-
| Texp_ident (_, { txt = li; _ }, _, _, _) ->
30+
| Texp_ident (_, { txt = li; _ }, _, _, _, _) ->
3131
let ppf, to_string = Format.to_string () in
3232
longident ppf li;
3333
Some (to_string ())

src/analysis/syntax_doc.ml

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,8 @@ let get_mod_bound_doc mod_bound =
200200
}
201201
: syntax_info)
202202

203-
let get_mode_doc mode =
203+
let get_mode_doc (Atom (axis, mode) : Mode.Alloc.atom) =
204204
let open Option.Infix in
205-
let* (P (axis, mode)) =
206-
match Typemode.Mode_axis_pair.of_string mode with
207-
| exception Not_found -> None
208-
| res -> Some res
209-
in
210205
let* description =
211206
match (axis, mode) with
212207
| Comonadic Areality, Local ->
@@ -291,27 +286,23 @@ let get_mode_doc mode =
291286
{ name = "Mode"; description; documentation = doc_url; level = Advanced }
292287
: syntax_info)
293288

294-
let get_modality_doc modality =
295-
let open Option.Infix in
296-
let* (P (axis, _)) =
297-
match Typemode.Modality_axis_pair.of_string modality with
298-
| exception Not_found -> None
299-
| res -> Some res
300-
in
289+
let get_modality_doc (Atom (axis, modality) : Mode.Modality.atom) =
301290
let description =
302291
(* CR-someday: Detect the context that the modality is within to make this message
303292
more detailed. Ex: "This field is always stronger than _, even if the record has a
304293
weaker mode." *)
305294
match axis with
306295
| Comonadic _ ->
307296
Format.asprintf
308-
"The annotated value's mode is always at least as strong as `%s`, even \
297+
"The annotated value's mode is always at least as strong as `%a`, even \
309298
if its container's mode is weaker."
299+
(Mode.Modality.Per_axis.print axis)
310300
modality
311301
| Monadic _ ->
312302
Format.asprintf
313-
"The annotated value's mode is always at least as weak as `%s`, even \
303+
"The annotated value's mode is always at least as weak as `%a`, even \
314304
if its container's mode is a stronger."
305+
(Mode.Modality.Per_axis.print axis)
315306
modality
316307
in
317308
(Some
@@ -644,17 +635,15 @@ let get_oxcaml_syntax_doc cursor_loc nodes : syntax_info =
644635
in
645636
match nodes with
646637
(* Modes and modalities *)
647-
| Mode { txt = Mode mode; _ } :: ancestors -> (
648-
match ancestors with
649-
| Jkind_annotation _ :: _ -> get_mod_bound_doc mode
650-
| _ -> get_mode_doc mode)
651-
| Modality { txt = Modality modality; _ } :: ancestors -> (
638+
| Mode { txt = mode; _ } :: _ -> get_mode_doc mode
639+
| Modality { txt = modality; _ } :: ancestors -> (
652640
match ancestors with
653641
| Jkind_annotation _ :: _ ->
654642
(* CR-someday: Provide separate documatation for modalities within a jkind *)
655643
get_modality_doc modality
656644
| _ -> get_modality_doc modality)
657645
(* Jkinds *)
646+
| Mod_bound { txt = Mode mod_bound; _ } :: _ -> get_mod_bound_doc mod_bound
658647
| Jkind_annotation { pjkind_desc = Pjk_abbreviation abbrev; _ } :: _ ->
659648
get_jkind_abbrev_doc abbrev
660649
| Jkind_annotation { pjkind_desc = Pjk_mod _; _ } :: _ ->
@@ -813,7 +802,8 @@ let get_syntax_doc cursor_loc node : syntax_info =
813802
:: ( _,
814803
Module_type_constraint
815804
(Tmodtype_explicit
816-
{ mty_desc = Tmty_with (_, [ (_, _, Twith_modtype _) ]); _ }) )
805+
({ mty_desc = Tmty_with (_, [ (_, _, Twith_modtype _) ]); _ }, _))
806+
)
817807
:: _ ->
818808
Some
819809
{ name = "Module substitution";

0 commit comments

Comments
 (0)