summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2017-10-30 10:44:12 +0300
committerDmitry Stogov <dmitry@zend.com>2017-10-30 10:44:12 +0300
commit49256dcf6fb746b8df5ad5d6f04f5f5eda0fb85a (patch)
tree556b1e5c3e076872cf03531e3ce6e31165e45d55
parent1a72d3225cfe03edcfcab49070bd7a6806b7958d (diff)
parent230e505fd8decde99af720fd640e70aaa297b5e2 (diff)
downloadphp-git-49256dcf6fb746b8df5ad5d6f04f5f5eda0fb85a.tar.gz
Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1: Fixed type inference
-rw-r--r--ext/opcache/Optimizer/zend_inference.c8
-rw-r--r--ext/opcache/tests/ssa_bug_009.phpt19
2 files changed, 26 insertions, 1 deletions
diff --git a/ext/opcache/Optimizer/zend_inference.c b/ext/opcache/Optimizer/zend_inference.c
index e108b7a4dd..fa20795690 100644
--- a/ext/opcache/Optimizer/zend_inference.c
+++ b/ext/opcache/Optimizer/zend_inference.c
@@ -3083,7 +3083,13 @@ static int zend_update_type_info(const zend_op_array *op_array,
}
j = zend_ssa_next_use(ssa_ops, ssa_ops[i].result_def, j);
}
- UPDATE_SSA_TYPE(tmp, ssa_ops[i].op1_def);
+ if ((tmp & MAY_BE_ARRAY)
+ && (tmp & (MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING))) {
+ UPDATE_SSA_TYPE(tmp, ssa_ops[i].op1_def);
+ } else {
+ /* invalid key type */
+ UPDATE_SSA_TYPE(t1, ssa_ops[i].op1_def);
+ }
COPY_SSA_OBJ_TYPE(ssa_ops[i].op1_use, ssa_ops[i].op1_def);
}
/* FETCH_LIST on a string behaves like FETCH_R on null */
diff --git a/ext/opcache/tests/ssa_bug_009.phpt b/ext/opcache/tests/ssa_bug_009.phpt
new file mode 100644
index 0000000000..a6248ff5bd
--- /dev/null
+++ b/ext/opcache/tests/ssa_bug_009.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Incorrect type inference
+--FILE--
+<?php
+class PHP_CodeCoverage
+{
+ private function addUncoveredFilesFromWhitelist()
+ {
+ foreach ($uncoveredFiles as $uncoveredFile) {
+ for ($i = 1; $i <= $lines; $i++) {
+ $data[$uncoveredFile][$i] = PHP_CodeCoverage_Driver::LINE_NOT_EXECUTED;
+ }
+ }
+ }
+}
+?>
+OK
+--EXPECT--
+OK