]> granicus.if.org Git - php/commitdiff
Inference: $a[]= results in long keys
authorNikita Popov <nikic@php.net>
Sat, 14 May 2016 14:49:52 +0000 (16:49 +0200)
committerNikita Popov <nikic@php.net>
Sat, 14 May 2016 15:16:32 +0000 (17:16 +0200)
ext/opcache/Optimizer/zend_inference.c

index 06f3cdc670d519fb6f744a9f267d370e134cb7e9..fd39baf749e0acf4566a1e65c6d162e7884fd2f2 100644 (file)
@@ -2215,18 +2215,22 @@ static uint32_t assign_dim_result_type(
                if (value_type & MAY_BE_UNDEF) {
                        tmp |= MAY_BE_ARRAY_OF_NULL;
                }
-               if (dim_type & (MAY_BE_LONG|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_RESOURCE|MAY_BE_DOUBLE)) {
+               if (dim_op_type == IS_UNUSED) {
                        tmp |= MAY_BE_ARRAY_KEY_LONG;
-               }
-               if (dim_type & MAY_BE_STRING) {
-                       tmp |= MAY_BE_ARRAY_KEY_STRING;
-                       if (dim_op_type != IS_CONST) {
-                               // FIXME: numeric string
+               } else {
+                       if (dim_type & (MAY_BE_LONG|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_RESOURCE|MAY_BE_DOUBLE)) {
                                tmp |= MAY_BE_ARRAY_KEY_LONG;
                        }
-               }
-               if (dim_type & (MAY_BE_UNDEF|MAY_BE_NULL)) {
-                       tmp |= MAY_BE_ARRAY_KEY_STRING;
+                       if (dim_type & MAY_BE_STRING) {
+                               tmp |= MAY_BE_ARRAY_KEY_STRING;
+                               if (dim_op_type != IS_CONST) {
+                                       // FIXME: numeric string
+                                       tmp |= MAY_BE_ARRAY_KEY_LONG;
+                               }
+                       }
+                       if (dim_type & (MAY_BE_UNDEF|MAY_BE_NULL)) {
+                               tmp |= MAY_BE_ARRAY_KEY_STRING;
+                       }
                }
        }
        return tmp;
@@ -2474,7 +2478,7 @@ static void zend_update_type_info(const zend_op_array *op_array,
                                if (t1 & MAY_BE_OBJECT) {
                                        tmp |= MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
                                } else {
-                                       tmp |= (t1 & MAY_BE_ANY) << MAY_BE_ARRAY_SHIFT;
+                                       tmp |= ((t1 & MAY_BE_ANY) << MAY_BE_ARRAY_SHIFT) | MAY_BE_ARRAY_KEY_LONG;
                                }
                        }
                        UPDATE_SSA_TYPE(tmp, ssa_ops[i].result_def);