diff --git a/CHANGELOG.md b/CHANGELOG.md index 66ed1f733d..c80b5439f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ #### :house: Internal - AST: Add bar location to `case`. https://github.com/rescript-lang/rescript/pull/7407 +- Clean up lazy from ASTs and back-end. https://github.com/rescript-lang/rescript/pull/7474 #### :nail_care: Polish diff --git a/analysis/reanalyze/src/Arnold.ml b/analysis/reanalyze/src/Arnold.ml index 9b31743603..9eec8d729e 100644 --- a/analysis/reanalyze/src/Arnold.ml +++ b/analysis/reanalyze/src/Arnold.ml @@ -988,9 +988,6 @@ module Compile = struct | Texp_letexception _ -> notImplemented "Texp_letexception"; assert false - | Texp_lazy _ -> - notImplemented "Texp_lazy"; - assert false | Texp_pack _ -> notImplemented "Texp_pack"; assert false diff --git a/analysis/reanalyze/src/SideEffects.ml b/analysis/reanalyze/src/SideEffects.ml index 5d4c077241..5aceaf124d 100644 --- a/analysis/reanalyze/src/SideEffects.ml +++ b/analysis/reanalyze/src/SideEffects.ml @@ -45,7 +45,6 @@ let rec exprNoSideEffects (expr : Typedtree.expression) = partial = Total && e |> exprNoSideEffects && cases |> List.for_all caseNoSideEffects | Texp_letmodule _ -> false - | Texp_lazy e -> e |> exprNoSideEffects | Texp_try (e, cases) -> e |> exprNoSideEffects && cases |> List.for_all caseNoSideEffects | Texp_tuple el -> el |> List.for_all exprNoSideEffects diff --git a/analysis/src/CompletionFrontEnd.ml b/analysis/src/CompletionFrontEnd.ml index 0970e5418b..2c2b49380e 100644 --- a/analysis/src/CompletionFrontEnd.ml +++ b/analysis/src/CompletionFrontEnd.ml @@ -538,7 +538,6 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor ?contextPath:(TypeUtils.contextPathFromCoreType coreType) p | Ppat_type _ -> () - | Ppat_lazy p -> scopePattern ~patternPath ?contextPath p | Ppat_unpack {txt; loc} -> scope := !scope |> Scope.addValue ~name:txt ~loc ?contextPath:contextPathToSave diff --git a/analysis/src/CompletionPatterns.ml b/analysis/src/CompletionPatterns.ml index c7d4e1646e..5ba9431c9a 100644 --- a/analysis/src/CompletionPatterns.ml +++ b/analysis/src/CompletionPatterns.ml @@ -46,7 +46,6 @@ and traversePattern (pat : Parsetree.pattern) ~patternPath ~locHasCursor in match pat.ppat_desc with | Ppat_constant _ | Ppat_interval _ -> None - | Ppat_lazy p | Ppat_constraint (p, _) | Ppat_alias (p, _) | Ppat_exception p diff --git a/analysis/src/Hint.ml b/analysis/src/Hint.ml index 53e97c0715..8d673a95a5 100644 --- a/analysis/src/Hint.ml +++ b/analysis/src/Hint.ml @@ -59,8 +59,8 @@ let inlay ~path ~pos ~maxLength ~debug = pexp_desc = ( Pexp_constant _ | Pexp_tuple _ | Pexp_record _ | Pexp_variant _ | Pexp_apply _ | Pexp_match _ | Pexp_construct _ | Pexp_ifthenelse _ - | Pexp_array _ | Pexp_ident _ | Pexp_try _ | Pexp_lazy _ - | Pexp_send _ | Pexp_field _ | Pexp_open _ + | Pexp_array _ | Pexp_ident _ | Pexp_try _ | Pexp_send _ + | Pexp_field _ | Pexp_open _ | Pexp_fun {arity = Some _} ); }; } -> diff --git a/analysis/src/ProcessCmt.ml b/analysis/src/ProcessCmt.ml index 6ea7ea699c..be770a0687 100644 --- a/analysis/src/ProcessCmt.ml +++ b/analysis/src/ProcessCmt.ml @@ -460,7 +460,6 @@ let rec forStructureItem ~env ~(exported : Exported.t) item = | Tpat_or (p, _, _) -> handlePattern [] p | Tpat_record (items, _) -> items |> List.iter (fun (_, _, p, _) -> handlePattern [] p) - | Tpat_lazy p -> handlePattern [] p | Tpat_variant (_, Some p, _) -> handlePattern [] p | Tpat_variant (_, None, _) | Tpat_any | Tpat_constant _ -> () in diff --git a/analysis/src/Utils.ml b/analysis/src/Utils.ml index 29e23e6031..863598dc56 100644 --- a/analysis/src/Utils.ml +++ b/analysis/src/Utils.ml @@ -106,7 +106,6 @@ let identifyPexp pexp = | Pexp_letmodule _ -> "Pexp_letmodule" | Pexp_letexception _ -> "Pexp_letexception" | Pexp_assert _ -> "Pexp_assert" - | Pexp_lazy _ -> "Pexp_lazy" | Pexp_newtype _ -> "Pexp_newtype" | Pexp_pack _ -> "Pexp_pack" | Pexp_extension _ -> "Pexp_extension" @@ -129,7 +128,6 @@ let identifyPpat pat = | Ppat_or _ -> "Ppat_or" | Ppat_constraint _ -> "Ppat_constraint" | Ppat_type _ -> "Ppat_type" - | Ppat_lazy _ -> "Ppat_lazy" | Ppat_unpack _ -> "Ppat_unpack" | Ppat_exception _ -> "Ppat_exception" | Ppat_extension _ -> "Ppat_extension" diff --git a/compiler/common/pattern_printer.ml b/compiler/common/pattern_printer.ml index a0008a9626..96d9fdf01d 100644 --- a/compiler/common/pattern_printer.ml +++ b/compiler/common/pattern_printer.ml @@ -38,7 +38,6 @@ let untype typed = in mkpat (Ppat_record (fields, closed_flag)) | Tpat_array lst -> mkpat (Ppat_array (List.map loop lst)) - | Tpat_lazy p -> mkpat (Ppat_lazy (loop p)) in loop typed diff --git a/compiler/core/js_dump.ml b/compiler/core/js_dump.ml index 11c0aeb4a7..e4c9f47736 100644 --- a/compiler/core/js_dump.ml +++ b/compiler/core/js_dump.ml @@ -969,12 +969,8 @@ and expression_desc cxt ~(level : int) f x : cxt = | _ -> J.Object (None, objs) in expression_desc cxt ~level f exp - | Caml_block - ( _, - _, - _, - (Blk_module_export _ | Blk_some | Blk_some_not_nested | Blk_lazy_general) - ) -> + | Caml_block (_, _, _, (Blk_module_export _ | Blk_some | Blk_some_not_nested)) + -> assert false | Caml_block (el, mutable_flag, _tag, Blk_tuple) -> expression_desc cxt ~level f (Array (el, mutable_flag)) diff --git a/compiler/core/js_exp_make.ml b/compiler/core/js_exp_make.ml index 4cf7f854e5..c469a64f04 100644 --- a/compiler/core/js_exp_make.ml +++ b/compiler/core/js_exp_make.ml @@ -283,7 +283,7 @@ let dummy_obj ?comment (info : Lam_tag_info.t) : t = {comment; expression_desc = Object (None, [])} | Blk_tuple | Blk_module_export _ -> {comment; expression_desc = Array ([], Mutable)} - | Blk_some | Blk_some_not_nested | Blk_lazy_general -> assert false + | Blk_some | Blk_some_not_nested -> assert false (* TODO: complete pure ... diff --git a/compiler/core/lam_constant_convert.ml b/compiler/core/lam_constant_convert.ml index 938977d581..3be30e048c 100644 --- a/compiler/core/lam_constant_convert.ml +++ b/compiler/core/lam_constant_convert.ml @@ -83,5 +83,4 @@ let rec convert_constant (const : Lambda.structured_constant) : Lam_constant.t = else Const_string {s; unicode = false} in Const_block (tag, t, [tag_val; convert_constant value]) - | _ -> assert false) - | Blk_lazy_general -> assert false) + | _ -> assert false)) diff --git a/compiler/core/lam_convert.ml b/compiler/core/lam_convert.ml index c62eed5d0b..ed8ced3601 100644 --- a/compiler/core/lam_convert.ml +++ b/compiler/core/lam_convert.ml @@ -31,13 +31,6 @@ let prim = Lam.prim let lam_extension_id loc (head : Lam.t) = prim ~primitive:lam_caml_id ~args:[head] loc -let lazy_block_info : Lam_tag_info.t = - Blk_record - { - fields = [|(Literals.lazy_done, false); (Literals.lazy_val, false)|]; - mutable_flag = Mutable; - } - (** A conservative approach to avoid packing exceptions for lambda expression like {[ try { ... }catch(id){body} @@ -197,22 +190,6 @@ let lam_prim ~primitive:(p : Lambda.primitive) ~args loc : Lam.t = ~primitive:(Pmakeblock (tag, info, mutable_flag)) ~args:[Lam.const tag_val; value] loc - | _ -> assert false) - | Blk_lazy_general -> ( - match args with - | [((Lvar _ | Lconst _ | Lfunction _) as result)] -> - let args = [Lam.const Const_js_true; result] in - prim ~primitive:(Pmakeblock (tag, lazy_block_info, Mutable)) ~args loc - | [computation] -> - let args = - [ - Lam.const Const_js_false; - (* FIXME: arity 0 does not get proper supported*) - Lam.function_ ~arity:0 ~params:[] ~body:computation - ~attr:Lambda.default_function_attribute; - ] - in - prim ~primitive:(Pmakeblock (tag, lazy_block_info, Mutable)) ~args loc | _ -> assert false)) | Pfn_arity -> prim ~primitive:Pfn_arity ~args loc | Pdebugger -> prim ~primitive:Pdebugger ~args loc diff --git a/compiler/ext/literals.ml b/compiler/ext/literals.ml index 9c413e7603..2b469652ad 100644 --- a/compiler/ext/literals.ml +++ b/compiler/ext/literals.ml @@ -164,8 +164,4 @@ let hd = "hd" let tl = "tl" -let lazy_done = "LAZY_DONE" - -let lazy_val = "VAL" - let pure = "@__PURE__" diff --git a/compiler/ext/primitive_modules.ml b/compiler/ext/primitive_modules.ml index af57d0be8b..b11bc8766a 100644 --- a/compiler/ext/primitive_modules.ml +++ b/compiler/ext/primitive_modules.ml @@ -42,8 +42,6 @@ let promise = "Primitive_promise" let module_ = "Primitive_module" -let lazy_ = "Primitive_lazy" - let option = "Primitive_option" let hash = "Primitive_hash" diff --git a/compiler/frontend/bs_ast_mapper.ml b/compiler/frontend/bs_ast_mapper.ml index a6dfc764e3..287608c40d 100644 --- a/compiler/frontend/bs_ast_mapper.ml +++ b/compiler/frontend/bs_ast_mapper.ml @@ -373,7 +373,6 @@ module E = struct (sub.extension_constructor sub cd) (sub.expr sub e) | Pexp_assert e -> assert_ ~loc ~attrs (sub.expr sub e) - | Pexp_lazy e -> lazy_ ~loc ~attrs (sub.expr sub e) | Pexp_newtype (s, e) -> newtype ~loc ~attrs (map_loc sub s) (sub.expr sub e) | Pexp_pack me -> pack ~loc ~attrs (sub.module_expr sub me) @@ -434,7 +433,6 @@ module P = struct | Ppat_constraint (p, t) -> constraint_ ~loc ~attrs (sub.pat sub p) (sub.typ sub t) | Ppat_type s -> type_ ~loc ~attrs (map_loc sub s) - | Ppat_lazy p -> lazy_ ~loc ~attrs (sub.pat sub p) | Ppat_unpack s -> unpack ~loc ~attrs (map_loc sub s) | Ppat_open (lid, p) -> open_ ~loc ~attrs (map_loc sub lid) (sub.pat sub p) | Ppat_exception p -> exception_ ~loc ~attrs (sub.pat sub p) diff --git a/compiler/ml/ast_helper.ml b/compiler/ml/ast_helper.ml index 05c715e6f5..c5d903b138 100644 --- a/compiler/ml/ast_helper.ml +++ b/compiler/ml/ast_helper.ml @@ -136,7 +136,6 @@ module Pat = struct let or_ ?loc ?attrs a b = mk ?loc ?attrs (Ppat_or (a, b)) let constraint_ ?loc ?attrs a b = mk ?loc ?attrs (Ppat_constraint (a, b)) let type_ ?loc ?attrs a = mk ?loc ?attrs (Ppat_type a) - let lazy_ ?loc ?attrs a = mk ?loc ?attrs (Ppat_lazy a) let unpack ?loc ?attrs a = mk ?loc ?attrs (Ppat_unpack a) let open_ ?loc ?attrs a b = mk ?loc ?attrs (Ppat_open (a, b)) let exception_ ?loc ?attrs a = mk ?loc ?attrs (Ppat_exception a) @@ -176,7 +175,6 @@ module Exp = struct let letmodule ?loc ?attrs a b c = mk ?loc ?attrs (Pexp_letmodule (a, b, c)) let letexception ?loc ?attrs a b = mk ?loc ?attrs (Pexp_letexception (a, b)) let assert_ ?loc ?attrs a = mk ?loc ?attrs (Pexp_assert a) - let lazy_ ?loc ?attrs a = mk ?loc ?attrs (Pexp_lazy a) let newtype ?loc ?attrs a b = mk ?loc ?attrs (Pexp_newtype (a, b)) let pack ?loc ?attrs a = mk ?loc ?attrs (Pexp_pack a) let open_ ?loc ?attrs a b c = mk ?loc ?attrs (Pexp_open (a, b, c)) diff --git a/compiler/ml/ast_helper.mli b/compiler/ml/ast_helper.mli index 467050bb5b..9fbee171ae 100644 --- a/compiler/ml/ast_helper.mli +++ b/compiler/ml/ast_helper.mli @@ -114,7 +114,6 @@ module Pat : sig val or_ : ?loc:loc -> ?attrs:attrs -> pattern -> pattern -> pattern val constraint_ : ?loc:loc -> ?attrs:attrs -> pattern -> core_type -> pattern val type_ : ?loc:loc -> ?attrs:attrs -> lid -> pattern - val lazy_ : ?loc:loc -> ?attrs:attrs -> pattern -> pattern val unpack : ?loc:loc -> ?attrs:attrs -> str -> pattern val open_ : ?loc:loc -> ?attrs:attrs -> lid -> pattern -> pattern val exception_ : ?loc:loc -> ?attrs:attrs -> pattern -> pattern @@ -203,7 +202,6 @@ module Exp : sig expression -> expression val assert_ : ?loc:loc -> ?attrs:attrs -> expression -> expression - val lazy_ : ?loc:loc -> ?attrs:attrs -> expression -> expression val newtype : ?loc:loc -> ?attrs:attrs -> str -> expression -> expression val pack : ?loc:loc -> ?attrs:attrs -> module_expr -> expression val open_ : diff --git a/compiler/ml/ast_iterator.ml b/compiler/ml/ast_iterator.ml index 9790cfc839..d33f1b656c 100644 --- a/compiler/ml/ast_iterator.ml +++ b/compiler/ml/ast_iterator.ml @@ -350,7 +350,6 @@ module E = struct sub.extension_constructor sub cd; sub.expr sub e | Pexp_assert e -> sub.expr sub e - | Pexp_lazy e -> sub.expr sub e | Pexp_newtype (_s, e) -> sub.expr sub e | Pexp_pack me -> sub.module_expr sub me | Pexp_open (_ovf, lid, e) -> @@ -407,7 +406,6 @@ module P = struct sub.pat sub p; sub.typ sub t | Ppat_type s -> iter_loc sub s - | Ppat_lazy p -> sub.pat sub p | Ppat_unpack s -> iter_loc sub s | Ppat_exception p -> sub.pat sub p | Ppat_extension x -> sub.extension sub x diff --git a/compiler/ml/ast_mapper.ml b/compiler/ml/ast_mapper.ml index dbaea2b466..06adfddb37 100644 --- a/compiler/ml/ast_mapper.ml +++ b/compiler/ml/ast_mapper.ml @@ -336,7 +336,6 @@ module E = struct (sub.extension_constructor sub cd) (sub.expr sub e) | Pexp_assert e -> assert_ ~loc ~attrs (sub.expr sub e) - | Pexp_lazy e -> lazy_ ~loc ~attrs (sub.expr sub e) | Pexp_newtype (s, e) -> newtype ~loc ~attrs (map_loc sub s) (sub.expr sub e) | Pexp_pack me -> pack ~loc ~attrs (sub.module_expr sub me) @@ -398,7 +397,6 @@ module P = struct | Ppat_constraint (p, t) -> constraint_ ~loc ~attrs (sub.pat sub p) (sub.typ sub t) | Ppat_type s -> type_ ~loc ~attrs (map_loc sub s) - | Ppat_lazy p -> lazy_ ~loc ~attrs (sub.pat sub p) | Ppat_unpack s -> unpack ~loc ~attrs (map_loc sub s) | Ppat_open (lid, p) -> open_ ~loc ~attrs (map_loc sub lid) (sub.pat sub p) | Ppat_exception p -> exception_ ~loc ~attrs (sub.pat sub p) diff --git a/compiler/ml/ast_mapper_from0.ml b/compiler/ml/ast_mapper_from0.ml index 959ef18690..ddd0f5e580 100644 --- a/compiler/ml/ast_mapper_from0.ml +++ b/compiler/ml/ast_mapper_from0.ml @@ -527,7 +527,7 @@ module E = struct (sub.extension_constructor sub cd) (sub.expr sub e) | Pexp_assert e -> assert_ ~loc ~attrs (sub.expr sub e) - | Pexp_lazy e -> lazy_ ~loc ~attrs (sub.expr sub e) + | Pexp_lazy _ -> failwith "Pexp_lazy is no longer present in ReScript" | Pexp_poly _ -> failwith "Pexp_poly is no longer present in ReScript" | Pexp_object () -> assert false | Pexp_newtype (s, e) -> @@ -572,7 +572,7 @@ module P = struct | Ppat_constraint (p, t) -> constraint_ ~loc ~attrs (sub.pat sub p) (sub.typ sub t) | Ppat_type s -> type_ ~loc ~attrs (map_loc sub s) - | Ppat_lazy p -> lazy_ ~loc ~attrs (sub.pat sub p) + | Ppat_lazy _ -> failwith "Ppat_lazy is no longer present in ReScript" | Ppat_unpack s -> unpack ~loc ~attrs (map_loc sub s) | Ppat_open (lid, p) -> open_ ~loc ~attrs (map_loc sub lid) (sub.pat sub p) | Ppat_exception p -> exception_ ~loc ~attrs (sub.pat sub p) diff --git a/compiler/ml/ast_mapper_to0.ml b/compiler/ml/ast_mapper_to0.ml index 0f5494bb23..d35d3702d4 100644 --- a/compiler/ml/ast_mapper_to0.ml +++ b/compiler/ml/ast_mapper_to0.ml @@ -460,7 +460,6 @@ module E = struct (sub.extension_constructor sub cd) (sub.expr sub e) | Pexp_assert e -> assert_ ~loc ~attrs (sub.expr sub e) - | Pexp_lazy e -> lazy_ ~loc ~attrs (sub.expr sub e) | Pexp_newtype (s, e) -> newtype ~loc ~attrs (map_loc sub s) (sub.expr sub e) | Pexp_pack me -> pack ~loc ~attrs (sub.module_expr sub me) @@ -568,7 +567,6 @@ module P = struct | Ppat_constraint (p, t) -> constraint_ ~loc ~attrs (sub.pat sub p) (sub.typ sub t) | Ppat_type s -> type_ ~loc ~attrs (map_loc sub s) - | Ppat_lazy p -> lazy_ ~loc ~attrs (sub.pat sub p) | Ppat_unpack s -> unpack ~loc ~attrs (map_loc sub s) | Ppat_open (lid, p) -> open_ ~loc ~attrs (map_loc sub lid) (sub.pat sub p) | Ppat_exception p -> exception_ ~loc ~attrs (sub.pat sub p) diff --git a/compiler/ml/depend.ml b/compiler/ml/depend.ml index ea3c71b947..f474d872cf 100644 --- a/compiler/ml/depend.ml +++ b/compiler/ml/depend.ml @@ -198,7 +198,6 @@ let rec add_pattern bv pat = add_type bv ty | Ppat_variant (_, op) -> add_opt add_pattern bv op | Ppat_type li -> add bv li - | Ppat_lazy p -> add_pattern bv p | Ppat_unpack id -> pattern_bv := StringMap.add id.txt bound !pattern_bv | Ppat_open (m, p) -> let bv = open_module bv m.txt in @@ -276,7 +275,6 @@ let rec add_expr bv exp = add_expr (StringMap.add id.txt b bv) e | Pexp_letexception (_, e) -> add_expr bv e | Pexp_assert e -> add_expr bv e - | Pexp_lazy e -> add_expr bv e | Pexp_newtype (_, e) -> add_expr bv e | Pexp_pack m -> add_module bv m | Pexp_open (_ovf, m, e) -> diff --git a/compiler/ml/env.ml b/compiler/ml/env.ml index a40a83bed0..970634be03 100644 --- a/compiler/ml/env.ml +++ b/compiler/ml/env.ml @@ -1878,11 +1878,6 @@ let open_signature slot root env0 = (* Open a signature from a file *) -let open_pers_signature name env = - match open_signature None (Pident (Ident.create_persistent name)) env with - | Some env -> env - | None -> assert false (* a compilation unit cannot refer to a functor *) - let open_signature ?(used_slot = ref false) ?(loc = Location.none) ?(toplevel = false) ovf root env = if diff --git a/compiler/ml/env.mli b/compiler/ml/env.mli index c36a0aa052..48eaba1c10 100644 --- a/compiler/ml/env.mli +++ b/compiler/ml/env.mli @@ -155,8 +155,6 @@ val open_signature : t -> t option -val open_pers_signature : string -> t -> t - (* Insertion by name *) val enter_value : diff --git a/compiler/ml/lambda.ml b/compiler/ml/lambda.ml index 2046977019..ce15e93de0 100644 --- a/compiler/ml/lambda.ml +++ b/compiler/ml/lambda.ml @@ -46,7 +46,6 @@ type tag_info = fields: string array; mutable_flag: Asttypes.mutable_flag; } - | Blk_lazy_general let tag_of_tag_info (tag : tag_info) = match tag with @@ -54,7 +53,6 @@ let tag_of_tag_info (tag : tag_info) = | Blk_tuple | Blk_poly_var _ | Blk_record _ | Blk_module _ | Blk_module_export _ | Blk_extension | Blk_some (* tag not make sense *) | Blk_some_not_nested (* tag not make sense *) - | Blk_lazy_general (* tag not make sense 248 *) | Blk_record_ext _ (* similar to Blk_extension*) -> 0 @@ -64,7 +62,6 @@ let mutable_flag_of_tag_info (tag : tag_info) = | Blk_record {mutable_flag} | Blk_record_ext {mutable_flag} -> mutable_flag - | Blk_lazy_general -> Mutable | Blk_tuple | Blk_constructor _ | Blk_poly_var _ | Blk_module _ | Blk_module_export _ | Blk_extension | Blk_some_not_nested | Blk_some -> Immutable diff --git a/compiler/ml/lambda.mli b/compiler/ml/lambda.mli index ecd5db632d..39e3a794f7 100644 --- a/compiler/ml/lambda.mli +++ b/compiler/ml/lambda.mli @@ -56,7 +56,6 @@ type tag_info = | Blk_some_not_nested (* ['a option] where ['a] can not inhabit a non-like value *) | Blk_record_ext of {fields: string array; mutable_flag: mutable_flag} - | Blk_lazy_general val find_name : Parsetree.attribute -> Asttypes.label option diff --git a/compiler/ml/matching.ml b/compiler/ml/matching.ml index 623869f705..5fba3beb56 100644 --- a/compiler/ml/matching.ml +++ b/compiler/ml/matching.ml @@ -40,12 +40,11 @@ let dbg = false returns true when they may have a common instance. *) -module MayCompat = Parmatch.Compat (struct - let equal = Types.may_equal_constr -end) -let may_compat = MayCompat.compat +let equal_cd c1 c2 = Types.may_equal_constr c1 c2 + +let may_compat = Parmatch.Compat.compat ~equal_cd -and may_compats = MayCompat.compats +and may_compats = Parmatch.Compat.compats ~equal_cd (* Many functions on the various data structures of the algorithm : @@ -225,12 +224,6 @@ let ctx_matcher p = (p, List.fold_right (fun (_, _, p, _) r -> p :: r) l' rem) | Tpat_any -> (p, List.fold_right (fun (_, _, p, _) r -> p :: r) l rem) | _ -> raise NoMatch) - | Tpat_lazy omega -> ( - fun q rem -> - match q.pat_desc with - | Tpat_lazy arg -> (p, arg :: rem) - | Tpat_any -> (p, omega :: rem) - | _ -> raise NoMatch) | _ -> fatal_error "Matching.ctx_matcher" let filter_ctx q ctx = @@ -627,7 +620,6 @@ let rec extract_vars r p = | Tpat_construct (_, _, pats) -> List.fold_left extract_vars r pats | Tpat_array pats -> List.fold_left extract_vars r pats | Tpat_variant (_, Some p, _) -> extract_vars r p - | Tpat_lazy p -> extract_vars r p | Tpat_or (p, _, _) -> extract_vars r p | Tpat_constant _ | Tpat_any | Tpat_variant (_, None, _) -> r @@ -696,10 +688,6 @@ and group_array = function | {pat_desc = Tpat_array _} -> true | _ -> false -and group_lazy = function - | {pat_desc = Tpat_lazy _} -> true - | _ -> false - let get_group p = match p.pat_desc with | Tpat_any -> group_var @@ -709,7 +697,6 @@ let get_group p = | Tpat_record _ -> group_record | Tpat_array _ -> group_array | Tpat_variant (_, _, _) -> group_variant - | Tpat_lazy _ -> group_lazy | _ -> fatal_error "Matching.get_group" let is_or p = @@ -1390,79 +1377,6 @@ let make_var_matching def = function let divide_var ctx pm = divide_line ctx_lshift make_var_matching get_args_var omega ctx pm -(* Matching and forcing a lazy value *) - -let get_arg_lazy p rem = - match p with - | {pat_desc = Tpat_any} -> omega :: rem - | {pat_desc = Tpat_lazy arg} -> arg :: rem - | _ -> assert false - -let matcher_lazy p rem = - match p.pat_desc with - | Tpat_or (_, _, _) -> raise OrPat - | Tpat_any | Tpat_var _ -> omega :: rem - | Tpat_lazy arg -> arg :: rem - | _ -> raise NoMatch - -(* Inlining the tag tests before calling the primitive that works on - lazy blocks. This is also used in translcore.ml. - No other call than Obj.tag when the value has been forced before. -*) - -let get_mod_field modname field = - lazy - (try - let mod_ident = Ident.create_persistent modname in - let env = Env.open_pers_signature modname Env.initial_safe_string in - let p = - try - match Env.lookup_value (Longident.Lident field) env with - | Path.Pdot (_, _, i), _ -> i - | _ -> - fatal_error ("Primitive " ^ modname ^ "." ^ field ^ " not found.") - with Not_found -> - fatal_error ("Primitive " ^ modname ^ "." ^ field ^ " not found.") - in - Lprim - ( Pfield (p, Fld_module {name = field}), - [Lprim (Pgetglobal mod_ident, [], Location.none)], - Location.none ) - with Not_found -> fatal_error ("Module " ^ modname ^ " unavailable.")) - -let code_force = get_mod_field Primitive_modules.lazy_ "force" - -(* inline_lazy_force inlines the beginning of the code of Lazy.force. When - the value argument is tagged as: - - forward, take field 0 - - lazy, call the primitive that forces (without testing again the tag) - - anything else, return it - - Using Lswitch below relies on the fact that the GC does not shortcut - Forward(val_out_of_heap). -*) - -let inline_lazy_force arg loc = - Lapply - { - ap_func = Lazy.force code_force; - ap_inlined = Default_inline; - ap_args = [arg]; - ap_loc = loc; - ap_transformed_jsx = false; - } -let make_lazy_matching def = function - | [] -> fatal_error "Matching.make_lazy_matching" - | (arg, _mut) :: argl -> - { - cases = []; - args = (inline_lazy_force arg Location.none, Strict) :: argl; - default = make_default matcher_lazy def; - } - -let divide_lazy p ctx pm = - divide_line (filter_ctx p) make_lazy_matching get_arg_lazy p ctx pm - (* Matching against a tuple pattern *) let get_args_tuple arity p rem = @@ -2669,10 +2583,6 @@ and do_compile_matching repr partial ctx arg pmh = partial divide_array (combine_array names pat.pat_loc arg partial) ctx pm - | Tpat_lazy _ -> - compile_no_test - (divide_lazy (normalize_pat pat)) - ctx_combine repr partial ctx pm | Tpat_variant (_, _, row) -> let names = None in compile_test @@ -2720,8 +2630,7 @@ let find_in_pat pred = pred p.pat_desc || match p.pat_desc with - | Tpat_alias (p, _, _) | Tpat_variant (_, Some p, _) | Tpat_lazy p -> - find_rec p + | Tpat_alias (p, _, _) | Tpat_variant (_, Some p, _) -> find_rec p | Tpat_tuple ps | Tpat_construct (_, _, ps) | Tpat_array ps -> List.exists find_rec ps | Tpat_record (lpats, _) -> @@ -2732,15 +2641,6 @@ let find_in_pat pred = in find_rec -let is_lazy_pat = function - | Tpat_lazy _ -> true - | Tpat_alias _ | Tpat_variant _ | Tpat_record _ | Tpat_tuple _ - | Tpat_construct _ | Tpat_array _ | Tpat_or _ | Tpat_constant _ | Tpat_var _ - | Tpat_any -> - false - -let is_lazy p = find_in_pat is_lazy_pat p - let have_mutable_field p = match p with | Tpat_record (lps, _) -> @@ -2750,9 +2650,8 @@ let have_mutable_field p = | Mutable -> true | Immutable -> false) lps - | Tpat_alias _ | Tpat_variant _ | Tpat_lazy _ | Tpat_tuple _ - | Tpat_construct _ | Tpat_array _ | Tpat_or _ | Tpat_constant _ | Tpat_var _ - | Tpat_any -> + | Tpat_alias _ | Tpat_variant _ | Tpat_tuple _ | Tpat_construct _ + | Tpat_array _ | Tpat_or _ | Tpat_constant _ | Tpat_var _ | Tpat_any -> false let is_mutable p = find_in_pat have_mutable_field p @@ -2762,7 +2661,7 @@ let is_mutable p = find_in_pat have_mutable_field p 2. And there are guards or lazy patterns. *) -let check_partial is_mutable is_lazy pat_act_list = function +let check_partial is_mutable pat_act_list = function | Partial -> Partial | Total -> if @@ -2770,14 +2669,13 @@ let check_partial is_mutable is_lazy pat_act_list = function || (* allow empty case list *) List.exists - (fun (pats, lam) -> is_mutable pats && (is_guarded lam || is_lazy pats)) + (fun (pats, lam) -> is_mutable pats && is_guarded lam) pat_act_list then Partial else Total -let check_partial_list = - check_partial (List.exists is_mutable) (List.exists is_lazy) -let check_partial = check_partial is_mutable is_lazy +let check_partial_list = check_partial (List.exists is_mutable) +let check_partial = check_partial is_mutable (* have toplevel handler when appropriate *) diff --git a/compiler/ml/matching.mli b/compiler/ml/matching.mli index 4f86b6b045..43d1d2cec3 100644 --- a/compiler/ml/matching.mli +++ b/compiler/ml/matching.mli @@ -71,8 +71,6 @@ val flatten_pattern : int -> pattern -> pattern list val expand_stringswitch : Location.t -> lambda -> (string * lambda) list -> lambda option -> lambda -val inline_lazy_force : lambda -> Location.t -> lambda - (* To be set by Lam_compile *) val names_from_construct_pattern : (pattern -> Ast_untagged_variants.switch_names option) ref diff --git a/compiler/ml/parmatch.ml b/compiler/ml/parmatch.ml index 27705031fe..51f91f02ab 100644 --- a/compiler/ml/parmatch.ml +++ b/compiler/ml/parmatch.ml @@ -166,8 +166,7 @@ let all_coherent column = | Tpat_record ([], _), Tpat_record (_, _) | Tpat_record (_, _), Tpat_record ([], _) | Tpat_variant _, Tpat_variant _ - | Tpat_array _, Tpat_array _ - | Tpat_lazy _, Tpat_lazy _ -> + | Tpat_array _, Tpat_array _ -> true | _, _ -> false in @@ -282,56 +281,51 @@ let records_args l1 l2 = in combine [] [] l1 l2 -module Compat (Constr : sig - val equal : - Types.constructor_description -> Types.constructor_description -> bool -end) = -struct - let rec compat p q = +module Compat = struct + type eq_cd = constructor_description -> constructor_description -> bool + + let rec compat ~(equal_cd : eq_cd) p q = match (p.pat_desc, q.pat_desc) with (* Variables match any value *) | (Tpat_any | Tpat_var _), _ | _, (Tpat_any | Tpat_var _) -> true (* Structural induction *) - | Tpat_alias (p, _, _), _ -> compat p q - | _, Tpat_alias (q, _, _) -> compat p q - | Tpat_or (p1, p2, _), _ -> compat p1 q || compat p2 q - | _, Tpat_or (q1, q2, _) -> compat p q1 || compat p q2 + | Tpat_alias (p, _, _), _ -> compat ~equal_cd p q + | _, Tpat_alias (q, _, _) -> compat ~equal_cd p q + | Tpat_or (p1, p2, _), _ -> compat ~equal_cd p1 q || compat ~equal_cd p2 q + | _, Tpat_or (q1, q2, _) -> compat ~equal_cd p q1 || compat ~equal_cd p q2 (* Constructors, with special case for extension *) | Tpat_construct (_, c1, ps1), Tpat_construct (_, c2, ps2) -> - Constr.equal c1 c2 && compats ps1 ps2 + equal_cd c1 c2 && compats ~equal_cd ps1 ps2 (* More standard stuff *) | Tpat_variant (l1, op1, _), Tpat_variant (l2, op2, _) -> - l1 = l2 && ocompat op1 op2 + l1 = l2 && ocompat ~equal_cd op1 op2 | Tpat_constant c1, Tpat_constant c2 -> const_compare c1 c2 = 0 - | Tpat_tuple ps, Tpat_tuple qs -> compats ps qs - | Tpat_lazy p, Tpat_lazy q -> compat p q + | Tpat_tuple ps, Tpat_tuple qs -> compats ~equal_cd ps qs | Tpat_record (l1, _), Tpat_record (l2, _) -> let ps, qs = records_args l1 l2 in - compats ps qs + compats ~equal_cd ps qs | Tpat_array ps, Tpat_array qs -> - List.length ps = List.length qs && compats ps qs + List.length ps = List.length qs && compats ~equal_cd ps qs | _, _ -> false - and ocompat op oq = + and ocompat ~equal_cd op oq = match (op, oq) with | None, None -> true - | Some p, Some q -> compat p q + | Some p, Some q -> compat ~equal_cd p q | None, Some _ | Some _, None -> false - and compats ps qs = + and compats ~equal_cd ps qs = match (ps, qs) with | [], [] -> true - | p :: ps, q :: qs -> compat p q && compats ps qs + | p :: ps, q :: qs -> compat ~equal_cd p q && compats ~equal_cd ps qs | _, _ -> false end -module SyntacticCompat = Compat (struct - let equal c1 c2 = Types.equal_tag c1.cstr_tag c2.cstr_tag -end) +let equal_tag c1 c2 = Types.equal_tag c1.cstr_tag c2.cstr_tag -let compat = SyntacticCompat.compat +let compat = Compat.compat ~equal_cd:equal_tag -and compats = SyntacticCompat.compats +and compats = Compat.compats ~equal_cd:equal_tag (* Due to (potential) rebinding, two extension constructors of the same arity type may equal *) @@ -417,7 +411,6 @@ let rec pretty_val ppf v = let elision_mark _ = () in fprintf ppf "@[{%a%t}@]" pretty_lvals filtered_lvs elision_mark) | Tpat_array vs -> fprintf ppf "@[[%a]@]" (pretty_vals ",") vs - | Tpat_lazy v -> fprintf ppf "@[<2>lazy@ %a@]" pretty_arg v | Tpat_alias (v, x, _) -> fprintf ppf "@[(%a@ as %a)@]" pretty_val v Ident.print x | Tpat_or (v, w, _) -> fprintf ppf "@[%a | @,%a@]" pretty_or v pretty_or w) @@ -493,7 +486,6 @@ let simple_match p1 p2 = Types.equal_tag c1.cstr_tag c2.cstr_tag | Tpat_variant (l1, _, _), Tpat_variant (l2, _, _) -> l1 = l2 | Tpat_constant c1, Tpat_constant c2 -> const_compare c1 c2 = 0 - | Tpat_lazy _, Tpat_lazy _ -> true | Tpat_record _, Tpat_record _ -> true | Tpat_tuple p1s, Tpat_tuple p2s | Tpat_array p1s, Tpat_array p2s -> List.length p1s = List.length p2s @@ -579,7 +571,6 @@ let rec simple_match_args p1 p2 = | Tpat_tuple args -> args | Tpat_record (args, _) -> extract_fields (record_arg p1) args | Tpat_array args -> args - | Tpat_lazy arg -> [arg] | Tpat_any | Tpat_var _ -> ( match p1.pat_desc with | Tpat_construct (_, _, args) -> omega_list args @@ -587,7 +578,6 @@ let rec simple_match_args p1 p2 = | Tpat_tuple args -> omega_list args | Tpat_record (args, _) -> omega_list args | Tpat_array args -> omega_list args - | Tpat_lazy _ -> [omega] | _ -> []) | _ -> [] @@ -617,7 +607,6 @@ let rec normalize_pat q = ( List.map (fun (lid, lbl, _, opt) -> (lid, lbl, omega, opt)) largs, closed )) q.pat_type q.pat_env - | Tpat_lazy _ -> make_pat (Tpat_lazy omega) q.pat_type q.pat_env | Tpat_or _ -> fatal_error "Parmatch.normalize_pat" (* @@ -634,7 +623,6 @@ let discr_pat q pss = acc_pat acc ((p1 :: ps) :: (p2 :: ps) :: pss) | ({pat_desc = Tpat_any | Tpat_var _} :: _) :: pss -> acc_pat acc pss | (({pat_desc = Tpat_tuple _} as p) :: _) :: _ -> normalize_pat p - | (({pat_desc = Tpat_lazy _} as p) :: _) :: _ -> normalize_pat p | (({pat_desc = Tpat_record (largs, closed)} as p) :: _) :: pss -> let new_omegas = List.fold_right @@ -702,10 +690,6 @@ let do_set_args erase_mutable q r = | _ -> assert false in make_pat (Tpat_variant (l, arg, row)) q.pat_type q.pat_env :: rest - | {pat_desc = Tpat_lazy _omega} -> ( - match r with - | arg :: rest -> make_pat (Tpat_lazy arg) q.pat_type q.pat_env :: rest - | _ -> fatal_error "Parmatch.do_set_args (lazy)") | {pat_desc = Tpat_array omegas} -> let args, rest = read_args omegas r in make_pat (Tpat_array args) q.pat_type q.pat_env :: rest @@ -798,7 +782,7 @@ let filter_all pat0 pss = filter_omega (filter_rec (match pat0.pat_desc with - | Tpat_record _ | Tpat_tuple _ | Tpat_lazy _ -> [(pat0, [])] + | Tpat_record _ | Tpat_tuple _ -> [(pat0, [])] | _ -> []) pss) pss @@ -892,7 +876,6 @@ let full_match closing env = | ({pat_desc = Tpat_tuple _}, _) :: _ -> true | ({pat_desc = Tpat_record _}, _) :: _ -> true | ({pat_desc = Tpat_array _}, _) :: _ -> false - | ({pat_desc = Tpat_lazy _}, _) :: _ -> true | ({pat_desc = Tpat_any | Tpat_var _ | Tpat_alias _ | Tpat_or _}, _) :: _ | [] -> assert false @@ -912,7 +895,7 @@ let should_extend ext env = Path.same path ext | Tpat_construct (_, {cstr_tag = Cstr_extension _}, _) -> false | Tpat_constant _ | Tpat_tuple _ | Tpat_variant _ | Tpat_record _ - | Tpat_array _ | Tpat_lazy _ -> + | Tpat_array _ -> false | Tpat_any | Tpat_var _ | Tpat_alias _ | Tpat_or _ -> assert false)) @@ -1187,7 +1170,6 @@ let rec has_instance p = | Tpat_construct (_, _, ps) | Tpat_tuple ps | Tpat_array ps -> has_instances ps | Tpat_record (lps, _) -> has_instances (List.map (fun (_, _, x, _) -> x) lps) - | Tpat_lazy p -> has_instance p and has_instances = function | [] -> true @@ -1790,7 +1772,6 @@ let rec le_pat p q = | Tpat_variant (l1, None, _r1), Tpat_variant (l2, None, _) -> l1 = l2 | Tpat_variant (_, _, _), Tpat_variant (_, _, _) -> false | Tpat_tuple ps, Tpat_tuple qs -> le_pats ps qs - | Tpat_lazy p, Tpat_lazy q -> le_pat p q | Tpat_record (l1, _), Tpat_record (l2, _) -> let ps, qs = records_args l1 l2 in le_pats ps qs @@ -1829,9 +1810,6 @@ let rec lub p q = | Tpat_tuple ps, Tpat_tuple qs -> let rs = lubs ps qs in make_pat (Tpat_tuple rs) p.pat_type p.pat_env - | Tpat_lazy p, Tpat_lazy q -> - let r = lub p q in - make_pat (Tpat_lazy r) p.pat_type p.pat_env | Tpat_construct (lid, c1, ps1), Tpat_construct (_, c2, ps2) when Types.equal_tag c1.cstr_tag c2.cstr_tag -> let rs = lubs ps1 ps2 in @@ -2013,7 +1991,6 @@ module Conv = struct in mkpat (Ppat_record (fields, Open)) | Tpat_array lst -> mkpat (Ppat_array (List.map loop lst)) - | Tpat_lazy p -> mkpat (Ppat_lazy (loop p)) in let ps = loop typed in (ps, constrs, labels) @@ -2146,7 +2123,6 @@ let rec collect_paths_from_pat r p = collect_paths_from_pat r p | Tpat_or (p1, p2, _) -> collect_paths_from_pat (collect_paths_from_pat r p1) p2 - | Tpat_lazy p -> collect_paths_from_pat r p (* Actual fragile check @@ -2248,7 +2224,7 @@ let inactive ~partial pat = | Total -> let rec loop pat = match pat.pat_desc with - | Tpat_lazy _ | Tpat_array _ -> false + | Tpat_array _ -> false | Tpat_any | Tpat_var _ | Tpat_variant (_, None, _) -> true | Tpat_constant c -> ( match c with diff --git a/compiler/ml/parmatch.mli b/compiler/ml/parmatch.mli index a5ca1d436c..201abd05ff 100644 --- a/compiler/ml/parmatch.mli +++ b/compiler/ml/parmatch.mli @@ -18,7 +18,6 @@ open Asttypes open Typedtree open Types -val pretty_const : constant -> string val top_pretty : Format.formatter -> pattern -> unit val pretty_pat : pattern -> unit val pretty_line : pattern list -> unit @@ -38,17 +37,12 @@ val const_compare : constant -> constant -> int val le_pat : pattern -> pattern -> bool val le_pats : pattern list -> pattern list -> bool -(* Exported compatibility functor, abstracted over constructor equality *) -module Compat : functor - (Constr : sig - val equal : - Types.constructor_description -> Types.constructor_description -> bool - end) - -> sig - val compat : pattern -> pattern -> bool - val compats : pattern list -> pattern list -> bool +(* Exported compatibility, abstracted over constructor equality *) +module Compat : sig + type eq_cd = constructor_description -> constructor_description -> bool + val compat : equal_cd:eq_cd -> pattern -> pattern -> bool + val compats : equal_cd:eq_cd -> pattern list -> pattern list -> bool end -[@@warning "-67"] exception Empty val lub : pattern -> pattern -> pattern @@ -61,7 +55,6 @@ val get_mins : ('a -> 'a -> bool) -> 'a list -> 'a list (_,_)::p1::p2::rem -> (p1, p2)::rem The second one will replace mutable arguments by '_' *) -val set_args : pattern -> pattern list -> pattern list val set_args_erase_mutable : pattern -> pattern list -> pattern list val pat_of_constr : pattern -> constructor_description -> pattern diff --git a/compiler/ml/parsetree.ml b/compiler/ml/parsetree.ml index 7374827192..24d5b725c8 100644 --- a/compiler/ml/parsetree.ml +++ b/compiler/ml/parsetree.ml @@ -193,7 +193,6 @@ and pattern_desc = | Ppat_or of pattern * pattern (* P1 | P2 *) | Ppat_constraint of pattern * core_type (* (P : T) *) | Ppat_type of Longident.t loc (* #tconst *) - | Ppat_lazy of pattern (* lazy P *) | Ppat_unpack of string loc (* (module P) Note: (module P : S) is represented as @@ -302,7 +301,6 @@ and expression_desc = (* assert E Note: "assert false" is treated in a special way by the type-checker. *) - | Pexp_lazy of expression (* lazy E *) | Pexp_newtype of string loc * expression (* fun (type t) -> E *) | Pexp_pack of module_expr (* (module ME) diff --git a/compiler/ml/pprintast.ml b/compiler/ml/pprintast.ml index ebbe4ea359..738f67764f 100644 --- a/compiler/ml/pprintast.ml +++ b/compiler/ml/pprintast.ml @@ -478,7 +478,6 @@ and simple_pattern ctxt (f : Format.formatter) (x : pattern) : unit = | Ppat_variant (l, None) -> pp f "`%s" l | Ppat_constraint (p, ct) -> pp f "@[<2>(%a@;:@;%a)@]" (pattern1 ctxt) p (core_type ctxt) ct - | Ppat_lazy p -> pp f "@[<2>(lazy@;%a)@]" (pattern1 ctxt) p | Ppat_exception p -> pp f "@[<2>exception@;%a@]" (pattern1 ctxt) p | Ppat_extension e -> extension ctxt f e | Ppat_open (lid, p) -> @@ -716,7 +715,6 @@ and expression ctxt f x = (extension_constructor ctxt) cd (expression ctxt) e | Pexp_assert e -> pp f "@[assert@ %a@]" (simple_expr ctxt) e - | Pexp_lazy e -> pp f "@[lazy@ %a@]" (simple_expr ctxt) e | Pexp_open (ovf, lid, e) -> pp f "@[<2>let open%s %a in@;%a@]" (override ovf) longident_loc lid (expression ctxt) e diff --git a/compiler/ml/printast.ml b/compiler/ml/printast.ml index 66a53135c1..2586c68b2b 100644 --- a/compiler/ml/printast.ml +++ b/compiler/ml/printast.ml @@ -207,9 +207,6 @@ and pattern i ppf x = line i ppf "Ppat_or\n"; pattern i ppf p1; pattern i ppf p2 - | Ppat_lazy p -> - line i ppf "Ppat_lazy\n"; - pattern i ppf p | Ppat_constraint (p, ct) -> line i ppf "Ppat_constraint\n"; pattern i ppf p; @@ -331,9 +328,6 @@ and expression i ppf x = | Pexp_assert e -> line i ppf "Pexp_assert\n"; expression i ppf e - | Pexp_lazy e -> - line i ppf "Pexp_lazy\n"; - expression i ppf e | Pexp_newtype (s, e) -> line i ppf "Pexp_newtype \"%s\"\n" s.txt; expression i ppf e diff --git a/compiler/ml/printlambda.ml b/compiler/ml/printlambda.ml index 27f8873df1..13928e3418 100644 --- a/compiler/ml/printlambda.ml +++ b/compiler/ml/printlambda.ml @@ -96,7 +96,6 @@ let print_taginfo ppf = function | Blk_module ss -> fprintf ppf "[%s]" (String.concat ";" ss) | Blk_some -> fprintf ppf "some" | Blk_some_not_nested -> fprintf ppf "some_not_nested" - | Blk_lazy_general -> fprintf ppf "lazy_general" | Blk_module_export _ -> fprintf ppf "module/exports" | Blk_record_inlined {fields = ss} -> fprintf ppf "[%s]" (String.concat ";" (List.map fst (Array.to_list ss))) diff --git a/compiler/ml/printtyped.ml b/compiler/ml/printtyped.ml index 6bdd794d97..a17ee3b80f 100644 --- a/compiler/ml/printtyped.ml +++ b/compiler/ml/printtyped.ml @@ -241,10 +241,7 @@ and pattern i ppf x = | Tpat_or (p1, p2, _) -> line i ppf "Tpat_or\n"; pattern i ppf p1; - pattern i ppf p2 - | Tpat_lazy p -> - line i ppf "Tpat_lazy\n"; - pattern i ppf p) + pattern i ppf p2) and expression_extra i ppf x attrs = match x with @@ -367,9 +364,6 @@ and expression i ppf x = | Texp_assert e -> line i ppf "Texp_assert"; expression i ppf e - | Texp_lazy e -> - line i ppf "Texp_lazy"; - expression i ppf e | Texp_pack me -> line i ppf "Texp_pack"; module_expr i ppf me diff --git a/compiler/ml/rec_check.ml b/compiler/ml/rec_check.ml index 43f13b4e2c..3d016a7438 100644 --- a/compiler/ml/rec_check.ml +++ b/compiler/ml/rec_check.ml @@ -160,7 +160,6 @@ let rec pattern_variables : Typedtree.pattern -> Ident.t list = List.concat (List.map (fun (_, _, p, _) -> pattern_variables p) fields) | Tpat_array pats -> List.concat (List.map pattern_variables pats) | Tpat_or (l, r, _) -> pattern_variables l @ pattern_variables r - | Tpat_lazy p -> pattern_variables p open Rec_context open Asttypes @@ -197,8 +196,8 @@ let rec classify_expression : Typedtree.expression -> sd = classify_expression e | Texp_ident _ | Texp_for _ | Texp_constant _ | Texp_tuple _ | Texp_array _ | Texp_construct _ | Texp_variant _ | Texp_record _ | Texp_setfield _ - | Texp_while _ | Texp_pack _ | Texp_function _ | Texp_lazy _ - | Texp_extension_constructor _ -> + | Texp_while _ | Texp_pack _ | Texp_function _ | Texp_extension_constructor _ + -> Static | Texp_apply {funct = {exp_desc = Texp_ident (_, _, vd)}} when is_ref vd -> Static @@ -291,10 +290,6 @@ let rec expression : Env.env -> Typedtree.expression -> Use.t = Use.join (expression env e) (list case env cases) | Texp_function {case = case_} -> Use.delay (list (case ~scrutinee:Use.empty) env [case_]) - | Texp_lazy e -> ( - match Typeopt.classify_lazy_argument e with - | `Constant_or_function | `Identifier _ | `Float -> expression env e - | `Other -> Use.delay (expression env e)) | Texp_extension_constructor _ -> Use.empty and option : 'a. (Env.env -> 'a -> Use.t) -> Env.env -> 'a option -> Use.t = @@ -431,7 +426,6 @@ and is_destructuring_pattern : Typedtree.pattern -> bool = | Tpat_array _ -> true | Tpat_or (l, r, _) -> is_destructuring_pattern l || is_destructuring_pattern r - | Tpat_lazy _ -> true let check_recursive_expression idlist expr = let ty = expression (build_unguarded_env idlist) expr in diff --git a/compiler/ml/tast_iterator.ml b/compiler/ml/tast_iterator.ml index 3220aa87fe..356df81a95 100644 --- a/compiler/ml/tast_iterator.ml +++ b/compiler/ml/tast_iterator.ml @@ -135,7 +135,6 @@ let pat sub {pat_extra; pat_desc; pat_env; _} = sub.pat sub p1; sub.pat sub p2 | Tpat_alias (p, _, _) -> sub.pat sub p - | Tpat_lazy p -> sub.pat sub p let expr sub {exp_extra; exp_desc; exp_env; _} = let extra = function @@ -202,7 +201,6 @@ let expr sub {exp_extra; exp_desc; exp_env; _} = sub.extension_constructor sub cd; sub.expr sub exp | Texp_assert exp -> sub.expr sub exp - | Texp_lazy exp -> sub.expr sub exp | Texp_pack mexpr -> sub.module_expr sub mexpr | Texp_extension_constructor _ -> () diff --git a/compiler/ml/tast_mapper.ml b/compiler/ml/tast_mapper.ml index c2e33e7b4f..09c5dc8b8c 100644 --- a/compiler/ml/tast_mapper.ml +++ b/compiler/ml/tast_mapper.ml @@ -176,7 +176,6 @@ let pat sub x = | Tpat_array l -> Tpat_array (List.map (sub.pat sub) l) | Tpat_or (p1, p2, rd) -> Tpat_or (sub.pat sub p1, sub.pat sub p2, rd) | Tpat_alias (p, id, s) -> Tpat_alias (sub.pat sub p, id, s) - | Tpat_lazy p -> Tpat_lazy (sub.pat sub p) in {x with pat_extra; pat_desc; pat_env} @@ -251,7 +250,6 @@ let expr sub x = | Texp_letexception (cd, exp) -> Texp_letexception (sub.extension_constructor sub cd, sub.expr sub exp) | Texp_assert exp -> Texp_assert (sub.expr sub exp) - | Texp_lazy exp -> Texp_lazy (sub.expr sub exp) | Texp_pack mexpr -> Texp_pack (sub.module_expr sub mexpr) | Texp_extension_constructor _ as e -> e in diff --git a/compiler/ml/translcore.ml b/compiler/ml/translcore.ml index e9f2400c1f..fbfe836d9f 100644 --- a/compiler/ml/translcore.ml +++ b/compiler/ml/translcore.ml @@ -925,11 +925,6 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda = | Texp_assert cond -> if !Clflags.noassert then lambda_unit else Lifthenelse (transl_exp cond, lambda_unit, assert_failed e) - | Texp_lazy e -> - (* when e needs no computation (constants, identifiers, ...), we - optimize the translation just as Lazy.lazy_from_val would - do *) - Lprim (Pmakeblock Blk_lazy_general, [transl_exp e], e.exp_loc) and transl_list expr_list = List.map transl_exp expr_list diff --git a/compiler/ml/typecore.ml b/compiler/ml/typecore.ml index dd69ad1ad2..bb96310964 100644 --- a/compiler/ml/typecore.ml +++ b/compiler/ml/typecore.ml @@ -154,7 +154,6 @@ let iter_expression f e = List.iter (fun (_, e, _) -> expr e) iel | Pexp_open (_, _, e) | Pexp_newtype (_, e) - | Pexp_lazy e | Pexp_assert e | Pexp_send (e, _) | Pexp_constraint (e, _) @@ -517,8 +516,7 @@ let rec build_as_type env p = | Some row -> let row = row_repr row in newty (Tvariant {row with row_closed = false; row_more = newvar ()})) - | Tpat_any | Tpat_var _ | Tpat_constant _ | Tpat_array _ | Tpat_lazy _ -> - p.pat_type + | Tpat_any | Tpat_var _ | Tpat_constant _ | Tpat_array _ -> p.pat_type let build_or_pat env loc lid = let path, decl = Typetexp.find_type env lid.loc lid.txt in @@ -1601,20 +1599,6 @@ and type_pat_aux ~constrs ~labels ~no_existentials ~mode ~explode ~env sp with Error _ -> set_state state env; type_pat ~mode sp2 expected_ty k)) - | Ppat_lazy sp1 -> - let nv = newvar () in - unify_pat_types loc !env (instance_def (Predef.type_lazy_t nv)) expected_ty; - (* do not explode under lazy: PR#7421 *) - type_pat ~explode:0 sp1 nv (fun p1 -> - rp k - { - pat_desc = Tpat_lazy p1; - pat_loc = loc; - pat_extra = []; - pat_type = expected_ty; - pat_attributes = sp.ppat_attributes; - pat_env = !env; - }) | Ppat_constraint (sp, sty) -> (* Separate when not already separated by !principal *) let separate = true in @@ -1818,7 +1802,6 @@ let rec is_nonexpansive exp = is_nonexpansive ifso && is_nonexpansive_opt ifnot | Texp_sequence (_e1, e2) -> is_nonexpansive e2 (* PR#4354 *) (* Note: nonexpansive only means no _observable_ side effects *) - | Texp_lazy e -> is_nonexpansive e | Texp_letmodule (_, _, mexp, e) -> is_nonexpansive_mod mexp && is_nonexpansive e | Texp_pack mexp -> is_nonexpansive_mod mexp @@ -2055,8 +2038,7 @@ let iter_ppat f p = | Ppat_exception p | Ppat_alias (p, _) | Ppat_open (_, p) - | Ppat_constraint (p, _) - | Ppat_lazy p -> + | Ppat_constraint (p, _) -> f p | Ppat_record (args, _flag) -> List.iter (fun (_, p, _) -> f p) args @@ -3074,20 +3056,6 @@ and type_expect_ ?type_clash_context ?in_function ?(recarg = Rejected) env sexp exp_attributes = sexp.pexp_attributes; exp_env = env; } - | Pexp_lazy e -> - let ty = newgenvar () in - let to_unify = Predef.type_lazy_t ty in - unify_exp_types loc env to_unify ty_expected; - let arg = type_expect env e ty in - re - { - exp_desc = Texp_lazy arg; - exp_loc = loc; - exp_extra = []; - exp_type = instance env ty_expected; - exp_attributes = sexp.pexp_attributes; - exp_env = env; - } | Pexp_newtype ({txt = name}, sbody) -> let ty = newvar () in (* remember original level *) diff --git a/compiler/ml/typedtree.ml b/compiler/ml/typedtree.ml index f9769ee13b..55707631dd 100644 --- a/compiler/ml/typedtree.ml +++ b/compiler/ml/typedtree.ml @@ -54,7 +54,6 @@ and pattern_desc = * closed_flag | Tpat_array of pattern list | Tpat_or of pattern * pattern * row_desc option - | Tpat_lazy of pattern and expression = { exp_desc: expression_desc; @@ -122,7 +121,6 @@ and expression_desc = | Texp_letmodule of Ident.t * string loc * module_expr * expression | Texp_letexception of extension_constructor * expression | Texp_assert of expression - | Texp_lazy of expression | Texp_pack of module_expr | Texp_extension_constructor of Longident.t loc * Path.t @@ -419,7 +417,6 @@ let iter_pattern_desc f = function | Tpat_or (p1, p2, _) -> f p1; f p2 - | Tpat_lazy p -> f p | Tpat_any | Tpat_var _ | Tpat_constant _ -> () let map_pattern_desc f d = @@ -430,7 +427,6 @@ let map_pattern_desc f d = Tpat_record (List.map (fun (lid, l, p, o) -> (lid, l, f p, o)) lpats, closed) | Tpat_construct (lid, c, pats) -> Tpat_construct (lid, c, List.map f pats) | Tpat_array pats -> Tpat_array (List.map f pats) - | Tpat_lazy p1 -> Tpat_lazy (f p1) | Tpat_variant (x1, Some p1, x2) -> Tpat_variant (x1, Some (f p1), x2) | Tpat_or (p1, p2, path) -> Tpat_or (f p1, f p2, path) | Tpat_var _ | Tpat_constant _ | Tpat_any | Tpat_variant (_, None, _) -> d diff --git a/compiler/ml/typedtree.mli b/compiler/ml/typedtree.mli index f3368c9539..bac990c35e 100644 --- a/compiler/ml/typedtree.mli +++ b/compiler/ml/typedtree.mli @@ -97,7 +97,6 @@ and pattern_desc = [row_desc] = [Some _] when translating [Ppat_type _], [None] otherwise. *) - | Tpat_lazy of pattern (** lazy P *) and expression = { exp_desc: expression_desc; @@ -223,7 +222,6 @@ and expression_desc = | Texp_letmodule of Ident.t * string loc * module_expr * expression | Texp_letexception of extension_constructor * expression | Texp_assert of expression - | Texp_lazy of expression | Texp_pack of module_expr | Texp_extension_constructor of Longident.t loc * Path.t diff --git a/compiler/ml/typedtreeIter.ml b/compiler/ml/typedtreeIter.ml index e0fe1e228e..a7597ea8d7 100644 --- a/compiler/ml/typedtreeIter.ml +++ b/compiler/ml/typedtreeIter.ml @@ -201,8 +201,7 @@ end = struct | Tpat_array list -> List.iter iter_pattern list | Tpat_or (p1, p2, _) -> iter_pattern p1; - iter_pattern p2 - | Tpat_lazy p -> iter_pattern p); + iter_pattern p2); Iter.leave_pattern pat and option f x = @@ -291,7 +290,6 @@ end = struct iter_extension_constructor cd; iter_expression exp | Texp_assert exp -> iter_expression exp - | Texp_lazy exp -> iter_expression exp | Texp_pack mexpr -> iter_module_expr mexpr | Texp_extension_constructor _ -> ()); Iter.leave_expression exp diff --git a/compiler/ml/typeopt.ml b/compiler/ml/typeopt.ml index d2ca2aa55f..a1e5e4fabd 100644 --- a/compiler/ml/typeopt.ml +++ b/compiler/ml/typeopt.ml @@ -16,8 +16,6 @@ (* Auxiliaries for type-based optimizations, e.g. array kinds *) open Types -open Asttypes -open Typedtree open Lambda let scrape_ty env ty = @@ -105,64 +103,3 @@ let is_base_type env ty base_ty_path = let maybe_pointer_type env ty = if Ctype.maybe_pointer_type env ty then Pointer else Immediate - -type classification = - | Int - | Float - | Lazy - | Addr (* anything except a float or a lazy *) - | Any - -let classify env ty = - let ty = scrape_ty env ty in - if maybe_pointer_type env ty = Immediate then Int - else - match ty.desc with - | Tvar _ | Tunivar _ -> Any - | Tconstr (p, _args, _abbrev) -> ( - if Path.same p Predef.path_float then Float - else if Path.same p Predef.path_lazy_t then Lazy - else if Path.same p Predef.path_string || Path.same p Predef.path_array - then Addr - else - try - match (Env.find_type p env).type_kind with - | Type_abstract -> Any - | Type_record _ | Type_variant _ | Type_open -> Addr - with Not_found -> - (* This can happen due to e.g. missing -I options, - causing some .cmi files to be unavailable. - Maybe we should emit a warning. *) - Any) - | Tarrow _ | Ttuple _ | Tpackage _ | Tobject _ | Tnil | Tvariant _ -> Addr - | Tlink _ | Tsubst _ | Tpoly _ | Tfield _ -> assert false - -(** Whether a forward block is needed for a lazy thunk on a value, i.e. - if the value can be represented as a float/forward/lazy *) -let lazy_val_requires_forward env ty = - match classify env ty with - | Any | Lazy -> true - | Float (*-> Config.flat_float_array*) | Addr | Int -> false - -(** The compilation of the expression [lazy e] depends on the form of e: - constants, floats and identifiers are optimized. The optimization must be - taken into account when determining whether a recursive binding is safe. *) -let classify_lazy_argument : - Typedtree.expression -> - [ `Constant_or_function - | `Float - | `Identifier of [`Forward_value | `Other] - | `Other ] = - fun e -> - match e.exp_desc with - | Texp_constant - ( Const_int _ | Const_char _ | Const_string _ | Const_int32 _ - | Const_int64 _ | Const_bigint _ ) - | Texp_function _ - | Texp_construct (_, {cstr_arity = 0}, _) -> - `Constant_or_function - | Texp_constant (Const_float _) -> `Float - | Texp_ident _ when lazy_val_requires_forward e.exp_env e.exp_type -> - `Identifier `Forward_value - | Texp_ident _ -> `Identifier `Other - | _ -> `Other diff --git a/compiler/ml/typeopt.mli b/compiler/ml/typeopt.mli index 38b667c273..f51b0227f0 100644 --- a/compiler/ml/typeopt.mli +++ b/compiler/ml/typeopt.mli @@ -21,11 +21,4 @@ val is_base_type : Env.t -> Types.type_expr -> Path.t -> bool val maybe_pointer_type : Env.t -> Types.type_expr -> Lambda.immediate_or_pointer -val classify_lazy_argument : - Typedtree.expression -> - [ `Constant_or_function - | `Float - | `Identifier of [`Forward_value | `Other] - | `Other ] - val type_cannot_contain_undefined : Types.type_expr -> Env.t -> bool diff --git a/compiler/syntax/src/res_ast_debugger.ml b/compiler/syntax/src/res_ast_debugger.ml index 70f1e298bf..55ac14bd09 100644 --- a/compiler/syntax/src/res_ast_debugger.ml +++ b/compiler/syntax/src/res_ast_debugger.ml @@ -691,7 +691,6 @@ module SexpAst = struct expression expr; ] | Pexp_assert expr -> Sexp.list [Sexp.atom "Pexp_assert"; expression expr] - | Pexp_lazy expr -> Sexp.list [Sexp.atom "Pexp_lazy"; expression expr] | Pexp_newtype (lbl, expr) -> Sexp.list [Sexp.atom "Pexp_newtype"; string lbl.Asttypes.txt; expression expr] @@ -818,7 +817,6 @@ module SexpAst = struct Sexp.list [Sexp.atom "Ppat_constraint"; pattern p; core_type typexpr] | Ppat_type longident_loc -> Sexp.list [Sexp.atom "Ppat_type"; longident longident_loc.Location.txt] - | Ppat_lazy p -> Sexp.list [Sexp.atom "Ppat_lazy"; pattern p] | Ppat_unpack string_loc -> Sexp.list [Sexp.atom "Ppat_unpack"; string string_loc.Location.txt] | Ppat_exception p -> Sexp.list [Sexp.atom "Ppat_exception"; pattern p] diff --git a/compiler/syntax/src/res_comments_table.ml b/compiler/syntax/src/res_comments_table.ml index 7b84296c6d..867a579d4e 100644 --- a/compiler/syntax/src/res_comments_table.ml +++ b/compiler/syntax/src/res_comments_table.ml @@ -1158,7 +1158,7 @@ and walk_expression expr t comments = attach t.leading expr2.pexp_loc leading; walk_expression expr2 t inside; attach t.trailing expr2.pexp_loc trailing - | Pexp_assert expr | Pexp_lazy expr -> + | Pexp_assert expr -> if is_block_expr expr then walk_expression expr t comments else let leading, inside, trailing = partition_by_loc comments expr.pexp_loc in @@ -2092,7 +2092,7 @@ and walk_pattern pat t comments = attach t.leading typ.ptyp_loc before_typ; walk_core_type typ t inside_typ; attach t.trailing typ.ptyp_loc after_typ - | Ppat_lazy pattern | Ppat_exception pattern -> + | Ppat_exception pattern -> let leading, inside, trailing = partition_by_loc comments pattern.ppat_loc in diff --git a/compiler/syntax/src/res_parens.ml b/compiler/syntax/src/res_parens.ml index bdad87851e..8c08829461 100644 --- a/compiler/syntax/src/res_parens.ml +++ b/compiler/syntax/src/res_parens.ml @@ -50,9 +50,9 @@ let call_expr expr = Nothing | { pexp_desc = - ( Pexp_lazy _ | Pexp_assert _ | Pexp_fun _ | Pexp_newtype _ - | Pexp_constraint _ | Pexp_setfield _ | Pexp_match _ | Pexp_try _ - | Pexp_while _ | Pexp_for _ | Pexp_ifthenelse _ ); + ( Pexp_assert _ | Pexp_fun _ | Pexp_newtype _ | Pexp_constraint _ + | Pexp_setfield _ | Pexp_match _ | Pexp_try _ | Pexp_while _ | Pexp_for _ + | Pexp_ifthenelse _ ); } -> Parenthesized | _ when Ast_uncurried.expr_is_uncurried_fun expr -> Parenthesized @@ -101,10 +101,10 @@ let unary_expr_operand expr = Nothing | { pexp_desc = - ( Pexp_lazy _ | Pexp_assert _ | Pexp_fun _ | Pexp_newtype _ - | Pexp_constraint _ | Pexp_setfield _ - | Pexp_extension _ (* readability? maybe remove *) | Pexp_match _ - | Pexp_try _ | Pexp_while _ | Pexp_for _ | Pexp_ifthenelse _ ); + ( Pexp_assert _ | Pexp_fun _ | Pexp_newtype _ | Pexp_constraint _ + | Pexp_setfield _ | Pexp_extension _ (* readability? maybe remove *) + | Pexp_match _ | Pexp_try _ | Pexp_while _ | Pexp_for _ + | Pexp_ifthenelse _ ); } -> Parenthesized | _ when ParsetreeViewer.expr_is_await expr -> Parenthesized @@ -130,7 +130,7 @@ let binary_expr_operand ~is_lhs expr = | expr when ParsetreeViewer.is_binary_expression expr -> Parenthesized | expr when ParsetreeViewer.is_ternary_expr expr -> Parenthesized | expr when ParsetreeViewer.is_unary_bitnot_expression expr -> Parenthesized - | {pexp_desc = Pexp_lazy _ | Pexp_assert _} when is_lhs -> Parenthesized + | {pexp_desc = Pexp_assert _} when is_lhs -> Parenthesized | _ when ParsetreeViewer.expr_is_await expr -> Parenthesized | {Parsetree.pexp_attributes = attrs} -> if ParsetreeViewer.has_printable_attributes attrs then Parenthesized @@ -191,7 +191,7 @@ let binary_operator_inside_await_needs_parens operator = ParsetreeViewer.operator_precedence operator < ParsetreeViewer.operator_precedence "->" -let lazy_or_assert_or_await_expr_rhs ?(in_await = false) expr = +let assert_or_await_expr_rhs ?(in_await = false) expr = let opt_braces, _ = ParsetreeViewer.process_braces_attr expr in match opt_braces with | Some ({Location.loc = braces_loc}, _) -> Braced braces_loc @@ -221,9 +221,9 @@ let lazy_or_assert_or_await_expr_rhs ?(in_await = false) expr = Nothing | { pexp_desc = - ( Pexp_lazy _ | Pexp_assert _ | Pexp_fun _ | Pexp_newtype _ - | Pexp_constraint _ | Pexp_setfield _ | Pexp_match _ | Pexp_try _ - | Pexp_while _ | Pexp_for _ | Pexp_ifthenelse _ ); + ( Pexp_assert _ | Pexp_fun _ | Pexp_newtype _ | Pexp_constraint _ + | Pexp_setfield _ | Pexp_match _ | Pexp_try _ | Pexp_while _ | Pexp_for _ + | Pexp_ifthenelse _ ); } -> Parenthesized | _ when (not in_await) && ParsetreeViewer.expr_is_await expr -> @@ -266,10 +266,10 @@ let field_expr expr = Nothing | { pexp_desc = - ( Pexp_lazy _ | Pexp_assert _ - | Pexp_extension _ (* %extension.x vs (%extension).x *) | Pexp_fun _ - | Pexp_newtype _ | Pexp_constraint _ | Pexp_setfield _ | Pexp_match _ - | Pexp_try _ | Pexp_while _ | Pexp_for _ | Pexp_ifthenelse _ ); + ( Pexp_assert _ | Pexp_extension _ (* %extension.x vs (%extension).x *) + | Pexp_fun _ | Pexp_newtype _ | Pexp_constraint _ | Pexp_setfield _ + | Pexp_match _ | Pexp_try _ | Pexp_while _ | Pexp_for _ + | Pexp_ifthenelse _ ); } -> Parenthesized | _ when ParsetreeViewer.expr_is_await expr -> Parenthesized diff --git a/compiler/syntax/src/res_parens.mli b/compiler/syntax/src/res_parens.mli index c45c87a34f..02642646dd 100644 --- a/compiler/syntax/src/res_parens.mli +++ b/compiler/syntax/src/res_parens.mli @@ -11,8 +11,7 @@ val rhs_binary_expr_operand : string -> Parsetree.expression -> bool val flatten_operand_rhs : string -> Parsetree.expression -> bool val binary_operator_inside_await_needs_parens : string -> bool -val lazy_or_assert_or_await_expr_rhs : - ?in_await:bool -> Parsetree.expression -> kind +val assert_or_await_expr_rhs : ?in_await:bool -> Parsetree.expression -> kind val field_expr : Parsetree.expression -> kind diff --git a/compiler/syntax/src/res_printer.ml b/compiler/syntax/src/res_printer.ml index 72c53be91c..9e8c776774 100644 --- a/compiler/syntax/src/res_printer.ml +++ b/compiler/syntax/src/res_printer.ml @@ -2529,17 +2529,6 @@ and print_pattern ~state (p : Parsetree.pattern) cmt_tbl = (Doc.concat docs) | Ppat_extension ext -> print_extension ~state ~at_module_lvl:false ext cmt_tbl - | Ppat_lazy p -> - let needs_parens = - match p.ppat_desc with - | Ppat_or (_, _) | Ppat_alias (_, _) -> true - | _ -> false - in - let pat = - let p = print_pattern ~state p cmt_tbl in - if needs_parens then Doc.concat [Doc.text "("; p; Doc.text ")"] else p - in - Doc.concat [Doc.text "lazy "; pat] | Ppat_alias (p, alias_loc) -> let needs_parens = match p.ppat_desc with @@ -3382,15 +3371,6 @@ and print_expression ~state (e : Parsetree.expression) cmt_tbl = | Pexp_assert expr -> let expr = print_expression_with_comments ~state expr cmt_tbl in Doc.concat [Doc.text "assert("; expr; Doc.text ")"] - | Pexp_lazy expr -> - let rhs = - let doc = print_expression_with_comments ~state expr cmt_tbl in - match Parens.lazy_or_assert_or_await_expr_rhs expr with - | Parens.Parenthesized -> add_parens doc - | Braced braces -> print_braces doc expr braces - | Nothing -> doc - in - Doc.group (Doc.concat [Doc.text "lazy "; rhs]) | Pexp_open (_overrideFlag, _longidentLoc, _expr) -> print_expression_block ~state ~braces:true e cmt_tbl | Pexp_pack mod_expr -> @@ -3464,7 +3444,7 @@ and print_expression ~state (e : Parsetree.expression) cmt_tbl = in let rhs = match - Parens.lazy_or_assert_or_await_expr_rhs ~in_await:true + Parens.assert_or_await_expr_rhs ~in_await:true { e with pexp_attributes =