Skip to content

Commit

Permalink
refactor(ppx): reuse is_unit function (#944)
Browse files Browse the repository at this point in the history
  • Loading branch information
anmonteiro authored Nov 29, 2023
1 parent 7b00afd commit f65ced3
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions ppx/ast_external_process.ml
Original file line number Diff line number Diff line change
Expand Up @@ -401,11 +401,6 @@ let has_mel_uncurry (attrs : Ast_attributes.t) =
txt = "mel.uncurry" || txt = "uncurry")
attrs

let is_unit ty =
match ty.ptyp_desc with
| Ptyp_constr ({ txt = Lident "unit"; _ }, []) -> true
| _ -> false

let is_user_option ty =
match ty.ptyp_desc with
| Ptyp_constr
Expand All @@ -419,7 +414,8 @@ let check_return_wrapper loc (wrapper : External_ffi_types.return_wrapper)
match wrapper with
| Return_identity -> wrapper
| Return_unset ->
if is_unit result_type then Return_replaced_with_unit else wrapper
if Ast_core_type.is_unit result_type then Return_replaced_with_unit
else wrapper
| Return_undefined_to_opt | Return_null_to_opt | Return_null_undefined_to_opt
->
if is_user_option result_type then wrapper
Expand Down

0 comments on commit f65ced3

Please sign in to comment.