Skip to content

Commit 8c601ed

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: BIND_STATIC may throw
2 parents 133afe8 + b610dce commit 8c601ed

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

Zend/Optimizer/zend_inference.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4764,9 +4764,15 @@ ZEND_API int zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op,
47644764
return 1;
47654765
}
47664766
ZEND_FALLTHROUGH;
4767-
case ZEND_BIND_STATIC:
47684767
case ZEND_UNSET_VAR:
47694768
return (t1 & (MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_ARRAY_OF_RESOURCE|MAY_BE_ARRAY_OF_ARRAY));
4769+
case ZEND_BIND_STATIC:
4770+
if (t1 & (MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_ARRAY_OF_RESOURCE|MAY_BE_ARRAY_OF_ARRAY)) {
4771+
/* Destructor may throw. */
4772+
return 1;
4773+
}
4774+
/* TODO: May not throw if initializer is not CONSTANT_AST. */
4775+
return 1;
47704776
case ZEND_ASSIGN_DIM:
47714777
if ((opline+1)->op1_type == IS_CV) {
47724778
if (_ssa_op1_info(op_array, ssa, opline+1, ssa_op+1) & MAY_BE_UNDEF) {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Bind static may throw
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
--FILE--
9+
<?php
10+
function test() {
11+
static $N = UNDEFINED;
12+
throw new Exception;
13+
}
14+
try {
15+
test();
16+
} catch (Error $e) {
17+
echo $e->getMessage(), "\n";
18+
}
19+
20+
?>
21+
--EXPECT--
22+
Undefined constant "UNDEFINED"

0 commit comments

Comments
 (0)