diff --git a/Zend/Optimizer/zend_inference.c b/Zend/Optimizer/zend_inference.c index f0d8d873977e..765fe253cbac 100644 --- a/Zend/Optimizer/zend_inference.c +++ b/Zend/Optimizer/zend_inference.c @@ -3716,7 +3716,9 @@ static zend_always_inline zend_result _zend_update_type_info( break; } } - if (opline->opcode != ZEND_FETCH_DIM_FUNC_ARG) { + if (opline->opcode != ZEND_FETCH_DIM_FUNC_ARG + && (opline->op2_type == IS_UNUSED + || !(t2 & (MAY_BE_ARRAY|MAY_BE_OBJECT)))) { tmp &= ~MAY_BE_ARRAY_EMPTY; } } diff --git a/Zend/tests/gh17144.phpt b/Zend/tests/gh17144.phpt new file mode 100644 index 000000000000..b9a39e9f8314 --- /dev/null +++ b/Zend/tests/gh17144.phpt @@ -0,0 +1,36 @@ +--TEST-- +GH-17144 (Assertion failure during type inference of ZEND_FETCH_DIM_W) +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.jit=1254 +--EXTENSIONS-- +opcache +--FILE-- + 1, + ]; + } +} + +function arrayKeyThrows() { + $a = []; + try { + $a[$a] = 1; + } catch (\Throwable $e) {} + return $a; +} + +var_dump(arrayKeyThrows()); +echo "Done\n"; +?> +--EXPECT-- +array(0) { +} +Done