Skip to content

Commit 1584803

Browse files
author
Jacques Garrigue
committed
exhauce PR#6367: introduce Asttypes.arg_label to encode labelled arguments
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15737 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1 parent c0de696 commit 1584803

35 files changed

+245
-219
lines changed

Changes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ Bug fixes:
5959
- PR#6650: Cty_constr not handled correctly by Subst
6060
- PR#6651: Failing component lookup
6161

62+
Features wishes:
63+
- PR#6367: introduce Asttypes.arg_label to encode labelled arguments
64+
6265
OCaml 4.02.2:
6366
-------------
6467

boot/ocamlc

1.75 KB
Binary file not shown.

boot/ocamldep

1.06 KB
Binary file not shown.

boot/ocamllex

1.13 KB
Binary file not shown.

bytecomp/translcore.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ open Typedtree
1818
open Lambda
1919

2020
val transl_exp: expression -> lambda
21-
val transl_apply: lambda -> (label * expression option * optional) list
21+
val transl_apply: lambda -> (arg_label * expression option * optional) list
2222
-> Location.t -> lambda
2323
val transl_let: rec_flag -> value_binding list -> lambda -> lambda
2424
val transl_primitive: Location.t -> Primitive.description -> Env.t

ocamldoc/odoc_info.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -780,11 +780,11 @@ val create_index_lists : 'a list -> ('a -> string) -> 'a list list
780780
val remove_option : Types.type_expr -> Types.type_expr
781781

782782
(** Return [true] if the given label is optional.*)
783-
val is_optional : string -> bool
783+
val is_optional : Asttypes.arg_label -> bool
784784

785785
(** Return the label name for the given label,
786786
i.e. removes the beginning '?' if present.*)
787-
val label_name : string -> string
787+
val label_name : Asttypes.arg_label -> string
788788

789789
(** Return the given name where the module name or
790790
part of it was removed, according to the list of modules

ocamldoc/odoc_misc.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ val search_string_backward : pat: string -> s: string -> int
107107
val remove_option : Types.type_expr -> Types.type_expr
108108

109109
(** Return [true] if the given label is optional.*)
110-
val is_optional : string -> bool
110+
val is_optional : Asttypes.arg_label -> bool
111111

112112
(** Return the label name for the given label,
113113
i.e. removes the beginning '?' if present.*)
114-
val label_name : string -> string
114+
val label_name : Asttypes.arg_label -> string

ocamldoc/odoc_str.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ let string_of_class_params c =
148148
Printf.bprintf b "%s%s%s%s -> "
149149
(
150150
match label with
151-
"" -> ""
152-
| s -> s^":"
151+
Asttypes.Nolabel -> ""
152+
| s -> Printtyp.string_of_label s ^":"
153153
)
154154
(if parent then "(" else "")
155155
(Odoc_print.string_of_type_expr

ocamldoc/odoc_value.ml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,22 +95,16 @@ let parameter_list_from_arrows typ =
9595
so there is nothing to merge. With this dummy list we can merge the
9696
parameter names from the .ml and the type from the .mli file. *)
9797
let dummy_parameter_list typ =
98-
let normal_name s =
99-
match s with
100-
"" -> s
101-
| _ ->
102-
match s.[0] with
103-
'?' -> String.sub s 1 ((String.length s) - 1)
104-
| _ -> s
105-
in
98+
let normal_name = Odoc_misc.label_name in
10699
Printtyp.mark_loops typ;
107100
let liste_param = parameter_list_from_arrows typ in
108101
let rec iter (label, t) =
109102
match t.Types.desc with
110103
| Types.Ttuple l ->
111-
if label = "" then
104+
let open Asttypes in
105+
if label = Nolabel then
112106
Odoc_parameter.Tuple
113-
(List.map (fun t2 -> iter ("", t2)) l, t)
107+
(List.map (fun t2 -> iter (Nolabel, t2)) l, t)
114108
else
115109
(* if there is a label, then we don't want to decompose the tuple *)
116110
Odoc_parameter.Simple_name

parsing/ast_helper.mli

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module Typ :
3838

3939
val any: ?loc:loc -> ?attrs:attrs -> unit -> core_type
4040
val var: ?loc:loc -> ?attrs:attrs -> string -> core_type
41-
val arrow: ?loc:loc -> ?attrs:attrs -> label -> core_type -> core_type
41+
val arrow: ?loc:loc -> ?attrs:attrs -> arg_label -> core_type -> core_type
4242
-> core_type
4343
val tuple: ?loc:loc -> ?attrs:attrs -> core_type list -> core_type
4444
val constr: ?loc:loc -> ?attrs:attrs -> lid -> core_type list -> core_type
@@ -93,11 +93,11 @@ module Exp:
9393
val constant: ?loc:loc -> ?attrs:attrs -> constant -> expression
9494
val let_: ?loc:loc -> ?attrs:attrs -> rec_flag -> value_binding list
9595
-> expression -> expression
96-
val fun_: ?loc:loc -> ?attrs:attrs -> label -> expression option -> pattern
96+
val fun_: ?loc:loc -> ?attrs:attrs -> arg_label -> expression option -> pattern
9797
-> expression -> expression
9898
val function_: ?loc:loc -> ?attrs:attrs -> case list -> expression
9999
val apply: ?loc:loc -> ?attrs:attrs -> expression
100-
-> (label * expression) list -> expression
100+
-> (arg_label * expression) list -> expression
101101
val match_: ?loc:loc -> ?attrs:attrs -> expression -> case list
102102
-> expression
103103
val try_: ?loc:loc -> ?attrs:attrs -> expression -> case list -> expression
@@ -293,7 +293,7 @@ module Cty:
293293

294294
val constr: ?loc:loc -> ?attrs:attrs -> lid -> core_type list -> class_type
295295
val signature: ?loc:loc -> ?attrs:attrs -> class_signature -> class_type
296-
val arrow: ?loc:loc -> ?attrs:attrs -> label -> core_type -> class_type -> class_type
296+
val arrow: ?loc:loc -> ?attrs:attrs -> arg_label -> core_type -> class_type -> class_type
297297
val extension: ?loc:loc -> ?attrs:attrs -> extension -> class_type
298298
end
299299

@@ -319,9 +319,12 @@ module Cl:
319319

320320
val constr: ?loc:loc -> ?attrs:attrs -> lid -> core_type list -> class_expr
321321
val structure: ?loc:loc -> ?attrs:attrs -> class_structure -> class_expr
322-
val fun_: ?loc:loc -> ?attrs:attrs -> label -> expression option -> pattern -> class_expr -> class_expr
323-
val apply: ?loc:loc -> ?attrs:attrs -> class_expr -> (label * expression) list -> class_expr
324-
val let_: ?loc:loc -> ?attrs:attrs -> rec_flag -> value_binding list -> class_expr -> class_expr
322+
val fun_: ?loc:loc -> ?attrs:attrs -> arg_label -> expression option -> pattern ->
323+
class_expr -> class_expr
324+
val apply:
325+
?loc:loc -> ?attrs:attrs -> class_expr -> (arg_label * expression) list -> class_expr
326+
val let_:
327+
?loc:loc -> ?attrs:attrs -> rec_flag -> value_binding list -> class_expr -> class_expr
325328
val constraint_: ?loc:loc -> ?attrs:attrs -> class_expr -> class_type -> class_expr
326329
val extension: ?loc:loc -> ?attrs:attrs -> extension -> class_expr
327330
end

0 commit comments

Comments
 (0)