Skip to content

Commit 8b8b625

Browse files
committed
Fixed bug #72635
This seems to be a simple oversight, where we did not enable exceptions. Other constexpr conditions already throw, so there is no particular reason to stick to a fatal error here.
1 parent 7189e0b commit 8b8b625

File tree

7 files changed

+27
-6
lines changed

7 files changed

+27
-6
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ PHP NEWS
66
. Fixed bug #76846 (Segfault in shutdown function after memory limit error).
77
(Nikita)
88
. Fixed bug #76946 (Cyclic reference in generator not detected). (Nikita)
9+
. Fixed bug #72635 (Undefined class used by class constant in constexpr
10+
generates fatal error). (Nikita)
911

1012
27 Sep 2018, PHP 7.3.0RC2
1113

Zend/tests/bug43344_3.phpt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@ function f($a=Foo::bar) {
99
echo f()."\n";
1010
?>
1111
--EXPECTF--
12-
Fatal error: Class 'Foo\Foo' not found in %sbug43344_3.php on line %d
12+
Fatal error: Uncaught Error: Class 'Foo\Foo' not found in %s:%d
13+
Stack trace:
14+
#0 %s(%d): Foo\f()
15+
#1 {main}
16+
thrown in %s on line %d

Zend/tests/bug43344_4.phpt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@ function f($a=array(Foo::bar)) {
99
echo f()."\n";
1010
?>
1111
--EXPECTF--
12-
Fatal error: Class 'Foo\Foo' not found in %sbug43344_4.php on line %d
12+
Fatal error: Uncaught Error: Class 'Foo\Foo' not found in %s:%d
13+
Stack trace:
14+
#0 %s(%d): Foo\f()
15+
#1 {main}
16+
thrown in %s on line %d

Zend/tests/bug43344_5.phpt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,8 @@ function f($a=array(Foo::bar=>0)) {
1010
echo f()."\n";
1111
?>
1212
--EXPECTF--
13-
Fatal error: Class 'Foo\Foo' not found in %sbug43344_5.php on line %d
13+
Fatal error: Uncaught Error: Class 'Foo\Foo' not found in %s:%d
14+
Stack trace:
15+
#0 %s(%d): Foo\f()
16+
#1 {main}
17+
thrown in %s on line %d

Zend/tests/class_constants_002.phpt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,8 @@ int(1)
2828
int(5)
2929
int(10)
3030

31-
Fatal error: Class 'NoSuchClass' not found in %s on line %d
31+
Fatal error: Uncaught Error: Class 'NoSuchClass' not found in %s:%d
32+
Stack trace:
33+
#0 %s(%d): bar()
34+
#1 {main}
35+
thrown in %s on line %d

Zend/zend_compile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8033,7 +8033,7 @@ void zend_compile_const_expr_class_const(zend_ast **ast_ptr) /* {{{ */
80338033
zend_ast_destroy(ast);
80348034
zend_string_release_ex(class_name, 0);
80358035

8036-
*ast_ptr = zend_ast_create_constant(name, fetch_type);
8036+
*ast_ptr = zend_ast_create_constant(name, fetch_type | ZEND_FETCH_CLASS_EXCEPTION);
80378037
}
80388038
/* }}} */
80398039

tests/classes/constants_error_004.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@ Class constant whose initial value references a non-existent class
1010
$a = new C();
1111
?>
1212
--EXPECTF--
13-
Fatal error: Class 'D' not found in %s on line %d
13+
Fatal error: Uncaught Error: Class 'D' not found in %s:%d
14+
Stack trace:
15+
#0 {main}
16+
thrown in %s on line %d

0 commit comments

Comments
 (0)