Skip to content

Commit

Permalink
Mark pexp_function as deprecated
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Ferris <[email protected]>
  • Loading branch information
patricoferris committed Sep 14, 2024
1 parent 8ecde1b commit 4d8fcf8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module Lambda = struct
let maybe_apply_generic ~loc ~binds maybe_arg cases =
let expr =
match maybe_arg with
| None -> pexp_function ~loc cases
| None -> pexp_function_cases ~loc cases
| Some arg -> pexp_match ~loc arg cases
in
with_let ~loc ~binds expr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ module Str_generate_of_sexp = struct
[%expr
let rec [%p Fresh_name.pattern fresh_iter] =
[%e
pexp_function
pexp_function_cases
~loc
[ [%pat?
Sexplib0.Sexp.List
Expand Down
4 changes: 3 additions & 1 deletion src/ast_builder.ml
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,16 @@ module Default = struct
pexp_desc = Pexp_function ([ case ], None, Pfunction_body e);
}

let pexp_function ~loc cases =
let pexp_function_cases ~loc cases =
{
pexp_loc_stack = [];
pexp_attributes = [];
pexp_loc = loc;
pexp_desc = Pexp_function ([], None, Pfunction_cases (cases, loc, []));
}

let pexp_function ~loc cases = pexp_function_cases ~loc cases

let value_binding ~loc ~pat ~expr =
value_binding ~loc ~pat ~expr ~constraint_:None

Expand Down
9 changes: 9 additions & 0 deletions src/ast_builder.mli
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ module Default : sig
loc:location -> longident loc -> pattern option -> pattern

val pexp_function : loc:location -> Import.cases -> expression
[@@ocaml.deprecated "use pexp_function_cases instead."]
(** @deprecated
This function will be used to construct a {! Parsetree.Pexp_function }
in the next release, to retain its current functionality migrate to
{! pexp_function_cases}. *)

val pexp_function_cases : loc:location -> Import.cases -> expression
(** [pexp_function_cases] builds an expression in the shape
[function C1 -> E1 | ...]. *)

val constructor_declaration :
loc:location ->
Expand Down

0 comments on commit 4d8fcf8

Please sign in to comment.