Skip to content

Commit de2dc18

Browse files
committed
Include existing arity information
1 parent 6905665 commit de2dc18

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

compiler/ml/typecore.ml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2864,9 +2864,17 @@ and type_expect_ ?deprecated_context ~context ?in_function ?(recarg = Rejected)
28642864
let index =
28652865
type_expect ~context:None env sindex (instance_def Predef.type_int)
28662866
in
2867-
let element_type = newgenvar () in
2868-
let array_type = instance_def (Predef.type_array element_type) in
2869-
unify_exp ~context:None env container array_type;
2867+
(* Extract element type from container to preserve arity information *)
2868+
let element_type =
2869+
match (expand_head env container.exp_type).desc with
2870+
| Tconstr (Pident {name = "array"}, [element_ty], _) -> element_ty
2871+
| _ ->
2872+
(* Fallback: create fresh type variable and unify *)
2873+
let element_type = newgenvar () in
2874+
let array_type = instance_def (Predef.type_array element_type) in
2875+
unify_exp ~context:None env container array_type;
2876+
element_type
2877+
in
28702878
let value = type_expect ~context:None env svalue element_type in
28712879
rue
28722880
{

0 commit comments

Comments
 (0)