Skip to content

Commit a4c41d4

Browse files
committed
Fixed type inference for COPY_TMP
1 parent ccdda69 commit a4c41d4

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

ext/opcache/Optimizer/zend_inference.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2518,7 +2518,7 @@ static zend_always_inline int _zend_update_type_info(
25182518
tmp |= MAY_BE_RCN;
25192519
}
25202520
}
2521-
if (opline->opcode != ZEND_QM_ASSIGN) {
2521+
if (opline->opcode == ZEND_COALESCE || opline->opcode == ZEND_JMP_SET) {
25222522
/* COALESCE and JMP_SET result can't be null */
25232523
tmp &= ~MAY_BE_NULL;
25242524
if (opline->opcode == ZEND_JMP_SET) {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
JIT COPY_TMP: 001
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
opcache.protect_memory=1
9+
--FILE--
10+
<?php
11+
function test() {
12+
echo "";
13+
}
14+
15+
$a = [];
16+
$a[test()] ??= 1;
17+
var_dump($a);
18+
?>
19+
--EXPECT--
20+
array(1) {
21+
[""]=>
22+
int(1)
23+
}

0 commit comments

Comments
 (0)