mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
DIM on null in const expr should emit warning
This commit is contained in:
parent
7b43d819c8
commit
3663f7661a
2 changed files with 11 additions and 1 deletions
10
Zend/tests/const_expr_dim_on_null_warning.phpt
Normal file
10
Zend/tests/const_expr_dim_on_null_warning.phpt
Normal file
|
@ -0,0 +1,10 @@
|
|||
--TEST--
|
||||
DIM on null in constant expr should emit warning
|
||||
--FILE--
|
||||
<?php
|
||||
const C = (null)['foo'];
|
||||
var_dump(C);
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: Trying to access array offset on value of type null in %s on line %d
|
||||
NULL
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue