mirror of
https://github.com/php/php-src.git
synced 2026-04-02 13:43:02 +02:00
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1: Fix GH-9769: Misleading error message for unpacking of objects
This commit is contained in:
1
NEWS
1
NEWS
@@ -10,6 +10,7 @@ PHP NEWS
|
||||
. Fixed bug GH-9890 (OpenSSL legacy providers not available on Windows). (cmb)
|
||||
. Fixed bug GH-9650 (Can't initialize heap: [0x000001e7]). (Michael Voříšek)
|
||||
. Fixed potentially undefined behavior in Windows ftok(3) emulation. (cmb)
|
||||
. Fixed GH-9769 (Misleading error message for unpacking of objects). (jhdxr)
|
||||
|
||||
- FPM:
|
||||
. Fixed bug GH-9959 (Solaris port event mechanism is still broken after bug
|
||||
|
||||
15
Zend/tests/array_unpack/gh9769.phpt
Normal file
15
Zend/tests/array_unpack/gh9769.phpt
Normal file
@@ -0,0 +1,15 @@
|
||||
--TEST--
|
||||
Unpacking arrays in constant expression
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
const A = [...[1, 2, 3]];
|
||||
const B = [...['a'=>1, 'b'=>2, 'c'=>3]];
|
||||
const C = [...new ArrayObject()];
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Uncaught Error: Only arrays can be unpacked in constant expression in %sgh9769.php:5
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in %sgh9769.php on line 5
|
||||
@@ -488,8 +488,7 @@ static zend_result zend_ast_add_unpacked_element(zval *result, zval *expr) {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/* Objects or references cannot occur in a constant expression. */
|
||||
zend_throw_error(NULL, "Only arrays and Traversables can be unpacked");
|
||||
zend_throw_error(NULL, "Only arrays can be unpacked in constant expression");
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user