Skip to content

Commit 99f25cc

Browse files
committed
short-cut unit type for object types
1 parent 0959437 commit 99f25cc

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

jscomp/syntax/ast_external_process.ml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -409,12 +409,13 @@ let process_obj
409409
let new_arg_label, new_arg_types, output_tys =
410410
match arg_label with
411411
| Nolabel ->
412-
let new_ty, arg_type = refine_obj_arg_type ~nolabel:true ty in
413-
if arg_type = Extern_unit then
414-
External_arg_spec.empty_kind arg_type,
415-
{param_type with ty = new_ty}::arg_types, result_types
416-
else
417-
Location.raise_errorf ~loc "expect label, optional, or unit here"
412+
begin match ty.ptyp_desc with
413+
| Ptyp_constr({txt = Lident "unit";_}, []) ->
414+
External_arg_spec.empty_kind Extern_unit,
415+
param_type ::arg_types, result_types
416+
| _ ->
417+
Location.raise_errorf ~loc "expect label, optional, or unit here"
418+
end
418419
| Labelled name ->
419420
let new_ty, obj_arg_type = refine_obj_arg_type ~nolabel:false ty in
420421
begin match obj_arg_type with

0 commit comments

Comments
 (0)