diff --git a/ocaml/parsing/pprintast.ml b/ocaml/parsing/pprintast.ml index cd783281f0c..66b325a344e 100644 --- a/ocaml/parsing/pprintast.ml +++ b/ocaml/parsing/pprintast.ml @@ -1915,7 +1915,7 @@ and constructor_declaration ctxt f (name, vars_jkinds, args, res, attrs) = (fun f -> function | Pcstr_tuple [] -> () | Pcstr_tuple l -> - pp f "@;of@;%a" (list (core_type1 ctxt) ~sep:"@;*@;") l + pp f "@;of@;%a" (list (maybe_modes_type core_type1 ctxt) ~sep:"@;*@;") l | Pcstr_record l -> pp f "@;of@;%a" (record_declaration ctxt) l ) args (attributes ctxt) attrs @@ -1925,7 +1925,7 @@ and constructor_declaration ctxt f (name, vars_jkinds, args, res, attrs) = (fun f -> function | Pcstr_tuple [] -> core_type1 ctxt f r | Pcstr_tuple l -> pp f "%a@;->@;%a" - (list (core_type1 ctxt) ~sep:"@;*@;") l + (list (maybe_modes_type core_type1 ctxt) ~sep:"@;*@;") l (core_type1 ctxt) r | Pcstr_record l -> pp f "%a@;->@;%a" (record_declaration ctxt) l (core_type1 ctxt) r diff --git a/ocaml/testsuite/tests/language-extensions/pprintast_unconditional.ml b/ocaml/testsuite/tests/language-extensions/pprintast_unconditional.ml index 05e0b700935..b167319baed 100644 --- a/ocaml/testsuite/tests/language-extensions/pprintast_unconditional.ml +++ b/ocaml/testsuite/tests/language-extensions/pprintast_unconditional.ml @@ -17,6 +17,16 @@ module Example = struct let parse p str = p (Lexing.from_string str) end + let modality_record = parse module_expr + "struct \ + type t = {global_ x : string; global_ y : int} \ + end" + let modality_cstrarg = parse module_expr + "struct \ + type t = Foo of global_ string * global_ string \ + type u = Foo : global_ string * global_ string -> u \ + end" + let longident = parse longident "No.Longidents.Require.extensions" let expression = parse expression "[x for x = 1 to 10]" let pattern = parse pattern "[:_:]" @@ -123,6 +133,9 @@ end = struct Test.setup () ;; + let modality_record = test "modality_record" module_expr Example.modality_record + let modality_cstrarg = test "modality_cstrarg" module_expr Example.modality_cstrarg + let longident = test "longident" longident Example.longident let expression = test "expression" expression Example.expression let pattern = test "pattern" pattern Example.pattern diff --git a/ocaml/testsuite/tests/language-extensions/pprintast_unconditional.reference b/ocaml/testsuite/tests/language-extensions/pprintast_unconditional.reference index 462e16842d0..f9dcbfc959d 100644 --- a/ocaml/testsuite/tests/language-extensions/pprintast_unconditional.reference +++ b/ocaml/testsuite/tests/language-extensions/pprintast_unconditional.reference @@ -1,6 +1,18 @@ ##### All extensions enabled -------------------------------- +modality_record: struct type t = { + global_ x: string ; + global_ y: int } end + +modality_cstrarg: + struct + type t = + | Foo of global_ string * global_ string + type u = + | Foo: global_ string * global_ string -> u + end + longident: No.Longidents.Require.extensions expression: [x for x = 1 to 10] @@ -58,6 +70,18 @@ tyvar: 'no_tyvars_require_extensions ##### Extensions disallowed -------------------------------- +modality_record: struct type t = { + global_ x: string ; + global_ y: int } end + +modality_cstrarg: + struct + type t = + | Foo of global_ string * global_ string + type u = + | Foo: global_ string * global_ string -> u + end + longident: No.Longidents.Require.extensions expression: [x for x = 1 to 10]