Skip to content

Commit e05f366

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Don't unconditionally add array value type for undef
2 parents 7e565da + 3733750 commit e05f366

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Zend/Optimizer/zend_inference.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2126,7 +2126,7 @@ static uint32_t assign_dim_result_type(
21262126
* key type exists iff a value type exists even in dead code that may use empty types. */
21272127
if (value_type & (MAY_BE_ANY|MAY_BE_UNDEF)) {
21282128
if (value_type & MAY_BE_UNDEF) {
2129-
tmp |= MAY_BE_ARRAY_OF_NULL;
2129+
value_type |= MAY_BE_NULL;
21302130
}
21312131
if (dim_op_type == IS_UNUSED) {
21322132
tmp |= MAY_BE_HASH_ONLY(arr_type) ? MAY_BE_ARRAY_NUMERIC_HASH : MAY_BE_ARRAY_KEY_LONG;

ext/opcache/tests/invalid_array_key_type.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ function test(\SplObjectStorage $definitions = null) {
1313
$definitions[$argument] = 1;
1414
$definitions[$argument] += 1;
1515
}
16+
function test2() {
17+
$a[[]] = $undef;
18+
}
1619

1720
?>
1821
===DONE===

0 commit comments

Comments
 (0)