|
@@ -2586,6 +2586,15 @@ and type_access ctx e p mode =
|
|
|
| _ ->
|
|
|
AKExpr (type_expr ctx (e,p) Value)
|
|
|
|
|
|
+and should_be_nullable_array_access ctx array_type access_mode =
|
|
|
+ if access_mode = MSet then
|
|
|
+ false
|
|
|
+ else
|
|
|
+ match array_type with
|
|
|
+ | TInst ({ cl_path = [],"Array"},[t]) ->
|
|
|
+ not ((Common.defined ctx.com Define.Static) && (type_has_meta (Abstract.follow_with_abstracts t) Meta.NotNull))
|
|
|
+ | _ -> false
|
|
|
+
|
|
|
and type_array_access ctx e1 e2 p mode =
|
|
|
let e1 = type_expr ctx e1 Value in
|
|
|
let e2 = type_expr ctx e2 Value in
|
|
@@ -2617,8 +2626,8 @@ and type_array_access ctx e1 e2 p mode =
|
|
|
t_dynamic
|
|
|
| TAbstract(a,tl) when Meta.has Meta.ArrayAccess a.a_meta ->
|
|
|
loop (apply_params a.a_params tl a.a_this)
|
|
|
- | _ ->
|
|
|
- let pt = mk_mono() in
|
|
|
+ | t ->
|
|
|
+ let pt = if should_be_nullable_array_access ctx t mode then ctx.t.tnull (mk_mono()) else mk_mono() in
|
|
|
let t = ctx.t.tarray pt in
|
|
|
(try unify_raise ctx et t p
|
|
|
with Error(Unify _,_) -> if not ctx.untyped then begin
|