@@ -304,27 +304,27 @@ let transl_declaration ~typeRecordAsObject env sdecl id =
304
304
in
305
305
let raw_status = get_unboxed_from_attributes sdecl in
306
306
307
- let checkUntaggedVariant = match sdecl.ptype_kind with
307
+ let checkUntaggedVariant() = match sdecl.ptype_kind with
308
308
| Ptype_variant cds -> Ext_list. for_all cds (function
309
309
| {pcd_args = Pcstr_tuple ([] | [_])} ->
310
310
(* at most one payload allowed for untagged variants *)
311
311
true
312
+ | {pcd_args = Pcstr_tuple (_ ::_ ::_ ); pcd_name ={txt =name } } ->
313
+ Ast_untagged_variants. reportConstructorMoreThanOneArg ~loc: sdecl.ptype_loc ~name
312
314
| {pcd_args = Pcstr_record _ } -> true
313
- | _ -> false )
315
+ )
314
316
| _ -> false
315
317
in
316
318
317
- if raw_status.unboxed && not raw_status.default && not checkUntaggedVariant then begin
319
+ if raw_status.unboxed && not raw_status.default && not ( checkUntaggedVariant() ) then begin
318
320
match sdecl.ptype_kind with
319
321
| Ptype_abstract ->
320
322
raise(Error (sdecl.ptype_loc, Bad_unboxed_attribute
321
323
" it is abstract" ))
322
324
| Ptype_variant [{pcd_args = Pcstr_tuple [] }] ->
323
325
raise(Error (sdecl.ptype_loc, Bad_unboxed_attribute
324
326
" its constructor has no argument" ))
325
- | Ptype_variant [{pcd_args = Pcstr_tuple [_]}] -> ()
326
- | Ptype_variant [{pcd_args = Pcstr_tuple (_::_::_); pcd_name = {txt= name}}] ->
327
- Ast_untagged_variants. reportConstructorMoreThanOneArg ~loc: sdecl.ptype_loc ~name
327
+ | Ptype_variant [{pcd_args = Pcstr_tuple _}] -> ()
328
328
| Ptype_variant [{pcd_args = Pcstr_record
329
329
[{pld_mutable= Immutable ; _}]}] -> ()
330
330
| Ptype_variant [{pcd_args = Pcstr_record [{pld_mutable= Mutable ; _}]}] ->
0 commit comments