]> granicus.if.org Git - php/commitdiff
Fixed bug #75687 (var 8 (TMP) has array key type but not value type)
authorXinchen Hui <laruence@gmail.com>
Sat, 16 Dec 2017 15:59:10 +0000 (23:59 +0800)
committerXinchen Hui <laruence@gmail.com>
Sat, 16 Dec 2017 15:59:10 +0000 (23:59 +0800)
NEWS
ext/opcache/Optimizer/zend_inference.c
ext/opcache/tests/bug75687.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index e8d8ef71e4c5333f3b2444f587bcd8c828b11be5..7dec72ca52176881e6a613f87defc35a4315e498 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,10 @@ PHP                                                                        NEWS
 - Core:
   . Fixed bug #75679 (Path 260 character problem). (Anatol)
 
+- Opcache:
+  . Fixed bug #75687 (var 8 (TMP) has array key type but not value type).
+    (Laruence)
+
 - PGSQL:
   . Fixed bug #75671 (pg_version() crashes when called on a connection to
     cockroach). (magicaltux at gmail dot com)
index dd49cc1a03d7ff34fc7d78d12656c435295af0ff..263df059f033e84e5610f2e77f16678c020a7848 100644 (file)
@@ -3338,6 +3338,9 @@ int zend_infer_types_ex(const zend_op_array *op_array, const zend_script *script
                                                        /* Ignore the constraint (either ce instanceof constraint->ce or
                                                         * they are unrelated, as far as we can statically determine) */
                                                }
+                                       } else if ((tmp & MAY_BE_ANY) == 0) {
+                                               /* FIXME: usage in unreachable block */
+                                               tmp |= MAY_BE_UNDEF;
                                        }
                                }
 
diff --git a/ext/opcache/tests/bug75687.phpt b/ext/opcache/tests/bug75687.phpt
new file mode 100644 (file)
index 0000000..67cf828
--- /dev/null
@@ -0,0 +1,21 @@
+--TEST--
+Bug #75687 (var 8 (TMP) has array key type but not value type)
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.optimization_level=-1
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+function x($y)
+{
+       if (is_array($y)) {
+               $z = is_array($y) ? array() : array($y);
+       }
+}
+?>
+okey
+--EXPECT--
+okey