Skip to content

Commit e5c0503

Browse files
committed
Commit merge conflicts
1 parent 921154f commit e5c0503

File tree

2 files changed

+54
-5
lines changed

2 files changed

+54
-5
lines changed

src/ocaml/typing/typeopt.ml

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -685,11 +685,38 @@ and value_kind_mixed_block_field env ~loc ~visited ~depth ~num_nodes_visited
685685
| Word -> num_nodes_visited, Word
686686
| Untagged_immediate -> num_nodes_visited, Untagged_immediate
687687
| Product fs ->
688-
let num_nodes_visited, kinds =
689-
Array.fold_left_map (fun num_nodes_visited field ->
690-
value_kind_mixed_block_field env ~loc ~visited ~depth ~num_nodes_visited
691-
field None
692-
) num_nodes_visited fs
688+
let unknown () = Array.init (Array.length fs) (fun _ -> None) in
689+
let types =
690+
match ty with
691+
| None -> unknown ()
692+
| Some ty ->
693+
let ty = scrape_ty env ty in
694+
match get_desc ty with
695+
| Tunboxed_tuple fields ->
696+
Misc.Stdlib.Array.of_list_map (fun (_, field) -> Some field) fields
697+
| Tconstr(p, _, _) ->
698+
begin match (Env.find_type p env).type_kind with
699+
| exception Not_found -> unknown ()
700+
| Type_record_unboxed_product (lbls, _, _) ->
701+
Misc.Stdlib.Array.of_list_map (fun {Types.ld_type} -> Some ld_type)
702+
lbls
703+
| Type_variant _ | Type_record _ | Type_abstract _ | Type_open ->
704+
(* We don't need to handle [@@unboxed] records/variants here,
705+
because [scrape_ty] looks though them. *)
706+
unknown ()
707+
end
708+
| Tvar _ | Tarrow _ | Ttuple _ | Tobject _ | Tfield _ | Tnil
709+
| Tlink _ | Tsubst _ | Tvariant _ | Tunivar _ | Tpoly _ | Tpackage _
710+
| Tof_kind _ -> unknown ()
711+
in
712+
let (_, num_nodes_visited), kinds =
713+
Array.fold_left_map (fun (i, num_nodes_visited) field ->
714+
let num_nodes_visited, kind =
715+
value_kind_mixed_block_field env ~loc ~visited ~depth
716+
~num_nodes_visited field types.(i)
717+
in
718+
(i + 1, num_nodes_visited), kind
719+
) (0, num_nodes_visited) fs
693720
in
694721
num_nodes_visited, Product kinds
695722
| Void -> num_nodes_visited, Product [||]
@@ -931,6 +958,16 @@ let value_kind env loc ty =
931958
with
932959
| Missing_cmi_fallback -> raise (Error (loc, Non_value_layout (ty, None)))
933960
961+
let transl_mixed_block_element env loc ty mbe =
962+
try
963+
let (_num_nodes_visited, value_kind) =
964+
value_kind_mixed_block_field env ~loc ~visited:Numbers.Int.Set.empty
965+
~depth:0 ~num_nodes_visited:0 mbe (Some ty)
966+
in
967+
value_kind
968+
with
969+
| Missing_cmi_fallback -> raise (Error (loc, Non_value_layout (ty, None)))
970+
934971
let[@inline always] rec layout_of_const_sort_generic ~value_kind ~error
935972
: Jkind.Sort.Const.t -> _ = function
936973
| Base Value -> Lambda.Pvalue (Lazy.force value_kind)

src/ocaml/typing/typeopt.mli

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ val bigarray_specialize_kind_and_layout :
4949
val value_kind : Env.t -> Types.type_expr -> Lambda.value_kind
5050
*)
5151

52+
<<<<<<< janestreet/merlin-jst:merge-5.2.0minus-18
53+
||||||| ocaml-flambda/flambda-backend:0ac8fae40c9729a24ef59fa55b51d70247ac5274
54+
val value_kind : Env.t -> Location.t -> Types.type_expr -> Lambda.value_kind
55+
56+
=======
57+
val value_kind : Env.t -> Location.t -> Types.type_expr -> Lambda.value_kind
58+
59+
val transl_mixed_block_element :
60+
Env.t -> Location.t -> Types.type_expr -> Types.mixed_block_element
61+
-> unit Lambda.mixed_block_element
62+
63+
>>>>>>> ocaml-flambda/flambda-backend:dec889241a60580e1390742671f8dc1ce679cf33
5264
val classify_lazy_argument : Typedtree.expression ->
5365
[ `Constant_or_function
5466
| `Float_that_cannot_be_shortcut

0 commit comments

Comments
 (0)