mirror of
https://github.com/php/php-src.git
synced 2026-04-05 15:12:39 +02:00
Merge branch 'PHP-8.1'
* PHP-8.1: Undef result if undef dim warning promoted to exception
This commit is contained in:
@@ -581,6 +581,7 @@ static zval* ZEND_FASTCALL zend_jit_fetch_dim_rw_helper(zend_array *ht, zval *di
|
||||
goto str_index;
|
||||
case IS_UNDEF:
|
||||
if (!zend_jit_undefined_op_helper_write(ht, EG(current_execute_data)->opline->op2.var)) {
|
||||
undef_result_after_exception();
|
||||
return NULL;
|
||||
}
|
||||
ZEND_FALLTHROUGH;
|
||||
@@ -644,6 +645,7 @@ static zval* ZEND_FASTCALL zend_jit_fetch_dim_w_helper(zend_array *ht, zval *dim
|
||||
goto str_index;
|
||||
case IS_UNDEF:
|
||||
if (!zend_jit_undefined_op_helper_write(ht, EG(current_execute_data)->opline->op2.var)) {
|
||||
undef_result_after_exception();
|
||||
return NULL;
|
||||
}
|
||||
ZEND_FALLTHROUGH;
|
||||
|
||||
38
ext/opcache/tests/jit/assign_dim_undef_exception.phpt
Normal file
38
ext/opcache/tests/jit/assign_dim_undef_exception.phpt
Normal file
@@ -0,0 +1,38 @@
|
||||
--TEST--
|
||||
Undef to exception for assign dim offset
|
||||
--INI--
|
||||
opcache.enable=1
|
||||
opcache.enable_cli=1
|
||||
opcache.file_update_protection=0
|
||||
opcache.jit_buffer_size=1M
|
||||
--FILE--
|
||||
<?php
|
||||
set_error_handler(function($_, $m){
|
||||
throw new Exception($m);
|
||||
});
|
||||
function test1() {
|
||||
$a = [];
|
||||
$res = $a[$undef] = null;
|
||||
}
|
||||
function test2() {
|
||||
$a = [];
|
||||
$res = $a[$undef] += 1;
|
||||
}
|
||||
function test3() {
|
||||
$a = [];
|
||||
$res = isset($a[$undef]);
|
||||
}
|
||||
try {
|
||||
test1();
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
try {
|
||||
test2();
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
Undefined variable $undef
|
||||
Undefined variable $undef
|
||||
Reference in New Issue
Block a user