Skip to content

Commit ef642fd

Browse files
mshinwellSkepfyrliam923TheNumbat
authored
Merge 5.2.0minus-22 (#191)
* flambda-backend -> oxcaml * Import ocaml sources for oxcaml/oxcaml@81eecd7a1fa * All 12 files with merge conflicts have been resolved: * src/ocaml/preprocess/parser_raw.mly (Hunks 3, 4, 10) - Added new grammar rules for quotation metaprogramming (spliceable_expr, Pexp_quote, Pexp_splice) * src/ocaml/parsing/pprintast.ml (Hunk 2) - Renamed jkind constructors with Pjk_ prefix while keeping Misc_stdlib.pp_parens_if * src/ocaml/typing/env.ml (Hunks 2, 5, 17, 23) - Added stage field to environment and integrated stage tracking helpers - Added Quotation_lock | Splice_lock cases for lock walking * src/ocaml/typing/env.mli (Hunk 7) - Added stage-related function signatures alongside existing fold functions * src/ocaml/typing/outcometree.mli (Hunk 1) - Added Oval_code constructor for quoted code values * src/ocaml/typing/printtyp.ml (Hunks 2, 3) - Kept Internal_names module structure and removed conflicting definitions * src/ocaml/typing/typecore.ml (Hunks 7, 16) - Added Texp_quotation, Texp_eval expression cases - Updated allocation mode error handling * src/ocaml/typing/typedtree.ml (Hunks 1, 3) - Added three new expression constructors: Texp_quotation, Texp_antiquotation, Texp_eval - Integrated fold_antiquote functions for traversing quotations * src/ocaml/typing/typedtree.mli (Hunks 1, 3) - Added new expression constructor signatures - Added fold_antiquote_exp function signature * src/ocaml/typing/typemod.ml (Hunk 1) - Combined quotation check with empty list parameter in transl_signature call * src/ocaml/typing/typeopt.ml (Hunks 1, 4) - Removed local is_always_gc_ignorable function (moved to Ctype module) - Updated calls to use Ctype.is_always_gc_ignorable * src/ocaml/typing/typetexp.ml (Hunk 4) - Updated lookup_local signature to return (type_expr * Env.stage) tuple * Vibecoded compilation fixes * Add camlinternalQuote.ml{,i} from 5.2.0minus-22 * update-magic-numbers.sh 569 5.2.0minus-22 * Formatting * Import ocaml sources for oxcaml/oxcaml@05b98d54a75 * Promote tests * Small fixes * Comment out line * Update comments in parser * Fix forkable mode doc Co-authored-by: Max Slater <[email protected]> --------- Co-authored-by: Jack Rickard <[email protected]> Co-authored-by: Liam Stevenson <[email protected]> Co-authored-by: Max Slater <[email protected]>
1 parent feef51f commit ef642fd

File tree

168 files changed

+32413
-24515
lines changed

Some content is hidden

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

168 files changed

+32413
-24515
lines changed

import-ocaml-source.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
cd "$(dirname "${BASH_SOURCE[0]}")"
44

55
# Script arguments with their default values
6-
repository=https://github.com/ocaml-flambda/flambda-backend
6+
repository=https://github.com/oxcaml/oxcaml
77
subdirectory=.
88
old_subdirectory=.
99

@@ -80,7 +80,7 @@ current_head="$(git symbolic-ref --short HEAD)"
8080
# First, add any files that have been added since the last import.
8181
./import-added-ocaml-source-files.sh "$commitish" "$repository" "$subdirectory" "$old_subdirectory"
8282

83-
# Then, fetch the new flambda-backend sources (which include ocaml-jst) and
83+
# Then, fetch the new oxcaml sources (which include ocaml-jst) and
8484
# copy into upstream/ocaml_flambda
8585
git fetch "$repository" "$commitish"
8686
rev=$(git rev-parse FETCH_HEAD)

src/analysis/construct.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,7 @@ module Gen = struct
558558
List.map choices ~f:(fun choice ->
559559
Ast_helper.Exp.unboxed_tuple choice)
560560
| Tvariant row_desc -> variant env rtyp row_desc
561+
| Tquote _ | Tsplice _ -> []
561562
| Tpackage (path, lids_args) -> begin
562563
let open Ast_helper in
563564
try

src/analysis/ptyp_of_type.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ and core_type type_expr =
134134
in
135135
Typ.poly names @@ core_type type_expr
136136
| Tof_kind _jkind -> (* CR modes: this is terrible *) Typ.any None
137+
| Tquote type_expr -> Typ.quote (core_type type_expr)
138+
| Tsplice type_expr -> Typ.splice (core_type type_expr)
137139
| Tpackage (path, lids_type_exprs) ->
138140
let loc = mknoloc (Untypeast.lident_of_path path) in
139141
let args =

src/analysis/syntax_doc.ml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ let get_mode_doc mode =
259259
Some "Functions with this mode can read but not write mutable data"
260260
| Comonadic Statefulness, Stateless ->
261261
Some "Functions with this mode cannot access mutable data"
262+
| Comonadic Forkable, Forkable ->
263+
Some "Functions with this mode may be executed concurrently."
264+
| Comonadic Forkable, Unforkable ->
265+
Some "Functions with this mode cannot be executed concurrently."
262266
in
263267
let doc_url =
264268
let subpage =
@@ -271,6 +275,7 @@ let get_mode_doc mode =
271275
| Comonadic Yielding -> "modes/intro/"
272276
| Monadic Visibility -> "modes/intro/"
273277
| Comonadic Statefulness -> "modes/intro/"
278+
| Comonadic Forkable -> "modes/intro/"
274279
in
275280
syntax_doc_url Oxcaml subpage
276281
in
@@ -641,16 +646,16 @@ let get_oxcaml_syntax_doc cursor_loc nodes : syntax_info =
641646
get_modality_doc modality
642647
| _ -> get_modality_doc modality)
643648
(* Jkinds *)
644-
| Jkind_annotation { pjkind_desc = Abbreviation abbrev; _ } :: _ ->
649+
| Jkind_annotation { pjkind_desc = Pjk_abbreviation abbrev; _ } :: _ ->
645650
get_jkind_abbrev_doc abbrev
646-
| Jkind_annotation { pjkind_desc = Mod _; _ } :: _ ->
651+
| Jkind_annotation { pjkind_desc = Pjk_mod _; _ } :: _ ->
647652
Some
648653
{ name = "`mod` keyword (in a kind)";
649654
description = "Types of this kind will cross the following modes";
650655
documentation = syntax_doc_url Oxcaml "kinds/intro/";
651656
level = Advanced
652657
}
653-
| Jkind_annotation { pjkind_desc = With (_, with_type, _); _ } :: _ -> (
658+
| Jkind_annotation { pjkind_desc = Pjk_with (_, with_type, _); _ } :: _ -> (
654659
match compare_cursor_to_loc with_type.ptyp_loc with
655660
| Before ->
656661
Some

src/analysis/tail_analysis.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ let expr_tail_positions = function
9191
| Texp_setmutvar _
9292
| Texp_idx _
9393
| Texp_atomic_loc _
94-
| Texp_hole _ -> []
94+
| Texp_hole _
95+
| Texp_quotation _
96+
| Texp_antiquotation _
97+
| Texp_eval _ -> []
9598
| Texp_match (_, _, cs, _) -> List.map cs ~f:(fun c -> Case c)
9699
| Texp_try (_, cs) -> List.map cs ~f:(fun c -> Case c)
97100
| Texp_letmodule (_, _, _, _, e)

src/ocaml/merlin_specific/browse_raw.ml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,9 @@ let rec of_expression_desc loc = function
504504
of_block_access block_access ** list_fold of_unboxed_access unboxed_access
505505
| Texp_atomic_loc (exp, _, _, _, _) -> of_expression exp
506506
| Texp_hole _ -> id_fold
507+
| Texp_quotation exp -> of_expression exp
508+
| Texp_antiquotation exp -> of_expression exp
509+
| Texp_eval (ct, _) -> of_core_type ct
507510

508511
(* We should consider taking into account param.fp_loc at some point, as it
509512
allows us to respond with the *parameter*'s type (as opposed to the
@@ -645,6 +648,8 @@ and of_core_type_desc = function
645648
of_core_type ct ** of_jkind_annotation_opt jkind
646649
| Ttyp_variant (rfs, _, _) -> list_fold (fun rf -> app (Row_field rf)) rfs
647650
| Ttyp_package pt -> app (Package_type pt)
651+
| Ttyp_quote ct -> of_core_type ct
652+
| Ttyp_splice ct -> of_core_type ct
648653

649654
and of_class_type_desc = function
650655
| Tcty_constr (_, _, cts) -> list_fold of_core_type cts
@@ -671,13 +676,14 @@ let of_jkind_annotation_desc : Parsetree.jkind_annotation_desc -> _ =
671676
id_fold
672677
in
673678
function
674-
| Default | Abbreviation _ -> id_fold
675-
| Mod (jkind, modes) -> of_jkind_annotation jkind ** list_fold of_mode modes
676-
| With (jkind, ct, modalities) ->
679+
| Pjk_default | Pjk_abbreviation _ -> id_fold
680+
| Pjk_mod (jkind, modes) ->
681+
of_jkind_annotation jkind ** list_fold of_mode modes
682+
| Pjk_with (jkind, ct, modalities) ->
677683
of_jkind_annotation jkind ** of_core_type ct
678684
** list_fold of_modality modalities
679-
| Kind_of ct -> of_core_type ct
680-
| Product jkinds -> list_fold of_jkind_annotation jkinds
685+
| Pjk_kind_of ct -> of_core_type ct
686+
| Pjk_product jkinds -> list_fold of_jkind_annotation jkinds
681687

682688
let of_attribute (attr : attribute) =
683689
let name = attr.attr_name.txt in

src/ocaml/parsing/ast_helper.ml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ module Typ = struct
7979
let package ?loc ?attrs a b = mk ?loc ?attrs (Ptyp_package (a, b))
8080
let extension ?loc ?attrs a = mk ?loc ?attrs (Ptyp_extension a)
8181
let open_ ?loc ?attrs mod_ident t = mk ?loc ?attrs (Ptyp_open (mod_ident, t))
82+
let quote ?loc ?attrs t = mk ?loc ?attrs (Ptyp_quote t)
83+
let splice ?loc ?attrs t = mk ?loc ?attrs (Ptyp_splice t)
8284
let of_kind ?loc ?attrs a = mk ?loc ?attrs (Ptyp_of_kind a)
8385

8486
let force_poly t =
@@ -138,6 +140,10 @@ module Typ = struct
138140
Ptyp_package(longident,List.map (fun (n,typ) -> (n,loop typ) ) lst)
139141
| Ptyp_open (mod_ident, core_type) ->
140142
Ptyp_open (mod_ident, loop core_type)
143+
| Ptyp_quote core_type ->
144+
Ptyp_quote (loop core_type)
145+
| Ptyp_splice core_type ->
146+
Ptyp_splice (loop core_type)
141147
| Ptyp_of_kind jkind ->
142148
Ptyp_of_kind (loop_jkind jkind)
143149
| Ptyp_extension (s, arg) ->
@@ -147,12 +153,13 @@ module Typ = struct
147153
and loop_jkind jkind =
148154
let pjkind_desc =
149155
match jkind.pjkind_desc with
150-
| Default as x -> x
151-
| Abbreviation _ as x -> x
152-
| Mod (jkind, modes) -> Mod (loop_jkind jkind, modes)
153-
| With (jkind, typ, modalities) -> With (loop_jkind jkind, loop typ, modalities)
154-
| Kind_of typ -> Kind_of (loop typ)
155-
| Product jkinds -> Product (List.map loop_jkind jkinds)
156+
| Pjk_default as x -> x
157+
| Pjk_abbreviation _ as x -> x
158+
| Pjk_mod (jkind, modes) -> Pjk_mod (loop_jkind jkind, modes)
159+
| Pjk_with (jkind, typ, modalities) ->
160+
Pjk_with (loop_jkind jkind, loop typ, modalities)
161+
| Pjk_kind_of typ -> Pjk_kind_of (loop typ)
162+
| Pjk_product jkinds -> Pjk_product (List.map loop_jkind jkinds)
156163
in
157164
{ jkind with pjkind_desc }
158165
and loop_row_field field =
@@ -266,6 +273,8 @@ module Exp = struct
266273
let stack ?loc ?attrs e = mk ?loc ?attrs (Pexp_stack e)
267274
let comprehension ?loc ?attrs e = mk ?loc ?attrs (Pexp_comprehension e)
268275
let overwrite ?loc ?attrs a b = mk ?loc ?attrs (Pexp_overwrite (a, b))
276+
let quote ?loc ?attrs a = mk ?loc ?attrs (Pexp_quote a)
277+
let splice ?loc ?attrs a = mk ?loc ?attrs (Pexp_splice a)
269278
let hole ?loc ?attrs () = mk ?loc ?attrs Pexp_hole
270279

271280
let case lhs ?guard rhs =

src/ocaml/parsing/ast_helper.mli

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ module Typ :
9494
val package: ?loc:loc -> ?attrs:attrs -> lid -> (lid * core_type) list
9595
-> core_type
9696
val open_ : ?loc:loc -> ?attrs:attrs -> lid -> core_type -> core_type
97+
val quote : ?loc:loc -> ?attrs:attrs -> core_type -> core_type
98+
val splice : ?loc:loc -> ?attrs:attrs -> core_type -> core_type
9799
val of_kind : ?loc:loc -> ?attrs:attrs -> jkind_annotation -> core_type
98100
val extension: ?loc:loc -> ?attrs:attrs -> extension -> core_type
99101

@@ -224,6 +226,8 @@ module Exp:
224226
val stack : ?loc:loc -> ?attrs:attrs -> expression -> expression
225227
val comprehension :
226228
?loc:loc -> ?attrs:attrs -> comprehension_expression -> expression
229+
val quote : ?loc:loc -> ?attrs:attrs -> expression -> expression
230+
val splice : ?loc:loc -> ?attrs:attrs -> expression -> expression
227231
val overwrite : ?loc:loc -> ?attrs:attrs -> expression -> expression -> expression
228232
val hole : ?loc:loc -> ?attrs:attrs -> unit -> expression
229233

src/ocaml/parsing/ast_iterator.ml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ module T = struct
155155
| Ptyp_open (mod_ident, t) ->
156156
iter_loc sub mod_ident;
157157
sub.typ sub t
158+
| Ptyp_quote t -> sub.typ sub t
159+
| Ptyp_splice t -> sub.typ sub t
158160
| Ptyp_of_kind jkind ->
159161
sub.jkind_annotation sub jkind
160162
| Ptyp_extension x -> sub.extension sub x
@@ -552,6 +554,8 @@ module E = struct
552554
| Pexp_stack e -> sub.expr sub e
553555
| Pexp_comprehension e -> iter_comp_exp sub e
554556
| Pexp_overwrite (e1, e2) -> sub.expr sub e1; sub.expr sub e2
557+
| Pexp_quote e -> sub.expr sub e
558+
| Pexp_splice e -> sub.expr sub e
555559
| Pexp_hole -> ()
556560

557561
let iter_binding_op sub {pbop_op; pbop_pat; pbop_exp; pbop_loc} =
@@ -854,17 +858,17 @@ let default_iterator =
854858
(fun this { pjkind_loc; pjkind_desc } ->
855859
this.location this pjkind_loc;
856860
match pjkind_desc with
857-
| Default -> ()
858-
| Abbreviation (_ : string) -> ()
859-
| Mod (t, mode_list) ->
861+
| Pjk_default -> ()
862+
| Pjk_abbreviation (_ : string) -> ()
863+
| Pjk_mod (t, mode_list) ->
860864
this.jkind_annotation this t;
861865
this.modes this mode_list
862-
| With (t, ty, modalities) ->
866+
| Pjk_with (t, ty, modalities) ->
863867
this.jkind_annotation this t;
864868
this.typ this ty;
865869
this.modalities this modalities
866-
| Kind_of ty -> this.typ this ty
867-
| Product ts -> List.iter (this.jkind_annotation this) ts);
870+
| Pjk_kind_of ty -> this.typ this ty
871+
| Pjk_product ts -> List.iter (this.jkind_annotation this) ts);
868872

869873
directive_argument =
870874
(fun this a ->

src/ocaml/parsing/ast_mapper.ml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ module T = struct
193193
(List.map (map_tuple (map_loc sub) (sub.typ sub)) l)
194194
| Ptyp_open (mod_ident, t) ->
195195
open_ ~loc ~attrs (map_loc sub mod_ident) (sub.typ sub t)
196+
| Ptyp_quote t ->
197+
quote ~loc ~attrs (sub.typ sub t)
198+
| Ptyp_splice t ->
199+
splice ~loc ~attrs (sub.typ sub t)
196200
| Ptyp_of_kind jkind ->
197201
of_kind ~loc ~attrs (sub.jkind_annotation sub jkind)
198202
| Ptyp_extension x -> extension ~loc ~attrs (sub.extension sub x)
@@ -629,6 +633,8 @@ module E = struct
629633
| Pexp_stack e -> stack ~loc ~attrs (sub.expr sub e)
630634
| Pexp_comprehension c -> comprehension ~loc ~attrs (map_cexp sub c)
631635
| Pexp_overwrite (e1, e2) -> overwrite ~loc ~attrs (sub.expr sub e1) (sub.expr sub e2)
636+
| Pexp_quote e -> quote ~loc ~attrs e
637+
| Pexp_splice e -> splice ~loc ~attrs e
632638
| Pexp_hole -> hole ~loc ~attrs ()
633639

634640
let map_binding_op sub {pbop_op; pbop_pat; pbop_exp; pbop_loc} =
@@ -961,14 +967,19 @@ let default_mapper =
961967
let pjkind_loc = this.location this pjkind_loc in
962968
let pjkind_desc =
963969
match pjkind_desc with
964-
| Default -> Default
965-
| Abbreviation (s : string) -> Abbreviation s
966-
| Mod (t, mode_list) ->
967-
Mod (this.jkind_annotation this t, this.modes this mode_list)
968-
| With (t, ty, modalities) ->
969-
With (this.jkind_annotation this t, this.typ this ty, this.modalities this modalities)
970-
| Kind_of ty -> Kind_of (this.typ this ty)
971-
| Product ts -> Product (List.map (this.jkind_annotation this) ts)
970+
| Pjk_default -> Pjk_default
971+
| Pjk_abbreviation (s : string) -> Pjk_abbreviation s
972+
| Pjk_mod (t, mode_list) ->
973+
Pjk_mod (this.jkind_annotation this t, this.modes this mode_list)
974+
| Pjk_with (t, ty, modalities) ->
975+
Pjk_with (
976+
this.jkind_annotation this t,
977+
this.typ this ty,
978+
this.modalities this modalities
979+
)
980+
| Pjk_kind_of ty -> Pjk_kind_of (this.typ this ty)
981+
| Pjk_product ts ->
982+
Pjk_product (List.map (this.jkind_annotation this) ts)
972983
in
973984
{ pjkind_loc; pjkind_desc });
974985

0 commit comments

Comments
 (0)