Skip to content

Commit cd5ace5

Browse files
committed
Put arg_label in Outcome tree
1 parent 752e3a9 commit cd5ace5

3 files changed

Lines changed: 19 additions & 6 deletions

File tree

ocaml/typing/oprint.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,10 @@ and print_out_type_1 mode ppf =
305305
function
306306
| Otyp_arrow (lab, am, ty1, rm, ty2) ->
307307
pp_open_box ppf 0;
308-
if lab <> "" then (pp_print_string ppf lab; pp_print_char ppf ':');
308+
(match lab with
309+
| Nolabel -> ()
310+
| Labelled l -> pp_print_string ppf l; pp_print_char ppf ':'
311+
| Optional l -> pp_print_string ppf ("?"^l); pp_print_char ppf ':');
309312
print_out_arg am ppf ty1;
310313
pp_print_string ppf " ->";
311314
pp_print_space ppf ();

ocaml/typing/outcometree.mli

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,16 @@ type out_global =
7575
| Ogf_global
7676
| Ogf_unrestricted
7777

78+
type arg_label =
79+
| Nolabel
80+
| Labelled of string (** [label:T -> ...] *)
81+
| Optional of string (*** [?label:T -> ...] *)
82+
7883
type out_type =
7984
| Otyp_abstract
8085
| Otyp_open
8186
| Otyp_alias of out_type * string
82-
| Otyp_arrow of string * out_alloc_mode * out_type * out_alloc_mode * out_type
87+
| Otyp_arrow of arg_label * out_alloc_mode * out_type * out_alloc_mode * out_type
8388
| Otyp_class of bool * out_ident * out_type list
8489
| Otyp_constr of out_ident * out_type list
8590
| Otyp_manifest of out_type * out_type

ocaml/typing/printtyp.ml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -509,9 +509,9 @@ let print_name ppf = function
509509
| Some name -> fprintf ppf "\"%s\"" name
510510

511511
let string_of_label = function
512-
Nolabel -> ""
513-
| Labelled s -> s
514-
| Optional s -> "?"^s
512+
Types.Nolabel -> ""
513+
| Types.Labelled s -> s
514+
| Types.Optional s -> "?"^s
515515

516516
let visited = ref []
517517
let rec raw_type ppf ty =
@@ -1117,7 +1117,12 @@ let rec tree_of_typexp mode ty =
11171117
Otyp_var (non_gen, Names.name_of_type name_gen tty)
11181118
| Tarrow ((l, marg, mret), ty1, ty2, _) ->
11191119
let lab =
1120-
if !print_labels || is_optional l then string_of_label l else ""
1120+
if !print_labels || is_optional l then
1121+
match l with
1122+
| Types.Nolabel -> Outcometree.Nolabel
1123+
| Types.Labelled l -> Labelled l
1124+
| Types.Optional l -> Optional l
1125+
else Nolabel
11211126
in
11221127
let t1 =
11231128
if is_optional l then

0 commit comments

Comments
 (0)