diff --git a/camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml b/camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml index 9a5d80d07..63730aa7e 100644 --- a/camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml +++ b/camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml @@ -238,7 +238,7 @@ module Make (Ast : Sig.Camlp4Ast) = struct | TyApp loc _ _ as f -> let (f, al) = ctyp_fa [] f in let (is_cls, li) = ctyp_long_id f in - if is_cls then mktyp loc (Ptyp_class li (List.map ctyp al) []) + if is_cls then mktyp loc (Ptyp_class li (List.map ctyp al)) else mktyp loc (Ptyp_constr li (List.map ctyp al)) | TyArr loc (TyLab _ lab t1) t2 -> mktyp loc (Ptyp_arrow lab (ctyp t1) (ctyp t2)) @@ -250,7 +250,7 @@ module Make (Ast : Sig.Camlp4Ast) = struct | <:ctyp@loc< < $fl$ .. > >> -> mktyp loc (Ptyp_object (meth_list fl []) Open) | TyCls loc id -> - mktyp loc (Ptyp_class (ident id) [] []) + mktyp loc (Ptyp_class (ident id) []) | <:ctyp@loc< (module $pt$) >> -> let (i, cs) = package_type pt in mktyp loc (Ptyp_package i cs) @@ -660,8 +660,8 @@ value varify_constructors var_names = Ptyp_constr longident (List.map loop lst) | Ptyp_object (lst, o) -> Ptyp_object (List.map (fun (s, t) -> (s, loop t)) lst, o) - | Ptyp_class longident lst lbl_list -> - Ptyp_class (longident, List.map loop lst, lbl_list) + | Ptyp_class longident lst -> + Ptyp_class (longident, List.map loop lst) | Ptyp_alias core_type string -> Ptyp_alias(loop core_type, string) | Ptyp_variant row_field_list flag lbl_lst_option -> diff --git a/camlp4/boot/Camlp4.ml b/camlp4/boot/Camlp4.ml index 15cd3a365..01991f091 100644 --- a/camlp4/boot/Camlp4.ml +++ b/camlp4/boot/Camlp4.ml @@ -14363,7 +14363,7 @@ module Struct = let (is_cls, li) = ctyp_long_id f in if is_cls - then mktyp loc (Ptyp_class (li, (List.map ctyp al), [])) + then mktyp loc (Ptyp_class (li, (List.map ctyp al))) else mktyp loc (Ptyp_constr (li, (List.map ctyp al))) | TyArr (loc, (TyLab (_, lab, t1)), t2) -> mktyp loc (Ptyp_arrow (lab, (ctyp t1), (ctyp t2))) @@ -14380,7 +14380,7 @@ module Struct = mktyp loc (Ptyp_object (meth_list fl [], Open)) | TyCls (loc, id) -> - mktyp loc (Ptyp_class ((ident id), [], [])) + mktyp loc (Ptyp_class ((ident id), [])) | Ast.TyPkg (loc, pt) -> let (i, cs) = package_type pt in mktyp loc (Ptyp_package (i, cs)) @@ -14884,8 +14884,8 @@ module Struct = Ptyp_constr (longident, (List.map loop lst)) | Ptyp_object (lst, o) -> Ptyp_object (List.map (fun (s, t) -> (s, loop t)) lst, o) - | Ptyp_class (longident, lst, lbl_list) -> - Ptyp_class ((longident, (List.map loop lst), lbl_list)) + | Ptyp_class (longident, lst) -> + Ptyp_class ((longident, (List.map loop lst))) | Ptyp_alias (core_type, string) -> Ptyp_alias (((loop core_type), string)) | Ptyp_variant (row_field_list, flag, lbl_lst_option) -> diff --git a/experimental/frisch/extension_points.txt b/experimental/frisch/extension_points.txt index 043122cbf..3b469ce48 100644 --- a/experimental/frisch/extension_points.txt +++ b/experimental/frisch/extension_points.txt @@ -421,6 +421,10 @@ Rationale: - Make it explicit when the guard can appear. +--- Get rid of "fun p when guard -> e" + +See #5939, #5936. + --- Get rid of the location argument on pci_params @@ -436,6 +440,10 @@ invariants in the Parsetree (such as: := constraints cannot be on qualified identifiers). Also, we avoid mixing in a single Longident.t identifier which can be LIDENT or UIDENT. +--- Get rid of the "#c [> `A]" syntax + + +See #5936, #5983. === More TODOs diff --git a/otherlibs/labltk/browser/searchpos.ml b/otherlibs/labltk/browser/searchpos.ml index 6c88b5ccc..1c4276fd7 100644 --- a/otherlibs/labltk/browser/searchpos.ml +++ b/otherlibs/labltk/browser/searchpos.ml @@ -122,7 +122,7 @@ let rec search_pos_type t ~pos ~env = add_found_sig (`Type, lid.txt) ~env ~loc:t.ptyp_loc | Ptyp_object (fl, _) -> List.iter fl ~f:(fun (_, ty) -> search_pos_type ty ~pos ~env) - | Ptyp_class (lid, tl, _) -> + | Ptyp_class (lid, tl) -> List.iter tl ~f:(search_pos_type ~pos ~env); add_found_sig (`Type, lid.txt) ~env ~loc:t.ptyp_loc | Ptyp_alias (t, _) diff --git a/parsing/ast_helper.ml b/parsing/ast_helper.ml index c87fdb2bc..5c13dcdf7 100644 --- a/parsing/ast_helper.ml +++ b/parsing/ast_helper.ml @@ -38,7 +38,7 @@ module Typ = struct let tuple ?loc ?attrs a = mk ?loc ?attrs (Ptyp_tuple a) let constr ?loc ?attrs a b = mk ?loc ?attrs (Ptyp_constr (a, b)) let object_ ?loc ?attrs a b = mk ?loc ?attrs (Ptyp_object (a, b)) - let class_ ?loc ?attrs a b c = mk ?loc ?attrs (Ptyp_class (a, b, c)) + let class_ ?loc ?attrs a b = mk ?loc ?attrs (Ptyp_class (a, b)) let alias ?loc ?attrs a b = mk ?loc ?attrs (Ptyp_alias (a, b)) let variant ?loc ?attrs a b c = mk ?loc ?attrs (Ptyp_variant (a, b, c)) let poly ?loc ?attrs a b = mk ?loc ?attrs (Ptyp_poly (a, b)) diff --git a/parsing/ast_helper.mli b/parsing/ast_helper.mli index fc74ec225..bb0a20586 100644 --- a/parsing/ast_helper.mli +++ b/parsing/ast_helper.mli @@ -37,7 +37,7 @@ module Typ : val tuple: ?loc:loc -> ?attrs:attrs -> core_type list -> core_type val constr: ?loc:loc -> ?attrs:attrs -> lid -> core_type list -> core_type val object_: ?loc:loc -> ?attrs:attrs -> (string * core_type) list -> closed_flag -> core_type - val class_: ?loc:loc -> ?attrs:attrs -> lid -> core_type list -> label list -> core_type + val class_: ?loc:loc -> ?attrs:attrs -> lid -> core_type list -> core_type val alias: ?loc:loc -> ?attrs:attrs -> core_type -> string -> core_type val variant: ?loc:loc -> ?attrs:attrs -> row_field list -> closed_flag -> label list option -> core_type val poly: ?loc:loc -> ?attrs:attrs -> string list -> core_type -> core_type diff --git a/parsing/ast_mapper.ml b/parsing/ast_mapper.ml index 690f79f46..5a27c18f3 100644 --- a/parsing/ast_mapper.ml +++ b/parsing/ast_mapper.ml @@ -44,7 +44,7 @@ module T = struct | Ptyp_tuple tyl -> tuple ~loc ~attrs (List.map (sub # typ) tyl) | Ptyp_constr (lid, tl) -> constr ~loc ~attrs (map_loc sub lid) (List.map (sub # typ) tl) | Ptyp_object (l, o) -> object_ ~loc ~attrs (List.map (map_snd (sub # typ)) l) o - | Ptyp_class (lid, tl, ll) -> class_ ~loc ~attrs (map_loc sub lid) (List.map (sub # typ) tl) ll + | Ptyp_class (lid, tl) -> class_ ~loc ~attrs (map_loc sub lid) (List.map (sub # typ) tl) | Ptyp_alias (t, s) -> alias ~loc ~attrs (sub # typ t) s | Ptyp_variant (rl, b, ll) -> variant ~loc ~attrs (List.map (row_field sub) rl) b ll | Ptyp_poly (sl, t) -> poly ~loc ~attrs sl (sub # typ t) diff --git a/parsing/parser.mly b/parsing/parser.mly index e861b12d5..7b958a9b9 100644 --- a/parsing/parser.mly +++ b/parsing/parser.mly @@ -249,8 +249,8 @@ let varify_constructors var_names t = Ptyp_constr(longident, List.map loop lst) | Ptyp_object (lst, o) -> Ptyp_object (List.map (fun (s, t) -> (s, loop t)) lst, o) - | Ptyp_class (longident, lst, lbl_list) -> - Ptyp_class (longident, List.map loop lst, lbl_list) + | Ptyp_class (longident, lst) -> + Ptyp_class (longident, List.map loop lst) | Ptyp_alias(core_type, string) -> check_variable var_names t.ptyp_loc string; Ptyp_alias(loop core_type, string) @@ -1645,12 +1645,12 @@ simple_core_type2: { let (f, c) = $2 in mktyp(Ptyp_object (f, c)) } | LESS GREATER { mktyp(Ptyp_object ([], Closed)) } - | SHARP class_longident opt_present - { mktyp(Ptyp_class(mkrhs $2 2, [], $3)) } - | simple_core_type2 SHARP class_longident opt_present - { mktyp(Ptyp_class(mkrhs $3 3, [$1], $4)) } - | LPAREN core_type_comma_list RPAREN SHARP class_longident opt_present - { mktyp(Ptyp_class(mkrhs $5 5, List.rev $2, $6)) } + | SHARP class_longident + { mktyp(Ptyp_class(mkrhs $2 2, [])) } + | simple_core_type2 SHARP class_longident + { mktyp(Ptyp_class(mkrhs $3 3, [$1])) } + | LPAREN core_type_comma_list RPAREN SHARP class_longident + { mktyp(Ptyp_class(mkrhs $5 5, List.rev $2)) } | LBRACKET tag_field RBRACKET { mktyp(Ptyp_variant([$2], Closed, None)) } /* PR#3835: this is not LR(1), would need lookahead=2 @@ -1707,10 +1707,6 @@ amper_type_list: core_type { [$1] } | amper_type_list AMPERSAND core_type { $3 :: $1 } ; -opt_present: - LBRACKETGREATER name_tag_list RBRACKET { List.rev $2 } - | /* empty */ { [] } -; name_tag_list: name_tag { [$1] } | name_tag_list name_tag { $2 :: $1 } diff --git a/parsing/parsetree.mli b/parsing/parsetree.mli index 3c5f5d7f5..7bf87e6d5 100644 --- a/parsing/parsetree.mli +++ b/parsing/parsetree.mli @@ -66,13 +66,10 @@ and core_type_desc = (* < l1:T1; ...; ln:Tn > (flag = Closed) < l1:T1; ...; ln:Tn; .. > (flag = Open) *) - | Ptyp_class of Longident.t loc * core_type list * label list + | Ptyp_class of Longident.t loc * core_type list (* #tconstr T #tconstr - (T1, ..., Tn) tconstr - - The label list is used for the deprecated syntax: - #tconstr [> `A1 ... `An] + (T1, ..., Tn) #tconstr *) | Ptyp_alias of core_type * string (* T as 'a *) diff --git a/parsing/pprintast.ml b/parsing/pprintast.ml index 67d55706e..d80e6a332 100644 --- a/parsing/pprintast.ml +++ b/parsing/pprintast.ml @@ -297,13 +297,10 @@ class printer ()= object(self:'self) in pp f "@[<@ %a%a@ >@]" (self#list core_field_type ~sep:";") l field_var o - | Ptyp_class (li, l, low) -> (*FIXME*) - pp f "@[%a#%a%a@]" + | Ptyp_class (li, l) -> (*FIXME*) + pp f "@[%a#%a@]" (self#list self#core_type ~sep:"," ~first:"(" ~last:")") l self#longident_loc li - (fun f low -> match low with - | [] -> () - | _ -> pp f "@ [>@ %a]" (self#list self#string_quot) low) low | Ptyp_package (lid, cstrs) -> let aux f (s, ct) = pp f "type %a@ =@ %a" self#longident_loc s self#core_type ct in diff --git a/parsing/printast.ml b/parsing/printast.ml index df7309157..b86800884 100644 --- a/parsing/printast.ml +++ b/parsing/printast.ml @@ -162,10 +162,9 @@ let rec core_type i ppf x = core_type (i + 1) ppf t ) l - | Ptyp_class (li, l, low) -> + | Ptyp_class (li, l) -> line i ppf "Ptyp_class %a\n" fmt_longident_loc li; - list i core_type ppf l; - list i string ppf low + list i core_type ppf l | Ptyp_alias (ct, s) -> line i ppf "Ptyp_alias \"%s\"\n" s; core_type i ppf ct; diff --git a/tools/depend.ml b/tools/depend.ml index 39223467a..52ac3dd12 100644 --- a/tools/depend.ml +++ b/tools/depend.ml @@ -44,7 +44,7 @@ let rec add_type bv ty = | Ptyp_tuple tl -> List.iter (add_type bv) tl | Ptyp_constr(c, tl) -> add bv c; List.iter (add_type bv) tl | Ptyp_object (fl, _) -> List.iter (fun (_, t) -> add_type bv t) fl - | Ptyp_class(c, tl, _) -> add bv c; List.iter (add_type bv) tl + | Ptyp_class(c, tl) -> add bv c; List.iter (add_type bv) tl | Ptyp_alias(t, s) -> add_type bv t | Ptyp_variant(fl, _, _) -> List.iter diff --git a/tools/tast_iter.ml b/tools/tast_iter.ml index cf40cda57..e3b708391 100644 --- a/tools/tast_iter.ml +++ b/tools/tast_iter.ml @@ -288,7 +288,7 @@ let core_type sub ct = List.iter (sub # core_type) list | Ttyp_object (list, _o) -> List.iter (fun (_, t) -> sub # core_type t) list - | Ttyp_class (_path, _, list, _labels) -> + | Ttyp_class (_path, _, list) -> List.iter (sub # core_type) list | Ttyp_alias (ct, _s) -> sub # core_type ct diff --git a/tools/untypeast.ml b/tools/untypeast.ml index 5314a7aa2..abebeca03 100644 --- a/tools/untypeast.ml +++ b/tools/untypeast.ml @@ -496,9 +496,8 @@ and untype_core_type ct = List.map untype_core_type list) | Ttyp_object (list, o) -> Ptyp_object (List.map (fun (s, t) -> (s, untype_core_type t)) list, o) - | Ttyp_class (_path, lid, list, labels) -> - Ptyp_class (lid, - List.map untype_core_type list, labels) + | Ttyp_class (_path, lid, list) -> + Ptyp_class (lid, List.map untype_core_type list) | Ttyp_alias (ct, s) -> Ptyp_alias (untype_core_type ct, s) | Ttyp_variant (list, bool, labels) -> diff --git a/typing/printtyped.ml b/typing/printtyped.ml index cfd344cbe..7463ff0d4 100644 --- a/typing/printtyped.ml +++ b/typing/printtyped.ml @@ -176,10 +176,9 @@ let rec core_type i ppf x = core_type (i + 1) ppf t ) l - | Ttyp_class (li, _, l, low) -> + | Ttyp_class (li, _, l) -> line i ppf "Ptyp_class %a\n" fmt_path li; list i core_type ppf l; - list i string ppf low | Ttyp_alias (ct, s) -> line i ppf "Ptyp_alias \"%s\"\n" s; core_type i ppf ct; diff --git a/typing/typedtree.ml b/typing/typedtree.ml index 87aa9f9a9..9795fc548 100644 --- a/typing/typedtree.ml +++ b/typing/typedtree.ml @@ -321,7 +321,7 @@ and core_type_desc = | Ttyp_tuple of core_type list | Ttyp_constr of Path.t * Longident.t loc * core_type list | Ttyp_object of (string * core_type) list * closed_flag - | Ttyp_class of Path.t * Longident.t loc * core_type list * label list + | Ttyp_class of Path.t * Longident.t loc * core_type list | Ttyp_alias of core_type * string | Ttyp_variant of row_field list * closed_flag * label list option | Ttyp_poly of string list * core_type diff --git a/typing/typedtree.mli b/typing/typedtree.mli index d4a03a465..df300f9b2 100644 --- a/typing/typedtree.mli +++ b/typing/typedtree.mli @@ -320,7 +320,7 @@ and core_type_desc = | Ttyp_tuple of core_type list | Ttyp_constr of Path.t * Longident.t loc * core_type list | Ttyp_object of (string * core_type) list * closed_flag - | Ttyp_class of Path.t * Longident.t loc * core_type list * label list + | Ttyp_class of Path.t * Longident.t loc * core_type list | Ttyp_alias of core_type * string | Ttyp_variant of row_field list * closed_flag * label list option | Ttyp_poly of string list * core_type diff --git a/typing/typedtreeIter.ml b/typing/typedtreeIter.ml index f564b3cb4..aa487a042 100644 --- a/typing/typedtreeIter.ml +++ b/typing/typedtreeIter.ml @@ -513,7 +513,7 @@ module MakeIterator(Iter : IteratorArgument) : sig List.iter iter_core_type list | Ttyp_object (list, o) -> List.iter (fun (_, t) -> iter_core_type t) list - | Ttyp_class (path, _, list, labels) -> + | Ttyp_class (path, _, list) -> List.iter iter_core_type list | Ttyp_alias (ct, s) -> iter_core_type ct diff --git a/typing/typedtreeMap.ml b/typing/typedtreeMap.ml index 034534fb6..3284247ac 100644 --- a/typing/typedtreeMap.ml +++ b/typing/typedtreeMap.ml @@ -555,8 +555,8 @@ module MakeMap(Map : MapArgument) = struct Ttyp_constr (path, lid, List.map map_core_type list) | Ttyp_object (list, o) -> Ttyp_object (List.map (fun (s, t) -> (s, map_core_type t)) list, o) - | Ttyp_class (path, lid, list, labels) -> - Ttyp_class (path, lid, List.map map_core_type list, labels) + | Ttyp_class (path, lid, list) -> + Ttyp_class (path, lid, List.map map_core_type list) | Ttyp_alias (ct, s) -> Ttyp_alias (map_core_type ct, s) | Ttyp_variant (list, bool, labels) -> Ttyp_variant (List.map map_row_field list, bool, labels) diff --git a/typing/typetexp.ml b/typing/typetexp.ml index 8587b5aa1..26efe2691 100644 --- a/typing/typetexp.ml +++ b/typing/typetexp.ml @@ -285,7 +285,7 @@ let rec transl_type env policy styp = in let ty = newobj (transl_fields loc env policy [] o fields) in ctyp (Ttyp_object (fields, o)) ty - | Ptyp_class(lid, stl, present) -> + | Ptyp_class(lid, stl) -> let (path, decl, is_variant) = try let (path, decl) = Env.lookup_type lid.txt env in @@ -302,7 +302,6 @@ let rec transl_type env policy styp = Location.prerr_warning styp.ptyp_loc Warnings.Deprecated; (path, decl,true) with Not_found -> try - if present <> [] then raise Not_found; let lid2 = match lid.txt with Longident.Lident s -> Longident.Lident ("#" ^ s) @@ -334,14 +333,9 @@ let rec transl_type env policy styp = let ty = match ty.desc with Tvariant row -> let row = Btype.row_repr row in - List.iter - (fun l -> if not (List.mem_assoc l row.row_fields) then - raise(Error(styp.ptyp_loc, env, Present_has_no_type l))) - present; let fields = List.map (fun (l,f) -> l, - if List.mem l present then f else match Btype.row_field_repr f with | Rpresent (Some ty) -> Reither(false, [ty], false, ref None) @@ -367,7 +361,7 @@ let rec transl_type env policy styp = | _ -> assert false in - ctyp (Ttyp_class (path, lid, args, present)) ty + ctyp (Ttyp_class (path, lid, args)) ty | Ptyp_alias(st, alias) -> let cty = try