DIM on null in const expr should emit warning

This commit is contained in:
Ilija Tovilo 2022-08-04 11:23:37 +02:00
parent 7b43d819c8
commit 3663f7661a
No known key found for this signature in database
GPG key ID: A4F5D403F118200A
2 changed files with 11 additions and 1 deletions

View 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

View file

@ -10544,7 +10544,7 @@ static void zend_eval_const_expr(zend_ast **ast_ptr) /* {{{ */
c = (zend_uchar) Z_STRVAL_P(container)[offset]; c = (zend_uchar) Z_STRVAL_P(container)[offset];
ZVAL_CHAR(&result, c); ZVAL_CHAR(&result, c);
} else if (Z_TYPE_P(container) <= IS_FALSE) { } else if (Z_TYPE_P(container) <= IS_FALSE) {
ZVAL_NULL(&result); return; /* warning... handle at runtime */
} else { } else {
return; return;
} }