@@ -6178,23 +6178,17 @@ end = struct
61786178 let mk_prop ~subtype_env ~this_ty ~lhs ~rhs =
61796179 simplify ~subtype_env ~this_ty ~lhs ~rhs
61806180 in
6181- let is_container tk tv =
6181+ let simplify_default ~ subtype_env lhs rhs env =
61826182 Subtype. simplify
61836183 ~subtype_env
61846184 ~this_ty
6185- ~lhs: { sub_supportdyn; ty_sub = can_index.ci_key }
6186- ~rhs: { super_like = false ; super_supportdyn = false ; ty_super = tk }
6185+ ~lhs: { sub_supportdyn; ty_sub = lhs }
6186+ ~rhs: { super_like = false ; super_supportdyn = false ; ty_super = rhs }
61876187 env
6188- &&& Subtype. simplify
6189- ~subtype_env
6190- ~this_ty
6191- ~lhs: { sub_supportdyn; ty_sub = tv }
6192- ~rhs:
6193- {
6194- super_like = false ;
6195- super_supportdyn = false ;
6196- ty_super = can_index.ci_val;
6197- }
6188+ in
6189+ let is_container tk tv =
6190+ simplify_default ~subtype_env can_index.ci_key tk env
6191+ &&& simplify_default ~subtype_env tv can_index.ci_val
61986192 in
61996193 match deref ty_sub with
62006194 | (_ , Tvar _ ) ->
@@ -6206,16 +6200,10 @@ end = struct
62066200 (ConstraintType
62076201 (mk_constraint_type (reason_super, Tcan_index can_index)))
62086202 | (_ , Tdynamic) ->
6209- Subtype. simplify
6203+ simplify_default
62106204 ~subtype_env
6211- ~this_ty
6212- ~lhs: { sub_supportdyn; ty_sub = MakeType. dynamic reason_super }
6213- ~rhs:
6214- {
6215- super_like = false ;
6216- super_supportdyn = false ;
6217- ty_super = can_index.ci_val;
6218- }
6205+ (MakeType. dynamic reason_super)
6206+ can_index.ci_val
62196207 env
62206208 &&&
62216209 if
@@ -6225,16 +6213,10 @@ end = struct
62256213 let subtype_env =
62266214 { subtype_env with coerce = Some Typing_logic. CoerceToDynamic }
62276215 in
6228- Subtype. simplify
6216+ simplify_default
62296217 ~subtype_env
6230- ~this_ty
6231- ~lhs: { sub_supportdyn; ty_sub = can_index.ci_key }
6232- ~rhs:
6233- {
6234- super_like = false ;
6235- super_supportdyn = false ;
6236- ty_super = MakeType. dynamic (get_reason ty_sub);
6237- }
6218+ can_index.ci_key
6219+ (MakeType. dynamic (get_reason ty_sub))
62386220 else
62396221 valid
62406222 | (_, Tclass ((_, n), _, [tv]))
@@ -6264,6 +6246,35 @@ end = struct
62646246 (sub_supportdyn, ty_subs)
62656247 rhs
62666248 env
6249+ | (_ , Ttuple tup ) ->
6250+ (match can_index.ci_shape with
6251+ | IntLit i ->
6252+ (match List. nth tup.t_required i with
6253+ | Some ty -> simplify_default ~subtype_env ty can_index.ci_val env
6254+ | None ->
6255+ invalid
6256+ ~fail:
6257+ (Some
6258+ Typing_error. (
6259+ primary
6260+ @@ Primary. Generic_unify
6261+ {
6262+ pos = can_index.ci_index_pos;
6263+ msg = Reason. string_of_ureason Reason. index_tuple;
6264+ }))
6265+ env)
6266+ | _ ->
6267+ invalid
6268+ ~fail:
6269+ (Some
6270+ Typing_error. (
6271+ primary
6272+ @@ Primary. Generic_unify
6273+ {
6274+ pos = can_index.ci_index_pos;
6275+ msg = Reason. string_of_ureason Reason. URtuple_access ;
6276+ }))
6277+ env)
62676278 | _ -> invalid ~fail env
62686279end
62696280
0 commit comments