Skip to content

Commit 6144524

Browse files
committed
Don't unconditionally add array value type for undef
We have an invariant that an array value type is set if and only if an array key type is set, which is violated for the case of undef values for always invalid keys.
1 parent f4bcf8c commit 6144524

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

ext/opcache/Optimizer/zend_inference.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2047,7 +2047,7 @@ static uint32_t assign_dim_result_type(
20472047
* key type exists iff a value type exists even in dead code that may use empty types. */
20482048
if (value_type & (MAY_BE_ANY|MAY_BE_UNDEF)) {
20492049
if (value_type & MAY_BE_UNDEF) {
2050-
tmp |= MAY_BE_ARRAY_OF_NULL;
2050+
value_type |= MAY_BE_NULL;
20512051
}
20522052
if (dim_op_type == IS_UNUSED) {
20532053
tmp |= 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)