summaryrefslogtreecommitdiff
path: root/typing/printtyp.ml
diff options
context:
space:
mode:
authorFlorian Angeletti <florian.angeletti@inria.fr>2022-10-13 13:37:22 +0200
committerFlorian Angeletti <florian.angeletti@inria.fr>2022-10-17 10:49:10 +0200
commit58f91e6e572e26b9803bc21895c97bd41263beb2 (patch)
tree2391c028a251db4313f57db78497a2d1f6b9d217 /typing/printtyp.ml
parent1b932390bc4ee798ec0e673199ebe2224494777a (diff)
downloadocaml-58f91e6e572e26b9803bc21895c97bd41263beb2.tar.gz
Printtyp: avoid stack overflow when printing constructors or records
Toplevel functions exported by the Printtyp should in general prepare all types involved in the printing. The toplevel `constructor`, `label` and `extension_only_constructor` functions didn't prepare their arguments and return types making the printer loops on such types.
Diffstat (limited to 'typing/printtyp.ml')
-rw-r--r--typing/printtyp.ml5
1 files changed, 5 insertions, 0 deletions
diff --git a/typing/printtyp.ml b/typing/printtyp.ml
index 7e87cd4734..88d67013c5 100644
--- a/typing/printtyp.ml
+++ b/typing/printtyp.ml
@@ -1466,10 +1466,13 @@ and tree_of_label l =
let constructor ppf c =
reset_except_context ();
+ prepare_type_constructor_arguments c.cd_args;
+ Option.iter prepare_type c.cd_res;
!Oprint.out_constr ppf (tree_of_constructor c)
let label ppf l =
reset_except_context ();
+ prepare_type l.ld_type;
!Oprint.out_label ppf (tree_of_label l)
let tree_of_type_declaration id decl rs =
@@ -1537,6 +1540,8 @@ let extension_constructor id ppf ext =
let extension_only_constructor id ppf ext =
reset_except_context ();
+ prepare_type_constructor_arguments ext.ext_args;
+ Option.iter prepare_type ext.ext_ret_type;
let name = Ident.name id in
let args, ret =
extension_constructor_args_and_ret_type_subtree