1
0
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:
Nikita Popov
2021-09-28 11:36:35 +02:00
2 changed files with 40 additions and 0 deletions

View File

@@ -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;

View 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