Skip to content

Commit 3663f76

Browse files
committed
DIM on null in const expr should emit warning
1 parent 7b43d81 commit 3663f76

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
DIM on null in constant expr should emit warning
3+
--FILE--
4+
<?php
5+
const C = (null)['foo'];
6+
var_dump(C);
7+
?>
8+
--EXPECTF--
9+
Warning: Trying to access array offset on value of type null in %s on line %d
10+
NULL

Zend/zend_compile.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -10544,7 +10544,7 @@ static void zend_eval_const_expr(zend_ast **ast_ptr) /* {{{ */
1054410544
c = (zend_uchar) Z_STRVAL_P(container)[offset];
1054510545
ZVAL_CHAR(&result, c);
1054610546
} else if (Z_TYPE_P(container) <= IS_FALSE) {
10547-
ZVAL_NULL(&result);
10547+
return; /* warning... handle at runtime */
1054810548
} else {
1054910549
return;
1055010550
}

0 commit comments

Comments
 (0)