@@ -304,27 +304,27 @@ let transl_declaration ~typeRecordAsObject env sdecl id =
304304 in
305305 let raw_status = get_unboxed_from_attributes sdecl in
306306
307- let checkUntaggedVariant = match sdecl.ptype_kind with
307+ let checkUntaggedVariant() = match sdecl.ptype_kind with
308308 | Ptype_variant cds -> Ext_list. for_all cds (function
309309 | {pcd_args = Pcstr_tuple ([] | [_])} ->
310310 (* at most one payload allowed for untagged variants *)
311311 true
312+ | {pcd_args = Pcstr_tuple (_ ::_ ::_ ); pcd_name ={txt =name } } ->
313+ Ast_untagged_variants. reportConstructorMoreThanOneArg ~loc: sdecl.ptype_loc ~name
312314 | {pcd_args = Pcstr_record _ } -> true
313- | _ -> false )
315+ )
314316 | _ -> false
315317 in
316318
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
318320 match sdecl.ptype_kind with
319321 | Ptype_abstract ->
320322 raise(Error (sdecl.ptype_loc, Bad_unboxed_attribute
321323 " it is abstract" ))
322324 | Ptype_variant [{pcd_args = Pcstr_tuple [] }] ->
323325 raise(Error (sdecl.ptype_loc, Bad_unboxed_attribute
324326 " 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 _}] -> ()
328328 | Ptype_variant [{pcd_args = Pcstr_record
329329 [{pld_mutable= Immutable ; _}]}] -> ()
330330 | Ptype_variant [{pcd_args = Pcstr_record [{pld_mutable= Mutable ; _}]}] ->
0 commit comments