diff --git a/Zend/tests/const_expr_dim_on_null_warning.phpt b/Zend/tests/const_expr_dim_on_null_warning.phpt new file mode 100644 index 00000000000..9bea754446f --- /dev/null +++ b/Zend/tests/const_expr_dim_on_null_warning.phpt @@ -0,0 +1,10 @@ +--TEST-- +DIM on null in constant expr should emit warning +--FILE-- + +--EXPECTF-- +Warning: Trying to access array offset on value of type null in %s on line %d +NULL diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 924a2bb9a54..8be0c84c4c0 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -10544,7 +10544,7 @@ static void zend_eval_const_expr(zend_ast **ast_ptr) /* {{{ */ c = (zend_uchar) Z_STRVAL_P(container)[offset]; ZVAL_CHAR(&result, c); } else if (Z_TYPE_P(container) <= IS_FALSE) { - ZVAL_NULL(&result); + return; /* warning... handle at runtime */ } else { return; }