@@ -107,10 +107,10 @@ let constructor_args ~current_unit priv cd_args cd_res path rep =
107107
108108let constructor_descrs ~current_unit ty_path decl cstrs rep =
109109 let ty_res = newgenconstr ty_path decl.type_params in
110- let cstr_shapes_and_arg_jkinds =
110+ let cstr_shapes_and_arg_jkinds, is_unboxed =
111111 match rep, cstrs with
112112 | Variant_extensible , _ -> assert false
113- | Variant_boxed x , _ -> x
113+ | Variant_boxed x , _ -> x, false
114114 | Variant_unboxed , [{ cd_args }] ->
115115 (* CR layouts: It's tempting just to use [decl.type_jkind] here, instead
116116 of grabbing the jkind from the argument. However, doing so does not
@@ -124,7 +124,7 @@ let constructor_descrs ~current_unit ty_path decl cstrs rep =
124124 begin match cd_args with
125125 | Cstr_tuple [{ ca_sort = sort }]
126126 | Cstr_record [{ ld_sort = sort }] ->
127- [| Constructor_uniform_value , [| sort |] |]
127+ [| Constructor_uniform_value , [| sort |] |], true
128128 | Cstr_tuple ([] | _ :: _ ) | Cstr_record ([] | _ :: _ ) ->
129129 Misc. fatal_error " Multiple arguments in [@@unboxed] variant"
130130 end
@@ -135,15 +135,19 @@ let constructor_descrs ~current_unit ty_path decl cstrs rep =
135135 users to write their own null constructors. *)
136136 (* CR layouts v3.3: generalize to [any]. *)
137137 [| Constructor_uniform_value , [| |]
138- ; Constructor_uniform_value , [| Jkind.Sort.Const. value |] |]
138+ ; Constructor_uniform_value , [| Jkind.Sort.Const. value |] |],
139+ false
139140 in
140141 let num_consts = ref 0 and num_nonconsts = ref 0 in
141142 let cstr_constant =
142143 Array. map
143144 (fun (_ , sorts ) ->
144145 let all_void = Array. for_all Jkind.Sort.Const. all_void sorts in
145- if all_void then incr num_consts else incr num_nonconsts;
146- all_void)
146+ (* constant constructors are constructors of non-[@@unboxed] variants
147+ with 0 bits of payload *)
148+ let is_const = all_void && not is_unboxed in
149+ if is_const then incr num_consts else incr num_nonconsts;
150+ is_const)
147151 cstr_shapes_and_arg_jkinds
148152 in
149153 let describe_constructor (src_index , const_tag , nonconst_tag , acc )
0 commit comments