diff --git a/ext/opcache/Optimizer/zend_inference.c b/ext/opcache/Optimizer/zend_inference.c index e108b7a4dd8..fa20795690c 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 00000000000..a6248ff5bdd --- /dev/null +++ b/ext/opcache/tests/ssa_bug_009.phpt @@ -0,0 +1,19 @@ +--TEST-- +Incorrect type inference +--FILE-- + +OK +--EXPECT-- +OK